You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2019/11/22 03:38:50 UTC

[royale-asjs] branch develop updated: improve Spark DropDownList appearance. Still needs more tweaking. Should fix #569

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

aharui 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 dab6627  improve Spark DropDownList appearance.  Still needs more tweaking.  Should fix #569
dab6627 is described below

commit dab6627bdb973aec257d81a9be424d526800f2bf
Author: Alex Harui <ah...@apache.org>
AuthorDate: Thu Nov 21 19:38:25 2019 -0800

    improve Spark DropDownList appearance.  Still needs more tweaking.  Should fix #569
---
 .../SparkRoyale/src/main/resources/defaults.css    |  1 +
 .../src/main/royale/spark/components/DataGroup.as  |  1 +
 .../spark/components/beads/DropDownListView.as     |  3 +-
 .../beads/controllers/DropDownListController.as    |  8 +--
 .../supportClasses/DropDownListButton.as           | 73 ++++++++++++++++++++++
 5 files changed, 81 insertions(+), 5 deletions(-)

diff --git a/frameworks/projects/SparkRoyale/src/main/resources/defaults.css b/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
index f7eeeda..ce22cca 100644
--- a/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
@@ -114,6 +114,7 @@ DropDownList
 .DropDownDataGroup
 {
 	background-color: #FFFFFF;
+	border: 1px solid #333333
 }
 
 List
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/DataGroup.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/DataGroup.as
index aa4604e..f0acac1 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/DataGroup.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/DataGroup.as
@@ -201,6 +201,7 @@ public class DataGroup extends GroupBase implements IItemRendererProvider, IStra
         var presModel:IListPresentationModel = getBeadByType(IListPresentationModel) as IListPresentationModel;
         if (presModel == null) {
             presModel = new ListPresentationModel();
+            presModel.rowHeight = 18;
             addBead(presModel);
         }
         return presModel;
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/DropDownListView.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/DropDownListView.as
index d35d878..15f4a45 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/DropDownListView.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/DropDownListView.as
@@ -25,6 +25,7 @@ package spark.components.beads
     import mx.managers.PopUpManager;
 
     import spark.components.Button;
+    import spark.components.supportClasses.DropDownListButton;
     import spark.components.DropDownList;
 
     import org.apache.royale.core.IBead;
@@ -89,7 +90,7 @@ package spark.components.beads
             var chost:IContainer = host as IContainer;
             chost.strandChildren.removeElement(viewport.contentView);
 
-            label = new Button();
+            label = new DropDownListButton();
             if (selectionModel.selectedIndex == -1)
                 label.label = (host as DropDownList).prompt;
             chost.strandChildren.addElement(label);
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/controllers/DropDownListController.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/controllers/DropDownListController.as
index 9f09ba0..0530a1c 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/controllers/DropDownListController.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/controllers/DropDownListController.as
@@ -21,6 +21,8 @@ package spark.components.beads.controllers
 {
 
 
+import mx.core.UIComponent;
+
 import org.apache.royale.core.IBead;
 import org.apache.royale.core.IBeadController;
 import org.apache.royale.core.ISelectionModel;
@@ -30,12 +32,9 @@ import org.apache.royale.core.UIBase;
 import org.apache.royale.events.Event;
 import org.apache.royale.events.IEventDispatcher;
 import org.apache.royale.events.MouseEvent;
-import org.apache.royale.html.beads.IDropDownListView;
 import org.apache.royale.geom.Point;
+import org.apache.royale.html.beads.IDropDownListView;
 import org.apache.royale.utils.PointUtils;
-import org.apache.royale.events.MouseEvent;
-
-import mx.core.UIComponent;
 
 /**
  *  @private
@@ -78,6 +77,7 @@ public class DropDownListController implements IBead, IBeadController
         {
             var pt:Point = new Point(0, IUIBase(_strand).height);
             pt = PointUtils.localToGlobal(pt, _strand);
+            pt = PointUtils.globalToLocal(pt, IUIBase(viewBead.popUp).parent);
             IUIBase(viewBead.popUp).x = pt.x;
             IUIBase(viewBead.popUp).y = pt.y;
             IEventDispatcher(viewBead.popUp).addEventListener("change", changeHandler);
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/DropDownListButton.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/DropDownListButton.as
new file mode 100644
index 0000000..546a570
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/DropDownListButton.as
@@ -0,0 +1,73 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.components.supportClasses
+{
+	import spark.components.Button;
+	
+    /**
+	 */ 
+	public class DropDownListButton extends Button
+	{
+		
+		/**
+		 *  Constructor.
+         * 
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10
+		 *  @playerversion AIR 1.5
+		 *  @productversion Flex 4
+		 */
+		public function DropDownListButton()
+		{
+			super();			
+		}
+		
+        override public function setActualSize(w:Number, h:Number):void
+        {
+            super.setActualSize(w, h);
+            COMPILE::JS
+            {
+                updateSkin(w, h);
+            }
+        }
+        
+        COMPILE::JS
+        override public function set label(value:String):void
+        {
+            super.label = value;
+            updateSkin(width, height);
+        }
+        
+        COMPILE::JS
+        private function updateSkin(w:Number, h:Number):void
+        {
+            element.innerHTML = '<svg width="' + w + 'px" height="' +
+                h + 'px" xmlns="http://www.w3.org/2000/svg"><text y="3px">' +
+                label + '</text><style><![CDATA[' +
+                'text{ dominant-baseline: hanging;' +
+                /*    font: 12px Verdana, Helvetica, Arial, sans-serif;*/
+                '}]]></style><rect x="' +
+                (w - 26) + 'px" width="1px" height="' + (h - 4) + 'px"/><path d="M' +
+                (w - 21) + ',5 L ' + (w - 13) + ',5 L ' +
+                (w - 17) + ',12 L ' + (w - 21) + ',5"</path></svg>';    
+            
+        }
+	}
+}
\ No newline at end of file