| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark" width="{localWidth}" width.hovered="{localWidthHover}" height.normal="{localHeight}" height.hovered="{localHeightHover}" autoDrawBackground="false"> |
| <fx:Script> |
| <![CDATA[ |
| [Bindable] public var localHeight:int = 0; |
| [Bindable] public var localHeightHover:int = 0; |
| |
| [Bindable] public var localWidth:int = 0; |
| [Bindable] public var localWidthHover:int = 0; |
| |
| override public function set data(value:Object):void { |
| super.data = value; |
| |
| if(value == null){ |
| // the guts behind virtualization will set the data to null sometimes |
| return; |
| } |
| |
| lbl.text = data.myItemIndex; |
| |
| if (value.majorAxis == "vertical"){ |
| // majorSize is height |
| |
| this.localHeight = value.majorSize; |
| this.localHeightHover = value.majorSize * 2; |
| |
| this.localWidth = value.minorSize; |
| this.localWidthHover = value.minorSize; |
| |
| backgroundGradient.fill = verticalGradient; |
| |
| } else if (value.majorAxis == "horizontal") { |
| // majorSize is width |
| |
| this.localWidth = value.majorSize; |
| this.localWidthHover = value.majorSize * 2; |
| |
| this.localHeight = value.minorSize; |
| this.localHeightHover = value.minorSize; |
| |
| backgroundGradient.fill = horizontalGradient; |
| |
| } else { |
| throw new Error('invalid axis'); |
| } |
| |
| } |
| ]]> |
| </fx:Script> |
| |
| <fx:Declarations> |
| <s:LinearGradient id="verticalGradient" rotation="90"> |
| <s:entries> |
| <mx:GradientEntry color="0x111111" /> |
| <mx:GradientEntry color="0x888888" color.hovered="0x111111" /> |
| </s:entries> |
| </s:LinearGradient> |
| |
| <s:LinearGradient id="horizontalGradient" rotation="0"> |
| <s:entries> |
| <mx:GradientEntry color="0x111111" /> |
| <mx:GradientEntry color="0x888888" color.hovered="0x111111" /> |
| </s:entries> |
| </s:LinearGradient> |
| </fx:Declarations> |
| |
| <s:states> |
| <mx:State name="normal"/> |
| <mx:State name="hovered"/> |
| <mx:State name="selected"/> |
| </s:states> |
| |
| <s:Rect id="backgroundGradient" top="0" left="0" right="0" bottom="0"></s:Rect> |
| |
| <mx:Label id="lbl" color="0xFFFFFF" /> |
| |
| </s:ItemRenderer> |