This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 82c143b  jewel-combobox: use rowCount and rowHeight in popup list
82c143b is described below

commit 82c143bb4bc24f3a745e2d471524bc4ebf270ae9
Author: Carlos Rovira <[email protected]>
AuthorDate: Sat Feb 8 10:30:35 2020 +0100

    jewel-combobox: use rowCount and rowHeight in popup list
---
 .../projects/Jewel/src/main/resources/defaults.css |  1 -
 .../royale/org/apache/royale/jewel/ComboBox.as     | 49 ++++++++++++++++---
 .../royale/jewel/beads/views/ComboBoxPopUpView.as  | 29 ++++++++++--
 .../royale/jewel/beads/views/ComboBoxView.as       |  6 +++
 .../jewel/beads/views/VirtualComboBoxPopUpView.as  | 31 +++---------
 .../jewel/supportClasses/combobox/ComboBoxPopUp.as | 55 ++++++++++++++++++++++
 .../Jewel/src/main/sass/components/_combobox.sass  |  2 +-
 7 files changed, 136 insertions(+), 37 deletions(-)

diff --git a/frameworks/projects/Jewel/src/main/resources/defaults.css 
b/frameworks/projects/Jewel/src/main/resources/defaults.css
index cf74fa8..62c7628 100644
--- a/frameworks/projects/Jewel/src/main/resources/defaults.css
+++ b/frameworks/projects/Jewel/src/main/resources/defaults.css
@@ -434,7 +434,6 @@ j|ComboBox {
   top: calc(100% - 10px);
   left: 50%;
   box-shadow: 0px 0px 6px 1px rgba(1, 1, 1, 0.7) !important;
-  max-height: 170px;
   opacity: 0;
 }
 .combobox-popup.open {
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as
index 9a82a61..2c7fcff 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as
@@ -21,8 +21,8 @@ package org.apache.royale.jewel
        import org.apache.royale.core.IDataProviderModel;
        import org.apache.royale.core.ISelectionModel;
        import org.apache.royale.core.StyledUIBase;
-       import org.apache.royale.jewel.beads.models.ListPresentationModel;
-       import 
org.apache.royale.jewel.supportClasses.list.IListPresentationModel;
+       import org.apache.royale.jewel.beads.models.ComboBoxPresentationModel;
+       import 
org.apache.royale.jewel.supportClasses.combobox.IComboBoxPresentationModel;
 
        //--------------------------------------
     //  Events
@@ -161,19 +161,54 @@ package org.apache.royale.jewel
                }
 
                /**
-                *  The presentation model for the list.
+                *  The default height of each cell in every column
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.7
+                */
+        public function get rowHeight():Number
+        {
+            return (presentationModel as IComboBoxPresentationModel).rowHeight;
+        }
+        public function set rowHeight(value:Number):void
+        {
+            (presentationModel as IComboBoxPresentationModel).rowHeight = 
value;
+        }
+
+               /**
+                *  Maximum number of rows visible in the ComboBox popup list.
+                *  If there are fewer items in the dataProvider, the ComboBox 
shows only as many items as there are in the dataProvider.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.7
+                */
+        public function get rowCount():int
+        {
+            return (presentationModel as IComboBoxPresentationModel).rowCount;
+        }
+        public function set rowCount(value:int):void
+        {
+            (presentationModel as IComboBoxPresentationModel).rowCount = value;
+        }
+
+               /**
+                *  The presentation model for the combobox.
                 *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
                 *  @productversion Royale 0.9.4
-                *  @royaleignorecoercion 
org.apache.royale.jewel.supportClasses.list.IListPresentationModel
+                *  @royaleignorecoercion 
org.apache.royale.jewel.supportClasses.combobox.IComboBoxPresentationModel
                 */
