[Libreoffice-commits] online.git: 2 commits - loleaflet/src

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon May 20 08:39:44 UTC 2019


 loleaflet/src/layer/tile/TileLayer.js        |   30 +++++++++++++++++----
 loleaflet/src/layer/vector/Path.Transform.js |   38 ++++++++++++++++++++++-----
 loleaflet/src/layer/vector/SVGGroup.js       |    6 ++--
 3 files changed, 58 insertions(+), 16 deletions(-)

New commits:
commit 88e941c659ae7d4f62934e14c2278aad0547fe52
Author:     Marco Cecchetti <mrcekets at gmail.com>
AuthorDate: Wed Apr 10 23:23:34 2019 +0200
Commit:     Marco Cecchetti <mrcekets at gmail.com>
CommitDate: Mon May 20 10:39:40 2019 +0200

    loleaflet: exploiting new selection handling properties
    
    We use the new information sent by core through the graphic selection
    message, for showing only the meaning handler for the current selected
    object.
    
    Change-Id: I20a2d59583b89701b0f61c27c469fa916eabe20a
    Reviewed-on: https://gerrit.libreoffice.org/70572
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    Tested-by: Marco Cecchetti <mrcekets at gmail.com>

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 6878229a6..6028fe3ad 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -660,6 +660,9 @@ L.TileLayer = L.GridLayer.extend({
 							this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
 			this._graphicSelectionAngle = (strTwips.length > 4) ? parseInt(strTwips[4]) : 0;
 			this._isSelectionWriterGraphic = false;
+			this._isGraphicSelectionDraggable = true;
+			this._isGraphicSelectionResizable = true;
+			this._isGraphicSelectionRotatable = true;
 
 			if (data.length > 1) {
 				var properties = data[1].slice(0, -1).split(',');
@@ -674,12 +677,21 @@ L.TileLayer = L.GridLayer.extend({
 					if (name === 'WriterGraphic') {
 						this._isSelectionWriterGraphic = value;
 					}
+					else if (name === 'Draggable') {
+						this._isGraphicSelectionDraggable = value;
+					}
+					else if (name === 'Resizable') {
+						this._isGraphicSelectionResizable = value;
+					}
+					else if (name === 'Rotatable') {
+						this._isGraphicSelectionRotatable = value;
+					}
 				}
 			}
 			// Workaround for tdf#123874. For some reason the handling of the
 			// shapeselectioncontent messages that we get back causes the WebKit process
 			// to crash on iOS.
-			if (!window.ThisIsTheiOSApp) {
+			if (!window.ThisIsTheiOSApp && this._isGraphicSelectionDraggable) {
 				this._map._socket.sendMessage('rendershapeselection mimetype=image/svg+xml');
 			}
 		}
@@ -2108,7 +2120,8 @@ L.TileLayer = L.GridLayer.extend({
 				this._graphicMarker.removeEventParent(this._map);
 				this._graphicMarker.off('scalestart scaleend', this._onGraphicEdit, this);
 				this._graphicMarker.off('rotatestart rotateend', this._onGraphicRotate, this);
-				this._graphicMarker.dragging.disable();
+				if (this._graphicMarker.dragging)
+					this._graphicMarker.dragging.disable();
 				this._graphicMarker.transform.disable();
 				this._map.removeLayer(this._graphicMarker);
 			}
@@ -2118,7 +2131,7 @@ L.TileLayer = L.GridLayer.extend({
 			}
 
 			this._graphicMarker = L.svgGroup(this._graphicSelection, {
-				draggable: true,
+				draggable: this._isGraphicSelectionDraggable,
 				transform: true,
 				stroke: false,
 				fillOpacity: 0,
@@ -2134,14 +2147,19 @@ L.TileLayer = L.GridLayer.extend({
 			this._graphicMarker.on('scalestart scaleend', this._onGraphicEdit, this);
 			this._graphicMarker.on('rotatestart rotateend', this._onGraphicRotate, this);
 			this._map.addLayer(this._graphicMarker);
-			this._graphicMarker.dragging.enable();
-			this._graphicMarker.transform.enable({uniformScaling: !this._isGraphicAngleDivisibleBy90()});
+			if (this._isGraphicSelectionDraggable)
+				this._graphicMarker.dragging.enable();
+			this._graphicMarker.transform.enable({
+				scaling: this._isGraphicSelectionResizable,
+				rotation: this._isGraphicSelectionRotatable,
+				uniformScaling: !this._isGraphicAngleDivisibleBy90()});
 		}
 		else if (this._graphicMarker) {
 			this._graphicMarker.off('graphicmovestart graphicmoveend', this._onGraphicMove, this);
 			this._graphicMarker.off('scalestart scaleend', this._onGraphicEdit, this);
 			this._graphicMarker.off('rotatestart rotateend', this._onGraphicRotate, this);
-			this._graphicMarker.dragging.disable();
+			if (this._graphicMarker.dragging)
+				this._graphicMarker.dragging.disable();
 			this._graphicMarker.transform.disable();
 			this._map.removeLayer(this._graphicMarker);
 			this._graphicMarker.isDragged = false;
diff --git a/loleaflet/src/layer/vector/Path.Transform.js b/loleaflet/src/layer/vector/Path.Transform.js
index 492bc510e..0a45e6823 100644
--- a/loleaflet/src/layer/vector/Path.Transform.js
+++ b/loleaflet/src/layer/vector/Path.Transform.js
@@ -690,8 +690,10 @@ L.Handler.PathTransform = L.Handler.extend({
 				pos: this._getPoints()[this._activeMarker.options.index]
 			});
 
-		this._map.removeLayer(this._handleLine);
-		this._map.removeLayer(this._rotationMarker);
+		if (this.options.rotation) {
+			this._map.removeLayer(this._handleLine);
+			this._map.removeLayer(this._rotationMarker);
+		}
 
 		//this._handleLine = this._rotationMarker = null;
 	},
@@ -739,8 +741,10 @@ L.Handler.PathTransform = L.Handler.extend({
 			.off('mousemove', this._onScale,    this)
 			.off('mouseup',   this._onScaleEnd, this);
 
-		this._map.addLayer(this._handleLine);
-		this._map.addLayer(this._rotationMarker);
+		if (this.options.rotation) {
+			this._map.addLayer(this._handleLine);
+			this._map.addLayer(this._rotationMarker);
+		}
 
 		var type;
 		var index = this._activeMarker.options.index;
diff --git a/loleaflet/src/layer/vector/SVGGroup.js b/loleaflet/src/layer/vector/SVGGroup.js
index 12c3a2931..fb58fe528 100644
--- a/loleaflet/src/layer/vector/SVGGroup.js
+++ b/loleaflet/src/layer/vector/SVGGroup.js
@@ -57,7 +57,7 @@ L.SVGGroup = L.Layer.extend({
 			this.lastTouchEvent.clientY = evt.touches[0].clientY;
 		}
 
-		if (!this._dragShape)
+		if (!this._dragShape || !this.dragging)
 			return;
 		this._moved = false;
 
@@ -83,7 +83,7 @@ L.SVGGroup = L.Layer.extend({
 			this.lastTouchEvent.clientY = evt.touches[0].clientY;
 		}
 
-		if (!this._dragShape)
+		if (!this._dragShape || !this.dragging)
 			return;
 
 		if (!this._moved) {
@@ -103,7 +103,7 @@ L.SVGGroup = L.Layer.extend({
 		if (evt.type === 'touchend' && evt.touches.length == 0)
 			evt.touches[0] = {clientX: this.lastTouchEvent.clientX, clientY: this.lastTouchEvent.clientY};
 
-		if (!this._dragShape)
+		if (!this._dragShape || !this.dragging)
 			return;
 		L.DomEvent.off(this._dragShape, 'mousemove', this._onDrag, this);
 		L.DomEvent.off(this._dragShape, 'mouseup', this._onDragEnd, this);
commit d3f89829445f59667660d875a5021b92d3dca279
Author:     Marco Cecchetti <mrcekets at gmail.com>
AuthorDate: Mon Mar 4 20:36:45 2019 +0100
Commit:     Marco Cecchetti <mrcekets at gmail.com>
CommitDate: Mon May 20 10:39:25 2019 +0200

    leaflet: after resizing a shape, dragging cursor with mouse pans view
    
    The problem was in Path.Transform._apply executed at scale/rotate end
    which enabled map dragging unconditionally.
    
    Change-Id: Id42dc7de397a2ca2774f9d31a698c32b5e1c8514
    Reviewed-on: https://gerrit.libreoffice.org/70571
    Reviewed-by: Marco Cecchetti <mrcekets at gmail.com>
    Tested-by: Marco Cecchetti <mrcekets at gmail.com>

diff --git a/loleaflet/src/layer/vector/Path.Transform.js b/loleaflet/src/layer/vector/Path.Transform.js
index 4f8c45c03..492bc510e 100644
--- a/loleaflet/src/layer/vector/Path.Transform.js
+++ b/loleaflet/src/layer/vector/Path.Transform.js
@@ -282,6 +282,7 @@ L.Handler.PathTransform = L.Handler.extend({
 		var matrix = this._matrix.clone();
 		var angle = this._angle;
 		var scale = this._scale.clone();
+		var moved = this._handleDragged;
 
 		this._transformGeometries();
 
@@ -299,7 +300,11 @@ L.Handler.PathTransform = L.Handler.extend({
 
 		this._updateHandlers();
 
-		map.dragging.enable();
+		if (this._mapDraggingWasEnabled) {
+			if (moved) L.DomEvent._fakeStop({ type: 'click' });
+			map.dragging.enable();
+		}
+
 		this._path.fire('transformed', {
 			matrix: matrix,
 			scale: scale,
@@ -574,7 +579,12 @@ L.Handler.PathTransform = L.Handler.extend({
 	_onRotateStart: function(evt) {
 		var map = this._map;
 
-		map.dragging.disable();
+		this._handleDragged = false;
+		this._mapDraggingWasEnabled = false;
+		if (map.dragging.enabled()) {
+			map.dragging.disable();
+			this._mapDraggingWasEnabled = true;
+		}
 
 		this._originMarker     = null;
 		this._rotationOriginPt = map.latLngToLayerPoint(this._getRotationOrigin());
@@ -602,6 +612,8 @@ L.Handler.PathTransform = L.Handler.extend({
 		var previous = this._rotationStart;
 		var origin   = this._rotationOriginPt;
 
+		this._handleDragged = true;
+
 		// rotation step angle
 		this._angle = Math.atan2(pos.y - origin.y, pos.x - origin.x) -
 			Math.atan2(previous.y - origin.y, previous.x - origin.x);
@@ -647,7 +659,12 @@ L.Handler.PathTransform = L.Handler.extend({
 		var marker = evt.target;
 		var map = this._map;
 
-		map.dragging.disable();
+		this._handleDragged = false;
+		this._mapDraggingWasEnabled = false;
+		if (map.dragging.enabled()) {
+			map.dragging.disable();
+			this._mapDraggingWasEnabled = true;
+		}
 
 		this._activeMarker = marker;
 
@@ -686,6 +703,9 @@ L.Handler.PathTransform = L.Handler.extend({
 	_onScale: function(evt) {
 		var originPoint = this._originMarker._point;
 		var ratioX, ratioY;
+
+		this._handleDragged = true;
+
 		if (this.options.uniformScaling) {
 			ratioX = originPoint.distanceTo(evt.layerPoint) / this._initialDist;
 			ratioY = ratioX;


More information about the Libreoffice-commits mailing list