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/12/11 06:59:12 UTC

[royale-asjs] 01/03: implement modal for MXRoyale. Should fix #614

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

commit a4d4e810a6c8cf5f7f9635d24ae10f760e8bad08
Author: Alex Harui <ah...@apache.org>
AuthorDate: Tue Dec 10 21:58:52 2019 -0800

    implement modal for MXRoyale.  Should fix #614
---
 .../projects/Basic/src/main/royale/BasicClasses.as |  1 +
 .../html/beads/controllers/AlertController.as      |  2 +-
 .../MXRoyale/src/main/resources/defaults.css       | 14 +++-
 .../MXRoyale/src/main/royale/MXRoyaleClasses.as    |  1 +
 .../beads/controllers/AlertMouseController.as      | 53 ++++++++++++
 .../src/main/royale/mx/managers/PopUpManager.as    | 14 ++--
 .../main/royale/mx/managers/PopUpManagerModal.as   | 98 ++++++++++++++++++++++
 7 files changed, 175 insertions(+), 8 deletions(-)

diff --git a/frameworks/projects/Basic/src/main/royale/BasicClasses.as b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
index 1d2dc13..9fa88d2 100644
--- a/frameworks/projects/Basic/src/main/royale/BasicClasses.as
+++ b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
@@ -91,6 +91,7 @@ internal class BasicClasses
     import org.apache.royale.html.beads.GroupView; GroupView;
 	import org.apache.royale.html.beads.ContainerView; ContainerView;
 	import org.apache.royale.core.supportClasses.StyledImageBase; StyledImageBase;
+    import org.apache.royale.html.beads.plugin.ModalDisplay; ModalDisplay;
 
 
 	COMPILE::SWF
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/AlertController.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/AlertController.as
index 5a2b818..9be654c 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/AlertController.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/controllers/AlertController.as
@@ -85,7 +85,7 @@ package org.apache.royale.html.beads.controllers
 		/**
 		 * @private
 		 */