-               public function get presentationModel():IListPresentationModel
+               public function get 
presentationModel():IComboBoxPresentationModel
                {
-                       var presModel:IListPresentationModel = 
getBeadByType(IListPresentationModel) as IListPresentationModel;
+                       var presModel:IComboBoxPresentationModel = 
getBeadByType(IComboBoxPresentationModel) as IComboBoxPresentationModel;
                        if (presModel == null) {
-                               presModel = new ListPresentationModel();
+                               presModel = new ComboBoxPresentationModel();
                                addBead(presModel);
                        }
                        return presModel;
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxPopUpView.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxPopUpView.as
index d19a473..d5c443b 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxPopUpView.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxPopUpView.as
@@ -23,6 +23,8 @@ package org.apache.royale.jewel.beads.views
     import org.apache.royale.core.IParent;
     import org.apache.royale.core.IStrand;
     import org.apache.royale.jewel.List;
+    import org.apache.royale.jewel.supportClasses.combobox.ComboBoxPopUp;
+    import 
org.apache.royale.jewel.supportClasses.combobox.IComboBoxPresentationModel;
 
     /**
         * The ComboBoxPopUpView class is a view bead for the ComboBoxPopUp.
@@ -64,13 +66,32 @@ package org.apache.royale.jewel.beads.views
             _strand = value;
             
             var model:IBeadModel = _strand.getBeadByType(IBeadModel) as 
IBeadModel;
-
-            list = new List();
             list.model = model;
-            
+
+            var _presentationModel:IComboBoxPresentationModel = (_strand as 
ComboBoxPopUp).presentationModel as IComboBoxPresentationModel;
+            list.rowHeight = _presentationModel.rowHeight;
+
+            // use rowCount to configure height
+            var rowCount:int = _presentationModel.rowCount;
+
+            // var view:IListView = list.view as IListView;
+            // var dataGroup:IItemRendererParent = view.dataGroup;
+
+            // var factory:IItemRendererClassFactory = 
loadBeadFromValuesManager(IItemRendererClassFactory, 
"iItemRendererClassFactory", list) as IItemRendererClassFactory;
+            // var ir:ISelectableItemRenderer = 
factory.createItemRenderer(dataGroup) as ISelectableItemRenderer;
+            list.height = rowCount * list.rowHeight; //(ir as IUIBase).height;
+
             IParent(_strand).addElement(list);
                }
 
-        public var list:List;
+        protected var _list:List;
+        public function get list():List
+        {
+            if(!_list) {
+                _list = new List();
+            }
+            return _list;
+        }
+
     }
 }
\ No newline at end of file
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
index a8968cc..692e130 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
@@ -39,11 +39,13 @@ package org.apache.royale.jewel.beads.views
        import org.apache.royale.events.IEventDispatcher;
        import org.apache.royale.html.util.getLabelFromData;
        import org.apache.royale.jewel.Button;
+       import org.apache.royale.jewel.ComboBox;
        import org.apache.royale.jewel.List;
        import org.apache.royale.jewel.TextInput;
        import org.apache.royale.jewel.beads.controls.combobox.IComboBoxView;
        import org.apache.royale.jewel.beads.models.IJewelSelectionModel;
        import org.apache.royale.jewel.supportClasses.combobox.ComboBoxPopUp;
+       import 
org.apache.royale.jewel.supportClasses.combobox.IComboBoxPresentationModel;
        import org.apache.royale.utils.UIUtils;
 
        /**
@@ -142,6 +144,7 @@ package org.apache.royale.jewel.beads.views
                        parent.addElement(_button);
 
                        model = _strand.getBeadByType(IComboBoxModel) as 
IComboBoxModel;
+                       _presentationModel = (_strand as 
ComboBox).presentationModel;
 
                        if (model is IJewelSelectionModel) {
                                //do this here as well as in the controller,
@@ -156,6 +159,7 @@ package org.apache.royale.jewel.beads.views
                }
 
                private var model:IComboBoxModel;
+               private var _presentationModel:IComboBoxPresentationModel;
 
                private var _popUpClass:Class;
                /**
@@ -184,7 +188,9 @@ package org.apache.royale.jewel.beads.views
                     {
                         _popUpClass = 
ValuesManager.valuesImpl.getValue(_strand, "iPopUp") as Class;
                     }
+
                     _comboPopUp = new _popUpClass() as ComboBoxPopUp;
+                                       _comboPopUp.addBead(_presentationModel);
                     _comboPopUp.model = model;
 
                                        UIUtils.addPopUp(_comboPopUp, host);
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualComboBoxPopUpView.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualComboBoxPopUpView.as
index b4d0449..cf11311 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualComboBoxPopUpView.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualComboBoxPopUpView.as
@@ -18,9 +18,6 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.jewel.beads.views
 {
-    import org.apache.royale.core.IBeadModel;
-    import org.apache.royale.core.IParent;
-    import org.apache.royale.core.IStrand;
     import org.apache.royale.jewel.List;
     import org.apache.royale.jewel.VirtualList;
 
@@ -47,26 +44,12 @@ package org.apache.royale.jewel.beads.views
                        super();
                }
         
-        /**
-         *  Get the strand for this bead
-         * 
-         *  @copy org.apache.royale.core.IBead#strand
-         *  
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion Royale 0.9.7
-         */
-        override public function set strand(value:IStrand):void
-               {
-            _strand = value;
-            
-            var model:IBeadModel = _strand.getBeadByType(IBeadModel) as 
IBeadModel;
-
-            list = new VirtualList();
-            list.model = model;
-            
-            IParent(_strand).addElement(list);
-               }
+        override public function get list():List
+        {
+            if(!_list) {
+                _list = new VirtualList();
+            }
+            return _list;
+        }
     }
 }
