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/17 04:26:24 UTC

[royale-asjs] branch develop updated (856a1a0 -> dc10b0b)

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

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


    from 856a1a0  Merge pull request #561 from chrisdutz/develop
     new cb97d26  I think this has always been off by a little?
     new 0cec25f  fix a crash
     new dc10b0b  ADG Column Resizing.  Graphic is bright red for now.  Need new graphic

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/royale/html/beads/DataGridLinesBead.as  |   2 +-
 .../royale/org/apache/royale/events/MouseEvent.as  |   4 +-
 .../main/royale/mx/controls/AdvancedDataGrid.as    |   2 +
 .../mx/controls/beads/AdvancedDataGridSortBead.as  |   6 +-
 .../mx/controls/beads/DataGridColumnResizeBead.as  | 342 +++++++++++++++++++++
 .../beads/DataGridLinesBeadForICollectionView.as   |   9 +
 6 files changed, 361 insertions(+), 4 deletions(-)
 create mode 100644 frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/DataGridColumnResizeBead.as


[royale-asjs] 01/03: I think this has always been off by a little?

Posted by ah...@apache.org.
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 cb97d2655d1617e8270f14aa08318e74776b20c5
Author: Alex Harui <ah...@apache.org>
AuthorDate: Sat Nov 16 19:17:30 2019 -0800

    I think this has always been off by a little?
---
 .../Core/src/main/royale/org/apache/royale/events/MouseEvent.as       | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/events/MouseEvent.as b/frameworks/projects/Core/src/main/royale/org/apache/royale/events/MouseEvent.as
index 9674055..5d93700 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/events/MouseEvent.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/events/MouseEvent.as
@@ -507,7 +507,7 @@ package org.apache.royale.events
         
         public function get localX():Number
         {
-            return clientX;
+            return wrappedEvent ? wrappedEvent.clientX - wrappedEvent.currentTarget.getBoundingClientRect().left : _localX;
         }
         
         private var _localX:Number;
@@ -533,7 +533,7 @@ package org.apache.royale.events
         
         public function get localY():Number
         {
-            return clientY;
+            return wrappedEvent ? wrappedEvent.clientY - wrappedEvent.currentTarget.getBoundingClientRect().top : _localY;
         }
         
         private var _localY:Number;


[royale-asjs] 02/03: fix a crash

Posted by ah...@apache.org.
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 0cec25fdc4737aa92b3791693ffbaf271884c638
Author: Alex Harui <ah...@apache.org>
AuthorDate: Sat Nov 16 19:17:50 2019 -0800

    fix a crash
---
 .../src/main/royale/mx/controls/beads/AdvancedDataGridSortBead.as   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/AdvancedDataGridSortBead.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/AdvancedDataGridSortBead.as
index 7692eeb..5df4061 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/AdvancedDataGridSortBead.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/AdvancedDataGridSortBead.as
@@ -56,8 +56,12 @@ package mx.controls.beads
 		 */
 		private function mouseClickHandler(event:MouseEvent):void
 		{
+            var buttonBar:DataGridButtonBar = ((adg.view as DataGridView).header as DataGridButtonBar);
+            // probably down on one button and up on another button
+            // so the ButtonBar won't change selection
+            if (event.target == buttonBar) return;
             var adgEvent:AdvancedDataGridEvent = new AdvancedDataGridEvent(AdvancedDataGridEvent.SORT);
-            adgEvent.columnIndex = ((adg.view as DataGridView).header as DataGridButtonBar).selectedIndex;
+            adgEvent.columnIndex = buttonBar.selectedIndex;
             adgEvent.dataField = adg.columns[adgEvent.columnIndex].dataField;
             adg.dispatchEvent(adgEvent);
 		}


[royale-asjs] 03/03: ADG Column Resizing. Graphic is bright red for now. Need new graphic

Posted by ah...@apache.org.
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 dc10b0b748bd6270120d85fe037fdf1e3349a0f6
Author: Alex Harui <ah...@apache.org>
AuthorDate: Sat Nov 16 19:18:30 2019 -0800

    ADG Column Resizing.  Graphic is bright red for now.  Need new graphic