-        private function alertCloseHandler(event:CloseEvent):void
+        protected function alertCloseHandler(event:CloseEvent):void
         {
 			COMPILE::SWF
             {
diff --git a/frameworks/projects/MXRoyale/src/main/resources/defaults.css b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
index a1dea0c..ff1aefb 100644
--- a/frameworks/projects/MXRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
@@ -22,6 +22,7 @@
 @namespace core "mx.core.*";
 @namespace containerBeads "mx.containers.beads.*";
 @namespace adg "mx.controls.advancedDataGridClasses.*";
+@namespace pop "mx.managers.*";
 
 .royale *, . royale *:before, . royale *:after {
 	-moz-box-sizing: border-box;
@@ -112,7 +113,7 @@ Alert
 {
 	IBeadLayout: ClassReference("org.apache.royale.html.beads.layouts.VerticalFlexLayout");
 	IBeadView:  ClassReference("mx.controls.beads.AlertView");
-	IBeadController: ClassReference("org.apache.royale.html.beads.controllers.AlertController");
+	IBeadController: ClassReference("mx.controls.beads.controllers.AlertMouseController");
 	IBeadModel: ClassReference("org.apache.royale.html.beads.models.AlertModel");
 
 	background-color: #FFFFFF;
@@ -356,6 +357,17 @@ PanelTitleBar
 	border-bottom: 1px solid #333333;
 }
 
+pop|PopUpManagerModal
+{
+	background-color: #E2E2E2;
+	position: fixed;
+	opacity: 0.2;
+	top: 0px;
+	left: 0px;
+	width: 100%;
+	height: 100%;
+}
+
 TabNavigator
 {
 	IBeadModel: ClassReference("org.apache.royale.html.beads.models.ArraySelectionModel");
diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
index c001742..edd6821 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
@@ -57,6 +57,7 @@ internal class MXRoyaleClasses
 	import mx.containers.beads.CanvasLayout; CanvasLayout;
     import mx.containers.beads.layouts.BasicLayout; BasicLayout;
 	import mx.controls.beads.AlertView; AlertView;
+    import mx.controls.beads.controllers.AlertMouseController; AlertMouseController;
 	import mx.containers.gridClasses.GridColumnInfo; GridColumnInfo;
 	import mx.containers.gridClasses.GridRowInfo; GridRowInfo;
 	import mx.events.CloseEvent; CloseEvent;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/controllers/AlertMouseController.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/controllers/AlertMouseController.as
new file mode 100644
index 0000000..44909fe
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/controllers/AlertMouseController.as
@@ -0,0 +1,53 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.controls.beads.controllers
+{
+
+import mx.core.IFlexDisplayObject;
+import mx.managers.PopUpManager;
+
+import org.apache.royale.core.IBeadController;
+import org.apache.royale.core.IStrand;
+import org.apache.royale.events.CloseEvent;
+import org.apache.royale.events.IEventDispatcher;
+import org.apache.royale.events.MouseEvent;
+import org.apache.royale.html.beads.controllers.AlertController;
+
+/**
+ *  The RadioButtonMouseController is the default controller for the radio button emulation class.
+ *  It is responsible for creating the item click event
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+
+	public class AlertMouseController extends AlertController
+	{
+        override protected function alertCloseHandler(event:CloseEvent):void
+        {
+            PopUpManager.removePopUp(strand as IFlexDisplayObject);
+        }
+
+
+	}
+
+}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManager.as b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManager.as
index ca90827..84f2607 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManager.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManager.as
@@ -201,10 +201,8 @@ public class PopUpManager
         var popUpHost:IPopUpHost = UIUtils.findPopUpHost(parent as IUIBase);
         if (modal)
         {
-            var appStrand:IStrand = FlexGlobals.topLevelApplication as IStrand;
-            var modalBead:IModalDisplay = appStrand.getBeadByType(IModalDisplay) as IModalDisplay;
-            if (modalBead)
-                modalBead.show(popUpHost);
+            PopUpManagerModal.show(popUpHost as IUIBase);
+            modalWindows.push(window);
         }
         if (popUpHost is UIComponent)
             (window as UIComponent).systemManager = (popUpHost as UIComponent).systemManager;
@@ -232,6 +230,8 @@ public class PopUpManager
         UIUtils.center(popUp as IUIBase, (popUp.parent as IPopUpHostParent).popUpHost as IUIBase);
     }
 	
+    private static var modalWindows:Array = [];
+    
     /**
      *  Removes a popup window popped up by 
      *  the <code>createPopUp()</code> or <code>addPopUp()</code> method.
@@ -243,10 +243,12 @@ public class PopUpManager
      *  @playerversion AIR 1.1
      *  @productversion Flex 3
      */
-	
     public static function removePopUp(popUp:IFlexDisplayObject):void
     {
-		UIUtils.removePopUp(popUp as IChild)
+        var popUpHost:IUIBase = (popUp.parent as IPopUpHostParent).popUpHost as IUIBase;
+		UIUtils.removePopUp(popUp as IChild);
+        if (modalWindows.length > 0 && modalWindows[modalWindows.length - 1] == popUp)
+            PopUpManagerModal.remove(popUpHost);
     }
 } // class
 } // package
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManagerModal.as b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManagerModal.as
new file mode 100644
index 0000000..418dded
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManagerModal.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 mx.managers
+{
+  import org.apache.royale.events.EventDispatcher;
+  import org.apache.royale.core.IBead;
+  import org.apache.royale.core.IStrand;
+  import org.apache.royale.core.IUIBase;
+  import org.apache.royale.core.IPopUpHost;
+  import org.apache.royale.events.Event;
+  import org.apache.royale.utils.UIUtils;
+  import org.apache.royale.events.IEventDispatcher;
+  import org.apache.royale.core.IParent;
+  import org.apache.royale.core.IParentIUIBase;
+  import org.apache.royale.core.UIBase;
+  import org.apache.royale.utils.CSSUtils;
+  import org.apache.royale.events.MouseEvent;
+
+  import mx.core.UIComponent;
+
+  public class PopUpManagerModal extends UIComponent
+  {
+    public function PopUpManagerModal()
+    {
+      super();
+      typeNames = "PopUpManagerModal";
+    }
+    
+
+    // Application and View are both possible parents,
+    // but there's no single interface for both that will work.
+    private static var overlays:Array = [];
+    /**
+     *  @royaleignorecoercion Object
+     */
+    public static function show(host:IUIBase):void
+    {
+      var hostParent:IParent = host.parent;
+      var overlay:PopUpManagerModal = new PopUpManagerModal();
+      COMPILE::SWF
+      {
+        overlay.width = (hostParent as Object).width;
+        overlay.height = (hostParent as Object).height;
+	  	overlay.graphics.beginFill(overlay.getStyle("backgroundColor"),overlay.getStyle("backgroundAlpha"));
+		overlay.graphics.drawRect(0, 0, overlay.width, overlay.height);
+	    overlay.graphics.endFill();
+
+      }
+
+      /* in CSS
+      COMPILE::JS
+      {
+        var style:CSSStyleDeclaration = overlay.element.style;
+        style.position = "fixed";
+        style.top = "0px";
+        style.left = "0px";
+        style.width = "100%";
+        style.height = "100%";
+        style.opacity = alpha;
+        style.backgroundColor = CSSUtils.attributeFromColor(color);
+      }
+      */
+      hostParent.addElement(overlay);
+      overlay.addEventListener(MouseEvent.CLICK,handleClick);
+      overlays.push(overlay)
+    }
+
+    private static function handleClick(ev:MouseEvent):void
+    {
+      ev.preventDefault();
+      ev.stopImmediatePropagation();
+    }
+
+    public static function remove(host:IUIBase):void
+    {
+        var hostParent:IParent = host.parent;
+        hostParent.removeElement(overlays.pop());
+    }
+
+
+  }
+}
\ No newline at end of file