\ No newline at end of file
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/combobox/ComboBoxPopUp.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/combobox/ComboBoxPopUp.as
index 518b04f..e542f22 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/combobox/ComboBoxPopUp.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/combobox/ComboBoxPopUp.as
@@ -22,6 +22,7 @@ package org.apache.royale.jewel.supportClasses.combobox
     import org.apache.royale.core.IPopUp;
     import org.apache.royale.core.ISelectionModel;
     import org.apache.royale.core.StyledUIBase;
+    import org.apache.royale.jewel.beads.models.ComboBoxPresentationModel;
     
     //--------------------------------------
     //  Events
@@ -125,5 +126,59 @@ package org.apache.royale.jewel.supportClasses.combobox
                {
                        ISelectionModel(model).selectedItem = value;
                }
+
+               /**
+                *  The default height of each cell in every column
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.7
+                */
+        public function get rowHeight():Number
+        {
+            return (presentationModel as IComboBoxPresentationModel).rowHeight;
+        }
+        public function set rowHeight(value:Number):void
+        {
+            (presentationModel as IComboBoxPresentationModel).rowHeight = 
value;
+        }
+
+               /**
+                *  Maximum number of rows visible in the ComboBox popup list.
+                *  If there are fewer items in the dataProvider, the ComboBox 
shows only as many items as there are in the dataProvider.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.7
+                */
+        public function get rowCount():int
+        {
+            return (presentationModel as IComboBoxPresentationModel).rowCount;
+        }
+        public function set rowCount(value:int):void
+        {
+            (presentationModel as IComboBoxPresentationModel).rowCount = value;
+        }
+
+               /**
+                *  The presentation model for the list.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.7
+                *  @royaleignorecoercion 
org.apache.royale.jewel.supportClasses.list.IListPresentationModel
+                */
+               public function get 
presentationModel():IComboBoxPresentationModel
+               {
+                       var presModel:IComboBoxPresentationModel = 
getBeadByType(IComboBoxPresentationModel) as IComboBoxPresentationModel;
+                       if (presModel == null) {
+                               presModel = new ComboBoxPresentationModel();
+                               addBead(presModel);
+                       }
+                       return presModel;
+               }
        }
 }
diff --git a/frameworks/projects/Jewel/src/main/sass/components/_combobox.sass 
b/frameworks/projects/Jewel/src/main/sass/components/_combobox.sass
index c70b31b..5f9fa51 100644
--- a/frameworks/projects/Jewel/src/main/sass/components/_combobox.sass
+++ b/frameworks/projects/Jewel/src/main/sass/components/_combobox.sass
@@ -113,7 +113,7 @@ $combobox-item-min-heigh: 34px
         box-shadow: 0px 0px 6px 1px rgba(.7, .7, .7, .7) !important
 
         // width: $combobox-input-width + $combobox-button-width
-        max-height: $combobox-item-min-heigh * 5
+        // max-height: $combobox-item-min-heigh * 5
         opacity: 0
 
     &.open

Reply via email to