---
 .../apache/royale/html/beads/DataGridLinesBead.as  |   2 +-
 .../main/royale/mx/controls/AdvancedDataGrid.as    |   2 +
 .../mx/controls/beads/DataGridColumnResizeBead.as  | 342 +++++++++++++++++++++
 .../beads/DataGridLinesBeadForICollectionView.as   |   9 +
 4 files changed, 354 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridLinesBead.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridLinesBead.as
index 9a044bd..6341217 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridLinesBead.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridLinesBead.as
@@ -123,7 +123,7 @@ package org.apache.royale.html.beads
 	     *  @playerversion AIR 2.6
 	     *  @productversion Royale 0.0
 		 */
-		private function handleInitComplete(event:Event):void
+		protected function handleInitComplete(event:Event):void
 		{
 			var host:UIBase = _strand as UIBase;
             _area = _view.listArea as UIBase;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/AdvancedDataGrid.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/AdvancedDataGrid.as
index c22b948..fc84bb2 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/AdvancedDataGrid.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/AdvancedDataGrid.as
@@ -51,6 +51,7 @@ package mx.controls
     import mx.controls.beads.AdvancedDataGridSortBead;
     import mx.controls.beads.AdvancedDataGridView;
     import mx.controls.beads.DataGridLinesBeadForICollectionView;
+    import mx.controls.beads.DataGridColumnResizeBead;
     import mx.controls.dataGridClasses.DataGridColumn;
     import mx.controls.listClasses.AdvancedListBase;
     import mx.core.mx_internal;
@@ -653,6 +654,7 @@ public class AdvancedDataGrid extends AdvancedListBase implements IDataGrid
         addEventListener(FlexEvent.UPDATE_COMPLETE, updateCompleteHandler); */
         
         addBead(new DataGridLinesBeadForICollectionView());
+        addBead(new DataGridColumnResizeBead());
     }
 
     //--------------------------------------------------------------------------
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/DataGridColumnResizeBead.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/DataGridColumnResizeBead.as
new file mode 100644
index 0000000..8d45924
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/DataGridColumnResizeBead.as
@@ -0,0 +1,342 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+    import mx.collections.ICollectionView;
+    import mx.controls.AdvancedDataGrid;
+    import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
+    import mx.events.AdvancedDataGridEvent;
+    
+    import org.apache.royale.core.IBead;
+    import org.apache.royale.core.IBeadModel;
+    import org.apache.royale.core.IDataGridModel;
+    import org.apache.royale.core.ILayoutHost;
+    import org.apache.royale.core.IParentIUIBase;
+    import org.apache.royale.core.IStrand;
+    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.graphics.IStroke;
+    import org.apache.royale.graphics.SolidColor;
+    import org.apache.royale.graphics.SolidColorStroke;
+    import org.apache.royale.html.DataGridButtonBar;
+    import org.apache.royale.html.beads.DataGridLinesBead;
+    import org.apache.royale.html.beads.DataGridView;
+    import org.apache.royale.html.beads.models.DataGridPresentationModel;
+    import org.apache.royale.svg.CompoundGraphic;
+    
+
+    
+	public class DataGridColumnResizeBead implements IBead
+	{
+		public function DataGridColumnResizeBead()
+		{
+			super();
+            // Set default separator line stroke.
+            var lineStroke:SolidColorStroke = new SolidColorStroke();
+            lineStroke.color = 0xFF0000; //0x333333;
+            lineStroke.alpha = 1.0;
+            lineStroke.weight = 3;
+            stroke = lineStroke;
+		}
+
+        protected var _strand:IStrand;
+        
+        private var _view:org.apache.royale.html.beads.DataGridView;
+        
+        private var adg:AdvancedDataGrid;
+        
+        /**                         	
+         *  @copy org.apache.royale.core.IBead#strand
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.0
+         */
+        public function set strand(value:IStrand):void
+        {
+            _strand = value;
+            var host:UIBase = _strand as UIBase;
+            _view = host.view as org.apache.royale.html.beads.DataGridView; // need to get its initComplete handler to run first
+            
+            _overlay = new CompoundGraphic();
+            
+            IEventDispatcher(_strand).addEventListener("initComplete", handleInitComplete);
+
+            adg = value as AdvancedDataGrid;            
+        }
+        
+        private var _stroke:IStroke;
+        
+        /**
+         * Describes the line style used to separate the rows and columns.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.0
+         */
+        public function get stroke():IStroke
+        {
+            return _stroke;
+        }
+        public function set stroke(value:IStroke):void
+        {
+            _stroke = value;
+        }
+        
+        protected var _overlay:CompoundGraphic;
+        protected var _header:UIBase;
+        protected var _dragGraphic:CompoundGraphic;
+        
+        /**
+         * Invoked when all of the beads have been added to the DataGrid. This
+         * function seeks the Container that parents the lists that are the DataGrid's
+         * columns. An overlay GraphicContainer is added to this Container so that the
+         * grid lines will scroll with the rows.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.0
+         */
+        private function handleInitComplete(event:Event):void
+        {
+            var host:UIBase = _strand as UIBase;
+            _header = _view.header as UIBase;
+            _header.addElement(_overlay);
+            _overlay.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler, false);
+            
+            // Now set up listeners to handle changes in the size of the DataGrid.
+            IEventDispatcher(_strand).addEventListener("sizeChanged", drawLines);
+            IEventDispatcher(_strand).addEventListener("widthChanged", drawLines);
+            IEventDispatcher(_strand).addEventListener("heightChanged", drawLines);
+            
+            // Also set up a listener on the model to know when the dataProvider has
+            // changed which might affect the number of rows/columns and thus the
+            // grid lines.
+            var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel;
+            IEventDispatcher(model).addEventListener("dataProviderChanged", drawLines);
+        }
+        
+
+        /**
+         * This event handler is invoked whenever something happens to the DataGrid. This
+         * function draws the lines either using a default stroke or the one specified by
+         * the stroke property.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.0
+         * 
+         *  @royaleignorecoercion Array
+         *  @royaleignorecoercion SVGElement
+         */
+        protected function drawLines(event:Event):void
+        {
+            var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
+            var columns:Array = sharedModel.columns;			
+            var totalHeight:Number = _header.height;
+            
+            // translate the stroke to a fill since rectangles are used for the grid
+            // lines and not lines.
+            var lineFill:SolidColor = new SolidColor();
+            var weight:Number = 1;
+            lineFill.color = (stroke as SolidColorStroke).color;
+            lineFill.alpha = 0; //(stroke as SolidColorStroke).alpha;  // invisible overlay over each column boundary
+            weight = (stroke as SolidColorStroke).weight;
+            _overlay.fill = lineFill;
+            COMPILE::JS
+            {
+                _overlay.element.style.position = "absolute";        
+                _overlay.element.style.pointerEvents = "none";        
+            }
+            
+            var xpos:Number = 0;
+            
+            _overlay.clear();
+            
+            var firstOne:Boolean = true;
+            // draw the verticals
+            for (var i:int=0; i < columns.length - 1; i++) {
+                var column:AdvancedDataGridColumn = columns[i] as AdvancedDataGridColumn;
+                if (column.visible)
+                {
+                    // if a column is visible, don't draw a resize target unless
+                    // there is a column to its right that is visible
+                    if (firstOne)
+                        firstOne = false;
+                    else
+                        _overlay.drawRect(xpos - (weight / 2), 0, weight, totalHeight);
+                    xpos += column.columnWidth;
+                }
+            }
+            COMPILE::JS
+            {
+                var rects:Array = _overlay.element.childNodes as Array; 
+                var n:int = rects.length;
+                for (i = 0; i < n; i++)
+                {
+                    var e:SVGElement = rects[i] as SVGElement;
+                    e.style.pointerEvents = "auto";
+                }
+            }
+            
+            /*
+            // draw the horizontals
+            for (i=1; i < n+1; i++) {
+                _overlay.drawRect(0, i*rowHeight, _area.width, weight);
+            }
+            */
+        }
+        
+        private var columnIndex:int;
+        
+        /**
+         * @private
+         */
+        private function mouseOverHandler(event:MouseEvent):void
+        {
+            var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
+            var columns:Array = sharedModel.columns;			
+            var totalHeight:Number = _header.height;
+            
+            _overlay.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler, false);
+            _overlay.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, false);
+            
+            // translate the stroke to a fill since rectangles are used for the grid
+            // lines and not lines.
+            var lineFill:SolidColor = new SolidColor();
+            var weight:Number = 1;
+            lineFill.color = (stroke as SolidColorStroke).color;
+            lineFill.alpha = (stroke as SolidColorStroke).alpha;
+            weight = (stroke as SolidColorStroke).weight;
+            
+            var xpos:Number = 0;
+
+            columnIndex = -1;
+            for (var i:int=0; i < columns.length - 1; i++) {
+                var column:AdvancedDataGridColumn = columns[i] as AdvancedDataGridColumn;
+                if (column.visible)
+                {
+                    xpos += column.columnWidth;
+                }
+                else
+                    continue;
+                var left:Number = xpos - (weight / 2);
+                var right:Number = left + weight;
+                if (left < event.localX && event.localX < right)
+                {
+                    columnIndex = i;
+                    break;
+                }
+            }
+            if (columnIndex == -1)
+                return;
+            
+            _dragGraphic = new CompoundGraphic();
+            _header.addElement(_dragGraphic);
+            _dragGraphic.fill = lineFill;
+            COMPILE::JS
+            {
+                _dragGraphic.element.style.position = "absolute";
+                _dragGraphic.element.style.pointerEvents = "none";
+            }
+            _dragGraphic.clear();
+            _dragGraphic.drawRect(weight / 2, 0, weight, totalHeight);
+            _dragGraphic.drawRect(0, (totalHeight / 2) - (weight / 2),
+                weight * 2, weight);
+            
+            _dragGraphic.x = xpos - weight;
+        }
+
+        /**
+         * @private
+         */
+        private function mouseOutHandler(event:MouseEvent):void
+        {
+            if (_dragGraphic)
+            {
+                _header.removeElement(_dragGraphic);
+                _dragGraphic = null;
+            }
+            _overlay.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler, false);
+            _overlay.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, false);
+        }
+
+        private var lastX:Number = -1;
+        private var startX:Number;
+        
+        /**
+         * @private
+         */
+        private function mouseDownHandler(event:MouseEvent):void
+        {
+            _overlay.removeEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler, false);
+            _header.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, false);
+            _header.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, false);
+            startX = lastX = event.localX;
+        }
+
+        /**
+         * @private
+         */
+        private function mouseMoveHandler(event:MouseEvent):void
+        {
+            if (!_dragGraphic) return;
+            var deltaX:Number = event.localX - lastX;
+            lastX = event.localX;
+            _dragGraphic.x += deltaX;            
+        }
+        
+        /**
+         * @private
+         */
+        private function mouseUpHandler(event:MouseEvent):void
+        {
+            if (_dragGraphic)
+            {
+                _header.removeElement(_dragGraphic);
+                _dragGraphic = null;
+            }
+            _header.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, false);
+            _header.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, false);
+            
+            var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
+            var columns:Array = sharedModel.columns;
+            var oldWidth:Number = columns[columnIndex].columnWidth;
+            var deltaWidth:Number = lastX - startX;
+            // set column.width to column.columnWidth.  The DG may scale
+            // columns to fit.
+            for (var i:int = 0; i < columns.length; i++)
+            {
+                columns[i].width = columns[i].columnWidth;
+            }
+            columns[columnIndex].width += deltaWidth;
+            columns[columnIndex].columnWidth += deltaWidth;
+            columns[columnIndex + 1].columnWidth -= deltaWidth;
+            columns[columnIndex + 1].width -= deltaWidth;
+            adg.dispatchEvent(new Event("layoutNeeded"));
+        }
+        
+	}
+}
\ No newline at end of file
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/DataGridLinesBeadForICollectionView.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/DataGridLinesBeadForICollectionView.as
index 0d6e02b..af8f51f 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/DataGridLinesBeadForICollectionView.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/DataGridLinesBeadForICollectionView.as
@@ -25,6 +25,7 @@ package mx.controls.beads
     import org.apache.royale.core.ILayoutHost;
     import org.apache.royale.core.IParentIUIBase;
     import org.apache.royale.events.Event;
+    import org.apache.royale.events.IEventDispatcher;
     import org.apache.royale.graphics.SolidColor;
     import org.apache.royale.graphics.SolidColorStroke;
     import org.apache.royale.html.beads.DataGridLinesBead;
@@ -37,6 +38,14 @@ package mx.controls.beads
 		{
 			super();
 		}
+        
+        override protected function handleInitComplete(event:Event):void
+        {
+            super.handleInitComplete(event);
+            // column resizing
+            IEventDispatcher(_strand).addEventListener("layoutNeeded", drawLines);
+        }
+
 		
         override protected function getDataProviderLength():int
         {