Repository: flex-sdk Updated Branches: refs/heads/new_android_skins 10f8840fb -> 074a2f445
New skin and FXG for RadioButton. It uses the same FXG assets for all the DPIs Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/074a2f44 Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/074a2f44 Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/074a2f44 Branch: refs/heads/new_android_skins Commit: 074a2f44523ff1ed9857bbcbc5427a75ff45b59e Parents: 10f8840 Author: Om <[email protected]> Authored: Fri Mar 28 19:56:55 2014 -0700 Committer: Om <[email protected]> Committed: Fri Mar 28 19:56:55 2014 -0700 ---------------------------------------------------------------------- .../src/spark/skins/android4/RadioButtonSkin.as | 253 +++++++++++++++++++ .../skins/android4/assets/RadioButton_down.fxg | 34 +++ .../assets/RadioButton_downSymbolSelected.fxg | 29 +++ .../skins/android4/assets/RadioButton_up.fxg | 29 +++ .../assets/RadioButton_upSymbolSelected.fxg | 36 +++ 5 files changed, 381 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/074a2f44/frameworks/projects/mobiletheme/src/spark/skins/android4/RadioButtonSkin.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/mobiletheme/src/spark/skins/android4/RadioButtonSkin.as b/frameworks/projects/mobiletheme/src/spark/skins/android4/RadioButtonSkin.as new file mode 100644 index 0000000..fd74645 --- /dev/null +++ b/frameworks/projects/mobiletheme/src/spark/skins/android4/RadioButtonSkin.as @@ -0,0 +1,253 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +package spark.skins.android4 +{ + +import flash.display.DisplayObject; + +import mx.core.DPIClassification; + +import spark.skins.android4.assets.RadioButton_up; +import spark.skins.mobile.supportClasses.SelectableButtonSkinBase; + +/** + * ActionScript-based skin for RadioButton controls in mobile applications. + * + * @see spark.components.RadioButton + * + * @langversion 3.0 + * @playerversion Flash 10 + * @playerversion AIR 2.5 + * @productversion Flex 4.5 + */ +public class RadioButtonSkin extends SelectableButtonSkinBase +{ + //-------------------------------------------------------------------------- + // + // Class constants + // + //-------------------------------------------------------------------------- + + /** + * @private + */ + static private const exclusions:Array = ["labelDisplay", "labelDisplayShadow"]; + + //-------------------------------------------------------------------------- + // + // Member variables + // + //-------------------------------------------------------------------------- + + protected var symbolOffsetX:Number; + protected var symbolOffsetY:Number; + protected var iconWidth:Number; + protected var iconHeight:Number; + protected var symbolWidth:Number; + protected var symbolHeight:Number; + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10 + * @playerversion AIR 2.5 + * @productversion Flex 4.5 + * + */ + public function RadioButtonSkin() + { + super(); + + layoutPaddingLeft = 0; + layoutPaddingRight = 0; + layoutPaddingTop = 0; + layoutPaddingBottom = 0; + + upIconClass = spark.skins.android4.assets.RadioButton_up; + upSelectedIconClass = spark.skins.android4.assets.RadioButton_up; + downIconClass = spark.skins.android4.assets.RadioButton_down; + downSelectedIconClass = spark.skins.android4.assets.RadioButton_down; + upSymbolIconClass = null; + downSymbolIconClass = null; + upSymbolIconSelectedClass = spark.skins.android4.assets.RadioButton_upSymbolSelected; + downSymbolIconSelectedClass = spark.skins.android4.assets.RadioButton_downSymbolSelected; + + switch (applicationDPI) + { + case DPIClassification.DPI_640: + { + + layoutGap = 16; + minWidth = 128; + minHeight = 128; + iconWidth = 128; + iconHeight = 128; + symbolWidth = 44; + symbolHeight = 44; + symbolOffsetX = 44; + symbolOffsetY = 44; + + break; + } + case DPIClassification.DPI_480: + { + + layoutGap = 12; + minWidth = 96; + minHeight = 96; + iconWidth = 96; + iconHeight = 96; + symbolWidth = 33; + symbolHeight = 33; + symbolOffsetX = 33; + symbolOffsetY = 33; + + break; + } + case DPIClassification.DPI_320: + { + + layoutGap = 8; + minWidth = 64; + minHeight = 64; + iconWidth = 64; + iconHeight = 64; + symbolWidth = 22; + symbolHeight = 22; + symbolOffsetX = 22; + symbolOffsetY = 22; + + break; + } + case DPIClassification.DPI_240: + { + + layoutGap = 6; + minWidth = 48; + minHeight = 48; + iconWidth = 48; + iconHeight = 48; + symbolWidth = 16.5; + symbolHeight = 16.5; + symbolOffsetX = 16.5; + symbolOffsetY = 16.5; + + break; + } + case DPIClassification.DPI_120: + { + + layoutGap = 3; + minWidth = 24; + minHeight = 24; + iconWidth = 24; + iconHeight = 24; + symbolWidth = 8.25; + symbolHeight = 8.25; + symbolOffsetX = 8.25; + symbolOffsetY = 8.25; + + break; + } + default: + { + + layoutGap = 4; + minWidth = 32; + minHeight = 32; + iconWidth = 32; + iconHeight = 32; + symbolWidth = 11; + symbolHeight = 11; + symbolOffsetX = 11; + symbolOffsetY = 11; + + break; + } + } + } + + //-------------------------------------------------------------------------- + // + // Overridden methods + // + //-------------------------------------------------------------------------- + + /** + * @private + * RadioButton <code>chromeColor</code> is drawn to match the FXG ellipse + * shape and position. + */ + override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void + { + // super draws a transparent hit zone + super.drawBackground(unscaledWidth, unscaledHeight); + + // get the size and position of iconDisplay + var currentIcon:DisplayObject = getIconDisplay(); + + graphics.beginFill(getStyle("chromeColor")); + graphics.drawEllipse(currentIcon.x + 1, currentIcon.y + 1, currentIcon.width - 2, currentIcon.height - 2); + graphics.endFill(); + } + + /** + * @private + */ + override protected function get focusSkinExclusions():Array + { + return exclusions; + } + + override protected function commitCurrentState():void + { + super.commitCurrentState(); + if(symbolIcon != null) + { + symbolIcon.width = symbolWidth; + symbolIcon.height = symbolHeight; + } + var iconDisplay:DisplayObject = getIconDisplay(); + if(iconDisplay != null) + { + iconDisplay.width = iconWidth; + iconDisplay.height = iconHeight; + } + } + + override protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void + { + super.layoutContents(unscaledWidth, unscaledHeight); + // position the symbols to align with the background "icon" + if (symbolIcon) + { + var currentIcon:DisplayObject = getIconDisplay(); + setElementPosition(symbolIcon, symbolOffsetX, symbolOffsetY); + } + } +} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/074a2f44/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_down.fxg ---------------------------------------------------------------------- diff --git a/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_down.fxg b/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_down.fxg new file mode 100644 index 0000000..dc74414 --- /dev/null +++ b/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_down.fxg @@ -0,0 +1,34 @@ +<?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. + +--> + +<Graphic version="2.0" xmlns="http://ns.adobe.com/fxg/2008"> + <Group scaleGridLeft="8" scaleGridRight="24" scaleGridTop="24" scaleGridBottom="8"> + <Path winding="nonZero" data="M32 16C32 24.8364 24.8369 32 16 32 7.16309 32 0 24.8364 0 16 0 7.16357 7.16309 0 16 0 24.8369 0 32 7.16357 32 16Z"> + <fill> + <SolidColor color="#DEDEDD"/> + </fill> + </Path> + <Path x="8" y="8" winding="nonZero" data="M16 8C16 12.4185 12.418 16 8 16 3.58203 16 0 12.4185 0 8 0 3.58154 3.58203 0 8 0 12.418 0 16 3.58154 16 8Z"> + <stroke> + <SolidColorStroke caps="none" joints="miter" miterLimit="10" color="#676767"/> + </stroke> + </Path> + </Group> +</Graphic> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/074a2f44/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_downSymbolSelected.fxg ---------------------------------------------------------------------- diff --git a/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_downSymbolSelected.fxg b/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_downSymbolSelected.fxg new file mode 100644 index 0000000..374c9fc --- /dev/null +++ b/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_downSymbolSelected.fxg @@ -0,0 +1,29 @@ +<?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. + +--> + +<Graphic version="2.0" xmlns="http://ns.adobe.com/fxg/2008"> + <Group x="-1" y="-1" scaleGridLeft="2.5" scaleGridRight="7.5" scaleGridTop="7.5" scaleGridBottom="2.5"> + <Path winding="nonZero" data="M10 5C10 7.76123 7.76172 10 5 10 2.23828 10 0 7.76123 0 5 0 2.23877 2.23828 0 5 0 7.76172 0 10 2.23877 10 5Z"> + <fill> + <SolidColor color="#676767"/> + </fill> + </Path> + </Group> +</Graphic> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/074a2f44/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_up.fxg ---------------------------------------------------------------------- diff --git a/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_up.fxg b/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_up.fxg new file mode 100644 index 0000000..4110262 --- /dev/null +++ b/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_up.fxg @@ -0,0 +1,29 @@ +<?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. + +--> + +<Graphic version="2.0" xmlns="http://ns.adobe.com/fxg/2008" viewHeight="32" viewWidth="32"> + <Group x="8" y="8" scaleGridLeft="4.25" scaleGridRight="12.75" scaleGridTop="12.75" scaleGridBottom="4.25"> + <Path x="0.5" y="0.5" winding="nonZero" data="M16 8C16 12.4185 12.418 16 8 16 3.58203 16 0 12.4185 0 8 0 3.58154 3.58203 0 8 0 12.418 0 16 3.58154 16 8Z"> + <stroke> + <SolidColorStroke caps="none" joints="miter" miterLimit="10" color="#676767"/> + </stroke> + </Path> + </Group> +</Graphic> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/074a2f44/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_upSymbolSelected.fxg ---------------------------------------------------------------------- diff --git a/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_upSymbolSelected.fxg b/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_upSymbolSelected.fxg new file mode 100644 index 0000000..5b844b6 --- /dev/null +++ b/frameworks/projects/mobiletheme/src/spark/skins/android4/assets/RadioButton_upSymbolSelected.fxg @@ -0,0 +1,36 @@ +<?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. + +--> + +<Graphic version="2.0" xmlns="http://ns.adobe.com/fxg/2008"> + <Group> + <Group x="0.5" y="0.5"> + <Path winding="nonZero" data="M10 5C10 7.76123 7.76172 10 5 10 2.23828 10 0 7.76123 0 5 0 2.23877 2.23828 0 5 0 7.76172 0 10 2.23877 10 5Z"> + <fill> + <SolidColor color="#33B5E5"/> + </fill> + </Path> + </Group> + <Path x="0.5" y="0.5" winding="nonZero" data="M10 5C10 7.76123 7.76172 10 5 10 2.23828 10 0 7.76123 0 5 0 2.23877 2.23828 0 5 0 7.76172 0 10 2.23877 10 5Z"> + <stroke> + <SolidColorStroke caps="none" joints="miter" miterLimit="10" color="#676767"/> + </stroke> + </Path> + </Group> +</Graphic> \ No newline at end of file
