royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject [royale-asjs] branch develop updated: Updated DragAndDrop project to account for ICollectionView and changes to event bubbling.
Date Tue, 30 Jan 2018 19:53:52 GMT
This is an automated email from the ASF dual-hosted git repository.

pent 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 c417753  Updated DragAndDrop project to account for ICollectionView and changes to
event bubbling.
c417753 is described below

commit c417753d8c55145e617ae6ebef29975a914080d4
Author: Peter Ent <pent@apache.org>
AuthorDate: Tue Jan 30 14:56:25 2018 -0500

    Updated DragAndDrop project to account for ICollectionView and changes to event bubbling.
---
 .../royale/org/apache/royale/events/DragEvent.as   | 23 ++++++------------
 .../royale/html/beads/ButtonBarReorderBead.as      |  5 +---
 .../html/beads/DataGridWithDrawingLayerLayout.as   | 28 +++++++++++++---------
 .../html/beads/SingleSelectionDragImageBead.as     |  5 ++--
 .../html/beads/SingleSelectionDragSourceBead.as    | 21 ++++++++--------
 .../html/beads/SingleSelectionDropTargetBead.as    | 26 ++++++++++----------
 .../html/beads/controllers/DragMouseController.as  | 24 +++++++++++++++----
 .../html/beads/controllers/DropMouseController.as  |  6 +++--
 8 files changed, 77 insertions(+), 61 deletions(-)

diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/events/DragEvent.as
b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/events/DragEvent.as
index aeae6d4..5e3c93f 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/events/DragEvent.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/events/DragEvent.as
@@ -19,12 +19,15 @@
 package org.apache.royale.events
 {
     import org.apache.royale.core.IDragInitiator;
-	import org.apache.royale.utils.PointUtils;
-	import org.apache.royale.geom.Point;
+    import org.apache.royale.core.UIBase;
+    import org.apache.royale.geom.Point;
+    import org.apache.royale.utils.PointUtils;
+
     COMPILE::JS
     {
         import org.apache.royale.core.IUIBase;
 		import org.apache.royale.core.IStrand;
+		import org.apache.royale.core.UIBase;
         import window.Event;
         import window.MouseEvent;
         import org.apache.royale.events.utils.EventUtils;
@@ -334,6 +337,7 @@ package org.apache.royale.events
             COMPILE::JS
             {
                 this.type = type;
+				this.bubbles = bubbles;
             }
 		}
 
@@ -413,20 +417,7 @@ package org.apache.royale.events
                 target.dispatchEvent(event);                    
             }
             COMPILE::JS
-            {
-				// build an event target chain of ancestors so that bubbling
-				// will work for drag events on JS platform.
-				var pet:Object = target.getParentEventTarget();
-				if (!pet) {
-					var p:Object = target.parent;
-					var t:Object = target;
-					while (p != null && (p is IStrand)) {
-						t.setParentEventTarget(p);
-						t = p;
-						p = p.parent;
-					}
-				}
-				
+            {	
 				(target as IEventDispatcher).dispatchEvent(event);
             }
         }
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/ButtonBarReorderBead.as
b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/ButtonBarReorderBead.as
index 483d94c..1a18839 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/ButtonBarReorderBead.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/ButtonBarReorderBead.as
@@ -133,7 +133,7 @@ package org.apache.royale.html.beads
 			DragMouseController.dragImageOffsetX = 0;
 			DragMouseController.dragImageOffsetY = -30;
 
-			var startHere:Object = event.target;
+			var startHere:Object = event.relatedObject;
 			while (!(startHere is IItemRenderer) && startHere != null) {
 				startHere = startHere.itemRendererParent;
 			}
@@ -302,9 +302,6 @@ package org.apache.royale.html.beads
 					// insert before target index
 					dataList.addItemAt(dragSource, targetIndex);
 				}
-
-				var newList:ArrayList = new ArrayList(dataList.source);
-				dataProviderModel.dataProvider = newList;
 			}
 		}
 
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/DataGridWithDrawingLayerLayout.as
b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/DataGridWithDrawingLayerLayout.as
index bd1aad7..4f3232c 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/DataGridWithDrawingLayerLayout.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/DataGridWithDrawingLayerLayout.as
@@ -21,8 +21,9 @@ package org.apache.royale.html.beads
 	import org.apache.royale.core.IStrand;
 	import org.apache.royale.core.IUIBase;
 	import org.apache.royale.core.UIBase;
