Repository: flex-asjs Updated Branches: refs/heads/develop 631277b09 -> fbfb631bb
Add MDL DropDownList component it uses MDL Menu as drop down popup Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/fbfb631b Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/fbfb631b Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/fbfb631b Branch: refs/heads/develop Commit: fbfb631bbf30ca5aa61b96cb131c24884d8bab87 Parents: 631277b Author: piotrz <[email protected]> Authored: Mon May 1 11:23:51 2017 +0200 Committer: piotrz <[email protected]> Committed: Mon May 1 11:23:51 2017 +0200 ---------------------------------------------------------------------- .../src/main/flex/MDLClasses.as | 7 +- .../flex/org/apache/flex/mdl/DropDownList.as | 148 +++++++++++++++++++ .../apache/flex/mdl/beads/SliderThumbView.as | 130 ---------------- .../apache/flex/mdl/beads/SliderTrackView.as | 129 ---------------- .../beads/controllers/DropDownListController.as | 98 ++++++++++++ .../beads/controllers/SliderMouseController.as | 3 +- .../flex/mdl/beads/views/DropDownListView.as | 119 +++++++++++++++ .../flex/mdl/beads/views/SliderThumbView.as | 130 ++++++++++++++++ .../flex/mdl/beads/views/SliderTrackView.as | 129 ++++++++++++++++ .../src/main/resources/defaults.css | 16 +- .../src/main/resources/mdl-manifest.xml | 2 + 11 files changed, 644 insertions(+), 267 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fbfb631b/frameworks/projects/MaterialDesignLite/src/main/flex/MDLClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/MDLClasses.as b/frameworks/projects/MaterialDesignLite/src/main/flex/MDLClasses.as index c571fa5..aa4c17b 100644 --- a/frameworks/projects/MaterialDesignLite/src/main/flex/MDLClasses.as +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/MDLClasses.as @@ -37,11 +37,12 @@ package import org.apache.flex.mdl.materialIcons.MaterialIconType; MaterialIconType; import org.apache.flex.mdl.beads.UpgradeElement; UpgradeElement; import org.apache.flex.mdl.beads.UpgradeChildren; UpgradeChildren; - + import org.apache.flex.mdl.beads.controllers.DropDownListController; DropDownListController; + COMPILE::SWF { - import org.apache.flex.mdl.beads.SliderThumbView; SliderThumbView; - import org.apache.flex.mdl.beads.SliderTrackView; SliderTrackView; + import org.apache.flex.mdl.beads.views.SliderThumbView; org.apache.flex.mdl.beads.views.SliderThumbView; + import org.apache.flex.mdl.beads.views.SliderTrackView; org.apache.flex.mdl.beads.views.SliderTrackView; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fbfb631b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/DropDownList.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/DropDownList.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/DropDownList.as new file mode 100644 index 0000000..1e28630 --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/DropDownList.as @@ -0,0 +1,148 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.mdl +{ + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.html.Group; + import org.apache.flex.mdl.materialIcons.IMaterialIcon; + + [Event(name="change", type="org.apache.flex.events.Event")] + + /** + * The DropDownList class is a component that displays label field and + * pop-up list (MDL Menu) with selections. Selecting an item from the pop-up list + * places that item into the label field of the DropDownList. The DropDownList + * uses the following bead types: + * + * org.apache.flex.core.IBeadModel: the data model, which includes the dataProvider, selectedItem, and + * so forth. + * org.apache.flex.core.IBeadView: the bead that constructs the visual parts of the component. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public class DropDownList extends Group + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DropDownList() + { + super(); + } + + private var _icon:IMaterialIcon; + + /** + * The data for display by the DropDownList. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function get dataProvider():Object + { + return ISelectionModel(model).dataProvider; + } + public function set dataProvider(value:Object):void + { + ISelectionModel(model).dataProvider = value; + } + + [Bindable("change")] + /** + * @copy org.apache.flex.core.ISelectionModel#selectedIndex + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function get selectedIndex():int + { + return ISelectionModel(model).selectedIndex; + } + public function set selectedIndex(value:int):void + { + ISelectionModel(model).selectedIndex = value; + } + + [Bindable("change")] + /** + * @copy org.apache.flex.core.ISelectionModel#selectedItem + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function get selectedItem():Object + { + return ISelectionModel(model).selectedItem; + } + public function set selectedItem(value:Object):void + { + ISelectionModel(model).selectedItem = value; + } + + /** + * @copy org.apache.flex.core.ISelectionModel#labelField + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function get labelField():String + { + return ISelectionModel(model).labelField; + } + + public function set labelField(value:String):void + { + ISelectionModel(model).labelField = value; + } + + /** + * DropDownList material icon - default: MaterialIconType.ARROW_DROP_DOWN + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function get icon():IMaterialIcon + { + return _icon; + } + + public function set icon(value:IMaterialIcon):void + { + _icon = value; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fbfb631b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/SliderThumbView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/SliderThumbView.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/SliderThumbView.as deleted file mode 100644 index 0192636..0000000 --- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/SliderThumbView.as +++ /dev/null @@ -1,130 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 org.apache.flex.mdl.beads -{ - import flash.display.Graphics; - import flash.display.Shape; - import flash.display.SimpleButton; - - import org.apache.flex.core.BeadViewBase; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.IStrand; - import org.apache.flex.html.Button; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.core.IChild; - - /** - * The SliderThumbView class creates the draggable input element for the - * org.apache.flex.mdl.Slider component (swf version). - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.8 - */ - public class SliderThumbView extends BeadViewBase implements IBeadView - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.8 - */ - public function SliderThumbView() - { - hitArea = new Shape(); - upView = new Shape(); - downView = new Shape(); - overView = new Shape(); - } - - /** - * @private - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.8 - */ - private function drawView(g:Graphics, bgColor:uint):void - { - var host:Button = Button(_strand); - var button:SimpleButton = IChild(_strand).$displayObject as SimpleButton; - g.clear(); - g.lineStyle(1,0x000000); - g.beginFill(bgColor,1.0); - g.drawCircle(host.width/2, host.height/2, 10); - g.endFill(); - } - - private var hitArea:Shape; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.8 - * @flexjsignoreimport org.apache.flex.core.WrappedHTMLElement - * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement - */ - override public function set strand(value:IStrand):void - { - super.strand = value; - - drawView(hitArea.graphics, 0xDD0000); - drawView(upView.graphics, 0xFFFFFF); - drawView(downView.graphics, 0x999999); - drawView(overView.graphics, 0xDDDDDD); - - var button:SimpleButton = IChild(value).$displayObject as SimpleButton; - button.upState = upView; - button.downState = downView; - button.overState = overView; - button.hitTestState = hitArea; - - IEventDispatcher(value).addEventListener("widthChanged",sizeChangeHandler); - IEventDispatcher(value).addEventListener("heightChanged",sizeChangeHandler); - } - - private var upView:Shape; - private var downView:Shape; - private var overView:Shape; - - /** - * @private - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.8 - */ - private function sizeChangeHandler( event:Event ) : void - { - drawView(hitArea.graphics, 0xDD0000); - drawView(upView.graphics, 0xFFFFFF); - drawView(downView.graphics, 0x999999); - drawView(overView.graphics, 0xDDDDDD); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fbfb631b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/SliderTrackView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/SliderTrackView.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/SliderTrackView.as deleted file mode 100644 index 550ef9f..0000000 --- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/SliderTrackView.as +++ /dev/null @@ -1,129 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 org.apache.flex.mdl.beads -{ - import flash.display.Graphics; - import flash.display.Shape; - import flash.display.SimpleButton; - - import org.apache.flex.core.BeadViewBase; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.IStrand; - import org.apache.flex.html.Button; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.core.IChild; - - /** - * The SliderTrackView class creates the track area for the org.apache.flex.mdl.Slider - * component (swf version). - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.8 - */ - public class SliderTrackView extends BeadViewBase implements IBeadView - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function SliderTrackView() - { - hitArea = new Shape(); - upView = new Shape(); - downView = new Shape(); - overView = new Shape(); - } - - /** - * @private - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.8 - */ - private function drawView(g:Graphics, bgColor:uint):void - { - var host:Button = Button(_strand); - var button:SimpleButton = IChild(_strand).$displayObject as SimpleButton; - g.clear(); - g.lineStyle(1,0x000000); - g.beginFill(bgColor); - g.drawRect(0, 0, host.width, host.height); - g.endFill(); - } - - private var hitArea:Shape; - - /** - * @copy org.apache.flex.core.IBead#strand - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.8 - * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement - */ - override public function set strand(value:IStrand):void - { - super.strand = value; - - drawView(hitArea.graphics, 0xDD0000); - drawView(upView.graphics, 0xCCCCCC); - drawView(downView.graphics, 0x808080); - drawView(overView.graphics, 0xEEEEEE); - - var button:SimpleButton = IChild(value).$displayObject as SimpleButton; - button.upState = upView; - button.downState = downView; - button.overState = overView; - button.hitTestState = hitArea; - - IEventDispatcher(value).addEventListener("widthChanged",sizeChangeHandler); - IEventDispatcher(value).addEventListener("heightChanged",sizeChangeHandler); - } - - private var upView:Shape; - private var downView:Shape; - private var overView:Shape; - - /** - * @private - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.8 - */ - private function sizeChangeHandler( event:Event ) : void - { - drawView(hitArea.graphics, 0xDD0000); - drawView(upView.graphics, 0xCCCCCC); - drawView(downView.graphics, 0x808080); - drawView(overView.graphics, 0xEEEEEE); - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fbfb631b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/DropDownListController.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/DropDownListController.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/DropDownListController.as new file mode 100644 index 0000000..ec79b6d --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/DropDownListController.as @@ -0,0 +1,98 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.mdl.beads.controllers +{ + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.mdl.beads.views.DropDownListView; + import org.apache.flex.events.Event; + import org.apache.flex.events.MouseEvent; + + /** + * The DropDownListController class bead handles mouse events on the + * drop down list (org.apache.flex.mdl.Menu) component parts and + * dispatches change event on behalf of the DropDownList + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public class DropDownListController implements IBeadController + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function DropDownListController() + { + } + + /** + * Model + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + private var _model:ISelectionModel; + private var _dropDownListView:DropDownListView; + + private var _strand:IStrand; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function set strand(value:IStrand):void + { + _strand = value; + + _model = _strand.getBeadByType(ISelectionModel) as ISelectionModel; + _dropDownListView = value.getBeadByType(DropDownListView) as DropDownListView; + + _dropDownListView.displayList.addEventListener(MouseEvent.CLICK, onDisplayItemClick); + } + + private function onDisplayItemClick(event:MouseEvent):void + { + var eventTarget:Object = event.target; + + _model.selectedIndex = eventTarget.index; + _model.selectedItem = eventTarget.data; + + _dropDownListView.displayLabel.text = !_model.labelField ? + eventTarget.data : + eventTarget.data[_model.labelField]; + + IEventDispatcher(_strand).dispatchEvent(new Event(Event.CHANGE)); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fbfb631b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/SliderMouseController.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/SliderMouseController.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/SliderMouseController.as index 4cd2c4b..85a41fa 100644 --- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/SliderMouseController.as +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/SliderMouseController.as @@ -18,7 +18,6 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.mdl.beads.controllers { - import org.apache.flex.core.IBead; import org.apache.flex.core.IBeadController; import org.apache.flex.core.IRangeModel; import org.apache.flex.core.IStrand; @@ -49,7 +48,7 @@ package org.apache.flex.mdl.beads.controllers * @playerversion AIR 2.6 * @productversion FlexJS 0.8 */ - public class SliderMouseController implements IBead, IBeadController + public class SliderMouseController implements IBeadController { /** * constructor. http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fbfb631b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/DropDownListView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/DropDownListView.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/DropDownListView.as new file mode 100644 index 0000000..8b766fc --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/DropDownListView.as @@ -0,0 +1,119 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.mdl.beads.views +{ + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.html.Div; + import org.apache.flex.html.beads.GroupView; + import org.apache.flex.mdl.DropDownList; + import org.apache.flex.mdl.Menu; + import org.apache.flex.mdl.materialIcons.MaterialIcon; + import org.apache.flex.mdl.materialIcons.MaterialIconType; + import org.apache.flex.events.Event; + + /** + * The DropDownListView class creates the visual elements of the org.apache.flex.mdl.DropDownList + * component. The job of the view bead is to put together the parts of the DropDownList such as the Label + * control and material icon ARROW_DROP_DOWN to trigger the pop-up. + * + * @viewbead + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public class DropDownListView extends GroupView + { + public function DropDownListView() + { + super(); + } + + protected var _displayList:Menu; + protected var _displayLabel:Div; + + public function get displayList():Menu + { + return _displayList; + } + + public function get displayLabel():Div + { + return _displayLabel; + } + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + + var dropDownList:DropDownList = (value as DropDownList); + + _displayList = new Menu(); + _displayList.bottom = true; + + _displayLabel = new Div(); + + if (!dropDownList.icon) + { + var dropDownIcon:MaterialIcon = new MaterialIcon(); + dropDownIcon.text = MaterialIconType.ARROW_DROP_DOWN; + dropDownList.icon = dropDownIcon; + } + + var model:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel; + _displayList.model = model; + + dropDownList.addElement(_displayLabel); + dropDownList.addElement(dropDownList.icon); + dropDownList.addElement(_displayList); + } + + override protected function handleInitComplete(event:org.apache.flex.events.Event):void + { + super.handleInitComplete(event); + + COMPILE::JS + { + host.element.classList.add("DropDownList"); + setIdForDisplayList(); + } + _displayList.width = isNaN(host.width) ? 100 : host.width; + _displayLabel.width = isNaN(host.width) ? 100 : host.width - 25; + } + + COMPILE::JS + private function setIdForDisplayList():void + { + if (!host.element.id) + { + host.element.id = "dropDownList" + Math.random(); + } + + _displayList.dataMdlFor = host.element.id; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fbfb631b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/SliderThumbView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/SliderThumbView.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/SliderThumbView.as new file mode 100644 index 0000000..3c1a1c7 --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/SliderThumbView.as @@ -0,0 +1,130 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.mdl.beads.views +{ + import flash.display.Graphics; + import flash.display.Shape; + import flash.display.SimpleButton; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.html.Button; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.core.IChild; + + /** + * The SliderThumbView class creates the draggable input element for the + * org.apache.flex.mdl.Slider component (swf version). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public class SliderThumbView extends BeadViewBase implements IBeadView + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public function SliderThumbView() + { + hitArea = new Shape(); + upView = new Shape(); + downView = new Shape(); + overView = new Shape(); + } + + /** + * @private + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + private function drawView(g:Graphics, bgColor:uint):void + { + var host:Button = Button(_strand); + var button:SimpleButton = IChild(_strand).$displayObject as SimpleButton; + g.clear(); + g.lineStyle(1,0x000000); + g.beginFill(bgColor,1.0); + g.drawCircle(host.width/2, host.height/2, 10); + g.endFill(); + } + + private var hitArea:Shape; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + * @flexjsignoreimport org.apache.flex.core.WrappedHTMLElement + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + + drawView(hitArea.graphics, 0xDD0000); + drawView(upView.graphics, 0xFFFFFF); + drawView(downView.graphics, 0x999999); + drawView(overView.graphics, 0xDDDDDD); + + var button:SimpleButton = IChild(value).$displayObject as SimpleButton; + button.upState = upView; + button.downState = downView; + button.overState = overView; + button.hitTestState = hitArea; + + IEventDispatcher(value).addEventListener("widthChanged",sizeChangeHandler); + IEventDispatcher(value).addEventListener("heightChanged",sizeChangeHandler); + } + + private var upView:Shape; + private var downView:Shape; + private var overView:Shape; + + /** + * @private + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + private function sizeChangeHandler( event:Event ) : void + { + drawView(hitArea.graphics, 0xDD0000); + drawView(upView.graphics, 0xFFFFFF); + drawView(downView.graphics, 0x999999); + drawView(overView.graphics, 0xDDDDDD); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fbfb631b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/SliderTrackView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/SliderTrackView.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/SliderTrackView.as new file mode 100644 index 0000000..2dbce66 --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/SliderTrackView.as @@ -0,0 +1,129 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.mdl.beads.views +{ + import flash.display.Graphics; + import flash.display.Shape; + import flash.display.SimpleButton; + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.html.Button; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.core.IChild; + + /** + * The SliderTrackView class creates the track area for the org.apache.flex.mdl.Slider + * component (swf version). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + public class SliderTrackView extends BeadViewBase implements IBeadView + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function SliderTrackView() + { + hitArea = new Shape(); + upView = new Shape(); + downView = new Shape(); + overView = new Shape(); + } + + /** + * @private + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + private function drawView(g:Graphics, bgColor:uint):void + { + var host:Button = Button(_strand); + var button:SimpleButton = IChild(_strand).$displayObject as SimpleButton; + g.clear(); + g.lineStyle(1,0x000000); + g.beginFill(bgColor); + g.drawRect(0, 0, host.width, host.height); + g.endFill(); + } + + private var hitArea:Shape; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + + drawView(hitArea.graphics, 0xDD0000); + drawView(upView.graphics, 0xCCCCCC); + drawView(downView.graphics, 0x808080); + drawView(overView.graphics, 0xEEEEEE); + + var button:SimpleButton = IChild(value).$displayObject as SimpleButton; + button.upState = upView; + button.downState = downView; + button.overState = overView; + button.hitTestState = hitArea; + + IEventDispatcher(value).addEventListener("widthChanged",sizeChangeHandler); + IEventDispatcher(value).addEventListener("heightChanged",sizeChangeHandler); + } + + private var upView:Shape; + private var downView:Shape; + private var overView:Shape; + + /** + * @private + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.8 + */ + private function sizeChangeHandler( event:Event ) : void + { + drawView(hitArea.graphics, 0xDD0000); + drawView(upView.graphics, 0xCCCCCC); + drawView(downView.graphics, 0x808080); + drawView(overView.graphics, 0xEEEEEE); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fbfb631b/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css b/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css index 2c3709e..4051c88 100644 --- a/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css +++ b/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css @@ -67,7 +67,7 @@ Slider { IBeadModel: ClassReference("org.apache.flex.mdl.beads.models.SliderRangeModel"); iBeadView: ClassReference("org.apache.flex.mdl.beads.views.SliderView"); - iBeadController: ClassReference("org.apache.flex.mdl.beads.controllers.SliderMouseController"); + IBeadController: ClassReference("org.apache.flex.mdl.beads.controllers.SliderMouseController"); } List @@ -145,12 +145,22 @@ FooterLinkList IItemRenderer: ClassReference("org.apache.flex.mdl.itemRenderers.FooterLinkItemRenderer"); } +DropDownList +{ + IBeadView: ClassReference("org.apache.flex.mdl.beads.views.DropDownListView"); + IBeadModel: ClassReference("org.apache.flex.html.beads.models.ArraySelectionModel"); + IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.HorizontalFlexLayout"); + IBeadController: ClassReference("org.apache.flex.mdl.beads.controllers.DropDownListController"); + border: none; + border-bottom: 1px solid #F8F8F8; +} + @media -flex-flash { Slider { - iThumbView: ClassReference("org.apache.flex.mdl.beads.SliderThumbView"); - iTrackView: ClassReference("org.apache.flex.mdl.beads.SliderTrackView"); + iThumbView: ClassReference("org.apache.flex.mdl.beads.views.SliderThumbView"); + iTrackView: ClassReference("org.apache.flex.mdl.beads.views.SliderTrackView"); } RadioButton http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fbfb631b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml index f15a0f6..ebd7b00 100644 --- a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml +++ b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml @@ -117,4 +117,6 @@ <component id="FooterHeading" class="org.apache.flex.mdl.FooterHeading"/> <component id="UpgradeElement" class="org.apache.flex.mdl.beads.UpgradeElement"/> <component id="UpgradeChildren" class="org.apache.flex.mdl.beads.UpgradeChildren"/> + <component id="DropDownList" class="org.apache.flex.mdl.DropDownList"/> + <component id="DropDownListView" class="org.apache.flex.mdl.beads.views.DropDownListView"/> </componentPackage>
