loleaflet/build/deps.js                       |    4 +
 loleaflet/src/core/Socket.js                  |    2 
 loleaflet/src/layer/ObjectFocusDarkOverlay.js |   57 ++++++++++++++++++++++++++
 loleaflet/src/layer/tile/TileLayer.js         |   18 +++++++-
 loleaflet/src/map/Map.js                      |   21 +++++++++
 5 files changed, 98 insertions(+), 4 deletions(-)

New commits:
commit 17ab9909d67a98457aa7819b6e01f578bbb289b8
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Tue Jul 30 17:13:17 2019 +0200
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Thu Oct 17 21:47:32 2019 +0100

    Unify none state for _graphicSelection
    
    Change-Id: I8fb4f7813373b3b56a25040fc5d20e7592c6c92d

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 66c837fdf..fcc62e83b 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -915,7 +915,7 @@ L.Socket = L.Class.extend({
                if (this._map._docLayer) {
                        this._map._docLayer.removeAllViews();
                        this._map._docLayer._resetClientVisArea();
-                       this._map._docLayer._graphicSelection = null;
+                       this._map._docLayer._graphicSelection = new 
L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(0, 0));
                        this._map._docLayer._onUpdateGraphicSelection();
                }
 
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index fb0df110d..7587096fb 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -833,7 +833,7 @@ L.TileLayer = L.GridLayer.extend({
 
                                this._map.addObjectFocusDarkOverlay(xTwips, 
yTwips, wTwips, hTwips);
 
-                               this._graphicSelection = null;
+                               this._graphicSelection = new L.LatLngBounds(new 
L.LatLng(0, 0), new L.LatLng(0, 0));
                                this._onUpdateGraphicSelection();
                        }
                }
@@ -1819,7 +1819,7 @@ L.TileLayer = L.GridLayer.extend({
                // hide the selection handles
                this._onUpdateTextSelection();
                // hide the graphic selection
-               this._graphicSelection = null;
+               this._graphicSelection = new L.LatLngBounds(new L.LatLng(0, 0), 
new L.LatLng(0, 0));
                this._onUpdateGraphicSelection();
                this._cellCursor = null;
                this._onUpdateCellCursor();
commit d0474118250684214bf2226d15da5e8dea593d70
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Wed Jun 5 09:28:18 2019 +0200
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Thu Oct 17 21:16:53 2019 +0100

    Remove dark overlay after crash or disconnection
    
    Change-Id: Iceab041def6444b76c008a65d7fdeccb61126f84

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 39c2144b0..fb0df110d 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -822,21 +822,16 @@ L.TileLayer = L.GridLayer.extend({
                        this._resetSelectionRanges();
                }
                else if (textMsg.match('INPLACE EXIT')) {
-                       if (this._map.focusLayer) {
-                               this._map.removeLayer(this._map.focusLayer);
-                               this._map.focusLayer = null;
-                       }
+                       this._map.removeObjectFocusDarkOverlay();
                }
                else if (textMsg.match('INPLACE')) {
-                       if (!this._map.focusLayer) {
-                               this._map.focusLayer = new 
L.ObjectFocusDarkOverlay().addTo(this._map);
-
+                       if (!this._map.hasObjectFocusDarkOverlay()) {
                                var xTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getNorthWest()).x;
                                var yTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getNorthWest()).y;
                                var wTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getSouthEast()).x - 
xTwips;
                                var hTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getSouthEast()).y - 
yTwips;
 
-                               this._map.focusLayer.show({x: xTwips, y: 
yTwips, w: wTwips, h: hTwips});
+                               this._map.addObjectFocusDarkOverlay(xTwips, 
yTwips, wTwips, hTwips);
 
                                this._graphicSelection = null;
                                this._onUpdateGraphicSelection();
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 628227522..d5feb7c25 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -317,6 +317,7 @@ L.Map = L.Evented.extend({
 
        loadDocument: function(socket) {
                this._socket.connect(socket);
+               this.removeObjectFocusDarkOverlay();
        },
 
        sendInitUNOCommands: function() {
@@ -1731,7 +1732,25 @@ L.Map = L.Evented.extend({
 
        isRulerVisible: function() {
                return $('.loleaflet-ruler').is(':visible');
-       }
+       },
+
+       hasObjectFocusDarkOverlay: function() {
+               return !!this.focusLayer;
+       },
+
+       addObjectFocusDarkOverlay: function(xTwips, yTwips, wTwips, hTwips) {
+               if (!this.hasObjectFocusDarkOverlay()) {
+                       this.focusLayer = new 
L.ObjectFocusDarkOverlay().addTo(this);
+                       this.focusLayer.show({x: xTwips, y: yTwips, w: wTwips, 
h: hTwips});
+               }
+       },
+
+       removeObjectFocusDarkOverlay: function() {
+               if (this.hasObjectFocusDarkOverlay()) {
+                       this.removeLayer(this.focusLayer);
+                       this.focusLayer = null;
+               }
+       },
 });
 
 L.map = function (id, options) {
commit f0921608143f4fdeec2ed49fe2ddce72da3855ed
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Fri May 31 19:23:38 2019 +0200
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Thu Oct 17 21:16:53 2019 +0100

    Don't allow to enter incorrect state with dark overlay
    
    Change-Id: Idda18b8ba916bdb421a205290fd4569fb11d203b

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 54f0c231a..39c2144b0 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -822,7 +822,7 @@ L.TileLayer = L.GridLayer.extend({
                        this._resetSelectionRanges();
                }
                else if (textMsg.match('INPLACE EXIT')) {
-                       if (this._map.hasLayer(this._map.focusLayer)) {
+                       if (this._map.focusLayer) {
                                this._map.removeLayer(this._map.focusLayer);
                                this._map.focusLayer = null;
                        }
@@ -830,17 +830,17 @@ L.TileLayer = L.GridLayer.extend({
                else if (textMsg.match('INPLACE')) {
                        if (!this._map.focusLayer) {
                                this._map.focusLayer = new 
L.ObjectFocusDarkOverlay().addTo(this._map);
-                       }
 
-                       var xTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getNorthWest()).x;
-                       var yTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getNorthWest()).y;
-                       var wTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getSouthEast()).x - 
xTwips;
-                       var hTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getSouthEast()).y - 
yTwips;
+                               var xTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getNorthWest()).x;
+                               var yTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getNorthWest()).y;
+                               var wTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getSouthEast()).x - 
xTwips;
+                               var hTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getSouthEast()).y - 
yTwips;
 
-                       this._map.focusLayer.show({x: xTwips, y: yTwips, w: 
wTwips, h: hTwips});
+                               this._map.focusLayer.show({x: xTwips, y: 
yTwips, w: wTwips, h: hTwips});
 
-                       this._graphicSelection = null;
-                       this._onUpdateGraphicSelection();
+                               this._graphicSelection = null;
+                               this._onUpdateGraphicSelection();
+                       }
                }
                else {
                        textMsg = '[' + 
textMsg.substr('graphicselection:'.length) + ']';
commit d14b7ef8112b0c630e5ed9312be379894221ceb1
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Fri May 31 11:58:48 2019 +0200
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Thu Oct 17 21:16:53 2019 +0100

    ObjectFocusDarkOverlay refactoring
    
    Change-Id: Id53c3db15c4be65ca10b6b00dca2638023b7918b

diff --git a/loleaflet/src/layer/ObjectFocusDarkOverlay.js 
b/loleaflet/src/layer/ObjectFocusDarkOverlay.js
index ad012650b..16e8eddde 100644
--- a/loleaflet/src/layer/ObjectFocusDarkOverlay.js
+++ b/loleaflet/src/layer/ObjectFocusDarkOverlay.js
@@ -5,10 +5,7 @@
 
 L.ObjectFocusDarkOverlay = L.Layer.extend({
        onAdd: function() {
-       },
-
-       remove: function() {
-       },
+       }
 });
 
 // Libreoffice-specific functionality follows.
@@ -17,14 +14,10 @@ L.ObjectFocusDarkOverlay = L.Layer.extend({
  * A L.ObjectFocusDarkOverlay
  */
 L.ObjectFocusDarkOverlay = L.ObjectFocusDarkOverlay.extend({
-       onAdd: function(map) {
-               map.on('inplace', this._onStateChanged, this);
-       },
-
-       remove: function() {
-               this._map.off('inplace', this._onStateChanged, this);
+       onRemove: function() {
                this._parts.clearLayers();
                this._map.removeLayer(this._parts);
+               this._parts = null;
        },
 
        // coordinates are in Twips
@@ -47,14 +40,9 @@ L.ObjectFocusDarkOverlay = L.ObjectFocusDarkOverlay.extend({
                this._parts.addLayer(part);
        },
 
-       _onStateChanged: function(args) {
-               if (args.off && args.off === true) {
-                       this._parts.clearLayers();
-                       this._map.removeLayer(this._parts);
-                       this._parts = null;
-                       return;
-               }
-
+       // args: {x, y, w, h}
+       // defines area where the focused element is placed, values are in Twips
+       show: function(args) {
                this._parts = new L.LayerGroup();
                this._map.addLayer(this._parts);
 
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index f2976b152..54f0c231a 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -821,13 +821,24 @@ L.TileLayer = L.GridLayer.extend({
                if (textMsg.match('EMPTY')) {
                        this._resetSelectionRanges();
                }
+               else if (textMsg.match('INPLACE EXIT')) {
+                       if (this._map.hasLayer(this._map.focusLayer)) {
+                               this._map.removeLayer(this._map.focusLayer);
+                               this._map.focusLayer = null;
+                       }
+               }
                else if (textMsg.match('INPLACE')) {
+                       if (!this._map.focusLayer) {
+                               this._map.focusLayer = new 
L.ObjectFocusDarkOverlay().addTo(this._map);
+                       }
+
                        var xTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getNorthWest()).x;
                        var yTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getNorthWest()).y;
                        var wTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getSouthEast()).x - 
xTwips;
                        var hTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getSouthEast()).y - 
yTwips;
 
-                       this._map.fire('inplace', {x: xTwips, y: yTwips, w: 
wTwips, h: hTwips});
+                       this._map.focusLayer.show({x: xTwips, y: yTwips, w: 
wTwips, h: hTwips});
+
                        this._graphicSelection = null;
                        this._onUpdateGraphicSelection();
                }
commit 8eb003f90fb220ce8b497d6a556d94430e33c6a7
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Tue May 28 16:15:54 2019 +0200
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Thu Oct 17 21:16:53 2019 +0100

    Added ObjectFocusDarkOverlay based on L.Polygon
    
    Layer which shows dark overlay around edited chart.
    
    Change-Id: I1fd87f60e7ba58524481598baf5b012f4fb3d96f

diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index f003f06fe..d9bf83bf2 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -37,7 +37,9 @@ var deps = {
 
        TileLayer: {
                src: ['layer/tile/TileLayer.js',
-                         'layer/tile/TileLayer.TableOverlay.js'],
+                     'layer/tile/TileLayer.TableOverlay.js',
+                     'layer/ObjectFocusDarkOverlay.js'
+               ],
                desc: 'The base class for displaying tile layers on the map.',
                deps: ['GridLayer']
        },
diff --git a/loleaflet/src/layer/ObjectFocusDarkOverlay.js 
b/loleaflet/src/layer/ObjectFocusDarkOverlay.js
new file mode 100644
index 000000000..ad012650b
--- /dev/null
+++ b/loleaflet/src/layer/ObjectFocusDarkOverlay.js
@@ -0,0 +1,69 @@
+/*
+ * A Leaflet layer that shows dark overlay around focused object.
+ *
+ */
+
+L.ObjectFocusDarkOverlay = L.Layer.extend({
+       onAdd: function() {
+       },
+
+       remove: function() {
+       },
+});
+
+// Libreoffice-specific functionality follows.
+
+/*
+ * A L.ObjectFocusDarkOverlay
+ */
+L.ObjectFocusDarkOverlay = L.ObjectFocusDarkOverlay.extend({
+       onAdd: function(map) {
+               map.on('inplace', this._onStateChanged, this);
+       },
+
+       remove: function() {
+               this._map.off('inplace', this._onStateChanged, this);
+               this._parts.clearLayers();
+               this._map.removeLayer(this._parts);
+       },
+
+       // coordinates are in Twips
+       _addPart: function(x, y, w, h) {
+               var rectangles = [];
+               var topLeftTwips = new L.Point(x, y);
+               var topRightTwips = topLeftTwips.add(new L.Point(w, 0));
+               var bottomLeftTwips = topLeftTwips.add(new L.Point(0, h));
+               var bottomRightTwips = topLeftTwips.add(new L.Point(w, h));
+               rectangles.push([bottomLeftTwips, bottomRightTwips, 
topLeftTwips, topRightTwips]);
+
+               var polygons = L.PolyUtil.rectanglesToPolygons(rectangles, 
this._map._docLayer);
+               var part = new L.Polygon(polygons, {
+                       pointerEvents: 'none',
+                       fillColor: 'black',
+                       fillOpacity: 0.25,
+                       weight: 0,
+                       opacity: 0.25});
+
+               this._parts.addLayer(part);
+       },
+
+       _onStateChanged: function(args) {
+               if (args.off && args.off === true) {
+                       this._parts.clearLayers();
+                       this._map.removeLayer(this._parts);
+                       this._parts = null;
+                       return;
+               }
+
+               this._parts = new L.LayerGroup();
+               this._map.addLayer(this._parts);
+
+               var fullWidth = 1000000;
+               var fullHeight = 1000000;
+
+               this._addPart(0, 0, fullWidth, args.y);
+               this._addPart(0, args.y, args.x, args.h);
+               this._addPart(args.x + args.w, args.y, fullWidth, args.h);
+               this._addPart(0, (args.y + args.h), fullWidth, fullHeight);
+       }
+});
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 2c5364289..f2976b152 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -821,6 +821,16 @@ L.TileLayer = L.GridLayer.extend({
                if (textMsg.match('EMPTY')) {
                        this._resetSelectionRanges();
                }
+               else if (textMsg.match('INPLACE')) {
+                       var xTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getNorthWest()).x;
+                       var yTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getNorthWest()).y;
+                       var wTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getSouthEast()).x - 
xTwips;
+                       var hTwips = 
this._map._docLayer._latLngToTwips(this._graphicSelection.getSouthEast()).y - 
yTwips;
+
+                       this._map.fire('inplace', {x: xTwips, y: yTwips, w: 
wTwips, h: hTwips});
+                       this._graphicSelection = null;
+                       this._onUpdateGraphicSelection();
+               }
                else {
                        textMsg = '[' + 
textMsg.substr('graphicselection:'.length) + ']';
                        var msgData = JSON.parse(textMsg);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to