+	import org.apache.royale.events.Event;
 	import org.apache.royale.html.beads.IDataGridView;
-	import org.apache.royale.html.beads.layouts.VerticalFlexLayout;
+	import org.apache.royale.html.beads.layouts.DataGridLayout;
 
 	COMPILE::SWF {
 		import org.apache.royale.html.supportClasses.ScrollingViewport;
@@ -38,7 +39,7 @@ package org.apache.royale.html.beads
 	 *  @playerversion AIR 2.6
 	 *  @productversion Royale 0.0
 	 */
-	public class DataGridWithDrawingLayerLayout extends VerticalFlexLayout
+	public class DataGridWithDrawingLayerLayout extends DataGridLayout
 	{
 		/**
 		 *  constructor
@@ -67,6 +68,8 @@ package org.apache.royale.html.beads
 		{
 			super.strand = value;
 			_strand = value;
+			
+			_strand.addBead(new DataGridDrawingLayerBead());
 		}
 
 		/**
@@ -77,25 +80,28 @@ package org.apache.royale.html.beads
 			// If there is a drawing layer, remove it so the super.layout function
 			// will not include it.
 			var layerBead:IDrawingLayerBead = _strand.getBeadByType(IDrawingLayerBead) as IDrawingLayerBead;
-			if (layerBead != null && layerBead.layer != null) {
-				UIBase(_strand).removeElement(layerBead.layer);
+			if (layerBead != null && layerBead.layer == null) {
+				UIBase(_strand).dispatchEvent(new Event("beadsAdded"));
 			}
+//			if (layerBead != null && layerBead.layer != null) {
+//				UIBase(_strand).removeElement(layerBead.layer);
+//			}
 
 			// Run the actual layout
 			var result:Boolean = super.layout();
 
 			// Put the drawing layer back, sizing it to fit over the listArea.
 			if (layerBead != null && layerBead.layer != null) {
-				UIBase(_strand).addElement(layerBead.layer);
-
-				var layerX:Number = 0;
-				var layerY:Number = 0;
-				var useWidth:Number = UIBase(_strand).width;
-				var useHeight:Number = UIBase(_strand).height;
-
+//				UIBase(_strand).addElement(layerBead.layer);
+				
 				var view:IDataGridView = UIBase(_strand).view as IDataGridView;
 				var listArea:UIBase = view.listArea;
 
+				var layerX:Number = listArea.x;
+				var layerY:Number = listArea.y;
+				var useWidth:Number = listArea.width;
+				var useHeight:Number = listArea.height;
+
 				COMPILE::SWF {
 					var scrollViewport:ScrollingViewport = listArea.getBeadByType(ScrollingViewport) as
ScrollingViewport;
 					if (scrollViewport) {
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragImageBead.as
b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragImageBead.as
index ec185e7..446403c 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragImageBead.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragImageBead.as
@@ -127,9 +127,10 @@ package org.apache.royale.html.beads
 		 */
 		private function handleDragStart(event:DragEvent):void
 		{
-			trace("SingleSelectionDragImageBead received the DragStart via: "+event.target.toString());
+			//trace("SingleSelectionDragImageBead received the DragStart via: "+event.target.toString());
 
-			var renderer:IItemRenderer = getParentOrSelfByType(event.target as IChild, IItemRenderer)
as IItemRenderer;
+			var relatedObject:Object = event.relatedObject;
+			var renderer:IItemRenderer = getParentOrSelfByType(relatedObject as IChild, IItemRenderer)
as IItemRenderer;
 			if (renderer) {
 				DragMouseController.dragImage = createDragImage(renderer);
 			}
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragSourceBead.as
b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragSourceBead.as
index ad0af34..7397659 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragSourceBead.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDragSourceBead.as
@@ -27,6 +27,7 @@ package org.apache.royale.html.beads
 	import org.apache.royale.core.IItemRenderer;
 	import org.apache.royale.core.IItemRendererParent;
 	import org.apache.royale.core.IParent;
+	import org.apache.royale.core.ISelectionModel;
 	import org.apache.royale.core.IStrand;
 	import org.apache.royale.core.IUIBase;
 	import org.apache.royale.core.UIBase;
@@ -170,13 +171,14 @@ package org.apache.royale.html.beads
 		 */
 		private function handleDragStart(event:DragEvent):void
 		{
-			trace("SingleSelectionDragSourceBead received the DragStart");
+			//trace("SingleSelectionDragSourceBead received the DragStart");
 
 			DragEvent.dragInitiator = this;
 			DragMouseController.dragImageOffsetX = 0;
 			DragMouseController.dragImageOffsetY = -30;
 
-			var itemRenderer:IItemRenderer = getParentOrSelfByType(event.target as IChild, IItemRenderer)
as IItemRenderer;
+			var relatedObject:Object = event.relatedObject;
+			var itemRenderer:IItemRenderer = getParentOrSelfByType(relatedObject as IChild, IItemRenderer)
as IItemRenderer;
 
 			if (itemRenderer) {
 				var p:UIBase = itemRenderer.itemRendererParent as UIBase;
@@ -221,14 +223,17 @@ package org.apache.royale.html.beads
 		{
 			if (!continueDragOperation) return;
 
-			trace("SingleSelectionDragSourceBead accepting drop of type "+type);
+			//trace("SingleSelectionDragSourceBead accepting drop of type "+type);
 			var newEvent:Event = new Event("accept", false, true);
 			dispatchEvent(newEvent);
 			if (newEvent.defaultPrevented) return;
+			
+			var dataProviderModel:IDataProviderModel = _strand.getBeadByType(IDataProviderModel) as
IDataProviderModel;
+			if (dataProviderModel is ISelectionModel) {
+				(dataProviderModel as ISelectionModel).selectedIndex = -1;
+			}
 
 			if (dragType == "copy") return;
-
-			var dataProviderModel:IDataProviderModel = _strand.getBeadByType(IDataProviderModel) as
IDataProviderModel;
 			if (dataProviderModel.dataProvider is Array) {
 				var dataArray:Array = dataProviderModel.dataProvider as Array;
 
@@ -244,10 +249,6 @@ package org.apache.royale.html.beads
 
 				// remove the item being selected
 				DragEvent.dragSource = dataList.removeItemAt(_dragSourceIndex);
-
-				// refresh the dataProvider model
-				var newList:ArrayList = new ArrayList(dataList.source);
-				dataProviderModel.dataProvider = newList;
 			}
 		}
 
@@ -261,7 +262,7 @@ package org.apache.royale.html.beads
 		 */
 		public function acceptedDrop(dropTarget:Object, type:String):void
 		{
-			trace("SingleSelectionDragSourceBead accepted drop of type "+type);
+			//trace("SingleSelectionDragSourceBead accepted drop of type "+type);
 			var value:Object = DragEvent.dragSource;
 
 			_dragSourceIndex = -1;
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDropTargetBead.as
b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDropTargetBead.as
index 9fc81f7..2f159e2 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDropTargetBead.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/SingleSelectionDropTargetBead.as
@@ -25,11 +25,12 @@ package org.apache.royale.html.beads
 	import org.apache.royale.core.IDataProviderModel;
 	import org.apache.royale.core.IItemRenderer;
 	import org.apache.royale.core.IParent;
+	import org.apache.royale.core.ISelectionModel;
 	import org.apache.royale.core.IStrand;
 	import org.apache.royale.core.IUIBase;
 	import org.apache.royale.core.UIBase;
-	import org.apache.royale.events.Event;
 	import org.apache.royale.events.DragEvent;
+	import org.apache.royale.events.Event;
 	import org.apache.royale.events.EventDispatcher;
 	import org.apache.royale.events.IEventDispatcher;
 	import org.apache.royale.geom.Point;
@@ -203,7 +204,7 @@ package org.apache.royale.html.beads
 		 */
 		private function handleDragEnter(event:DragEvent):void
 		{
-			trace("SingleSelectionDropTargetBead received DragEnter via: "+event.relatedObject.toString());
+			//trace("SingleSelectionDropTargetBead received DragEnter via: "+event.relatedObject.toString());
 			var newEvent:Event = new Event("enter", false, true);
 			dispatchEvent(newEvent);
 			if (newEvent.defaultPrevented) return;
@@ -212,7 +213,7 @@ package org.apache.royale.html.beads
 			var pt1:Point;
 			var pt2:Point;
 
-			_dropController.acceptDragDrop(event.target as IUIBase, DropType.COPY);
+			_dropController.acceptDragDrop(event.relatedObject as IUIBase, DropType.COPY);
 
 			var startHere:Object = event.relatedObject;
 			while( !(startHere is IItemRenderer) && startHere != null) {
@@ -242,7 +243,7 @@ package org.apache.royale.html.beads
 		 */
 		private function handleDragExit(event:DragEvent):void
 		{
-			trace("SingleSelectionDropTargetBead received DragExit via: "+event.relatedObject.toString());
+			//trace("SingleSelectionDropTargetBead received DragExit via: "+event.relatedObject.toString());
 			dispatchEvent(new Event("exit", false, true));
 
 			if (indicatorVisible) {
@@ -258,7 +259,7 @@ package org.apache.royale.html.beads
 		 */
 		private function handleDragOver(event:DragEvent):void
 		{
-			trace("SingleSelectionDropTargetBead received DragOver via: "+event.relatedObject.toString());
+			//trace("SingleSelectionDropTargetBead received DragOver via: "+event.relatedObject.toString());
 			var newEvent:Event = new Event("over", false, true);
 			dispatchEvent(newEvent);
 			if (event.defaultPrevented) {
@@ -290,7 +291,7 @@ package org.apache.royale.html.beads
 		 */
 		private function handleDragDrop(event:DragEvent):void
 		{
-			trace("SingleSelectionDropTargetBead received DragDrop via: "+event.relatedObject.toString());
+			//trace("SingleSelectionDropTargetBead received DragDrop via: "+event.relatedObject.toString());
 
 			handleDragExit(event);
 
@@ -310,14 +311,14 @@ package org.apache.royale.html.beads
 
 			if (startHere is IItemRenderer) {
 				var ir:IItemRenderer = startHere as IItemRenderer;
-				trace("-- dropping onto an existing object: "+ir.data.toString());
+				//trace("-- dropping onto an existing object: "+ir.data.toString());
 
 				itemRendererParent = ir.itemRendererParent as UIBase;
 				targetIndex = itemRendererParent.getElementIndex(ir);
 			}
-			else  {
+			else if (startHere != null)  {
 				itemRendererParent = startHere.itemRendererParent as UIBase;
-				trace("-- dropping after the last item");
+				//trace("-- dropping after the last item");
 			}
 
 			var downPoint:Point = new Point(event.clientX, event.clientY);
@@ -360,15 +361,16 @@ package org.apache.royale.html.beads
 					// insert before target index
 					dataList.addItemAt(dragSource, targetIndex);
 				}
-
-				var newList:ArrayList = new ArrayList(dataList.source);
-				dataProviderModel.dataProvider = newList;
 			}
 
 			// Let the dragInitiator know the drop has been completed.
 			if (DragEvent.dragInitiator) {
 				DragEvent.dragInitiator.acceptedDrop(_strand, "object");
 			}
+			
+			if (dataProviderModel is ISelectionModel) {
+				(dataProviderModel as ISelectionModel).selectedIndex = targetIndex;
+			}
 
 			// is this event necessary? isn't "complete" enough?
 			IEventDispatcher(_strand).dispatchEvent(new Event("dragDropAccepted"));
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DragMouseController.as
b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DragMouseController.as
index c089a4f..4729119 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DragMouseController.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DragMouseController.as
@@ -176,8 +176,6 @@ package org.apache.royale.html.beads.controllers
 		{
 			_strand = value;
 
-			trace("DragMouseController instance "+DragMouseController.instanceNumber+"; isDragging
"+DragMouseController.dragging);
-
             IEventDispatcher(_strand).addEventListener(MouseEvent.MOUSE_DOWN, dragMouseDownHandler);
 
             DragMouseController.instanceNumber += 100;
@@ -224,6 +222,12 @@ package org.apache.royale.html.beads.controllers
 					dragEvent.clientX = mouseDownX;
 					dragEvent.clientY = mouseDownY;
 //					trace("DRAG-MOUSE: sending dragStart via "+event.target.toString()+" == "+dragImageOffsetX);
+					COMPILE::SWF {
+						dragEvent.relatedObject = event.target as InteractiveObject;
+					}
+					COMPILE::JS {
+						dragEvent.relatedObject = event.target;
+					}
 					DragEvent.dispatchDragEvent(dragEvent, event.target);
 					dispatchEvent(dragEvent);
 
@@ -257,6 +261,12 @@ package org.apache.royale.html.beads.controllers
                 pt = PointUtils.globalToLocal(new Point(event.clientX, event.clientY), host);
                 dragImage.x = pt.x + dragImageOffsetX;
                 dragImage.y = pt.y + dragImageOffsetY;
+				COMPILE::SWF {
+					dragEvent.relatedObject = event.target as InteractiveObject;
+				}
+				COMPILE::JS {
+					dragEvent.relatedObject = event.target;
+				}
                 DragEvent.dispatchDragEvent(dragEvent, event.target);
 				dispatchEvent(dragEvent);
             }
@@ -264,7 +274,7 @@ package org.apache.royale.html.beads.controllers
 
         private function dragMouseUpHandler(event:MouseEvent):void
         {
-            trace("DRAG-MOUSE: dragMouseUp");
+            //trace("DRAG-MOUSE: dragMouseUp");
             var dragEvent:DragEvent;
 
             host = UIUtils.findPopUpHost(_strand as IUIBase);
@@ -274,13 +284,19 @@ package org.apache.royale.html.beads.controllers
 
             if (dragging && event.target)
             {
-                trace("DRAG-MOUSE: sending dragEnd via: "+event.target.toString());
+                //trace("DRAG-MOUSE: sending dragEnd via: "+event.target.toString());
 
 				var screenPoint:Point = new Point(event.screenX, event.screenY);
 				var newPoint:Point = PointUtils.globalToLocal(screenPoint, event.target);
 				dragEvent = DragEvent.createDragEvent("dragEnd", event);
 				dragEvent.clientX = newPoint.x;
 				dragEvent.clientY = newPoint.y;
+				COMPILE::SWF {
+					dragEvent.relatedObject = event.target as InteractiveObject;
+				}
+				COMPILE::JS {
+					dragEvent.relatedObject = event.target;
+				}
 
                 DragEvent.dispatchDragEvent(dragEvent, event.target);
 				dispatchEvent(dragEvent);
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DropMouseController.as
b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DropMouseController.as
index 870692b..253ed5d 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DropMouseController.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/controllers/DropMouseController.as
@@ -150,6 +150,7 @@ package org.apache.royale.html.beads.controllers
             if (!inside)
             {
                 dragEvent = DragEvent.createDragEvent("dragEnter", event as MouseEvent);
+				dragEvent.relatedObject = event.relatedObject;
 				dispatchEvent(dragEvent);
                 inside = true;
                 IUIBase(_strand).addEventListener(DragEvent.DRAG_END, dragEndHandler);
@@ -160,6 +161,7 @@ package org.apache.royale.html.beads.controllers
             else
             {
                 dragEvent = DragEvent.createDragEvent("dragOver", event as MouseEvent);
+				dragEvent.relatedObject = event.relatedObject;
 				dispatchEvent(dragEvent);
             }
         }
@@ -197,10 +199,10 @@ package org.apache.royale.html.beads.controllers
 				dragEvent.relatedObject = event.target as InteractiveObject;
 			}
 			COMPILE::JS {
-				dragEvent.relatedObject = event.target;
+				dragEvent.relatedObject = event.relatedObject;
 			}
 
-			DragEvent.dispatchDragEvent(dragEvent, this);
+			dispatchEvent(dragEvent);
 
             inside = false;
             IUIBase(_strand).removeEventListener(DragEvent.DRAG_END, dragEndHandler);

-- 
To stop receiving notification emails like this one, please contact
pent@apache.org.

Mime
View raw message