loleaflet/src/control/Parts.js | 1 loleaflet/src/layer/tile/TileLayer.js | 55 ++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 15 deletions(-)
New commits: commit 663f47b858749688588cc399c16ecfe126618f50 Author: Henry Castro <hcas...@collabora.com> Date: Tue Sep 13 16:18:00 2016 -0400 loleaflet: update graphic markers LayerGroup handle internal list Map handle internal list TileLayer handle internal list Reduce internal list diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js index 45fd68d..f6c9a18 100644 --- a/loleaflet/src/control/Parts.js +++ b/loleaflet/src/control/Parts.js @@ -33,6 +33,7 @@ L.Map.include({ this._socket.sendMessage('setclientpart part=' + docLayer._selectedPart); docLayer._updateViewCursors(); docLayer._updateCellViewCursors(); + docLayer._updateGraphicViewSelections(); docLayer._clearSelections(); docLayer._updateOnChangePart(); docLayer._pruneTiles(); diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 8b40da6..e9594ae 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -146,10 +146,6 @@ L.TileLayer = L.GridLayer.extend({ map.addLayer(this._viewSelectionsGroup); this._viewSelections = {}; - this._graphicViewMarkersGroup = new L.LayerGroup(); - map.addLayer(this._graphicViewMarkersGroup); - this._graphicViewMarkers = {}; - this._searchResultsLayer = new L.LayerGroup(); map.addLayer(this._searchResultsLayer); @@ -500,23 +496,21 @@ L.TileLayer = L.GridLayer.extend({ } var strTwips = obj.selection.match(/\d+/g); - if (this._graphicViewMarkers[viewId]) { - this._graphicViewMarkersGroup.removeLayer(this._graphicViewMarkers[viewId]); - } + this._graphicViewMarkers[viewId] = this._graphicViewMarkers[viewId] || {}; + this._graphicViewMarkers[viewId].part = parseInt(obj.part); if (strTwips != null) { var topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1])); var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3])); var bottomRightTwips = topLeftTwips.add(offset); - var graphicSelection = new L.LatLngBounds( + this._graphicViewMarkers[viewId].bounds = new L.LatLngBounds( this._twipsToLatLng(topLeftTwips, this._map.getZoom()), this._twipsToLatLng(bottomRightTwips, this._map.getZoom())); - this._graphicViewMarkers[viewId] = L.rectangle(graphicSelection, { - pointerEvents: 'none', - fill: false, - color: L.LOUtil.getViewIdHexColor(viewId) - }); - this._graphicViewMarkersGroup.addLayer(this._graphicViewMarkers[viewId]); } + else { + this._graphicViewMarkers[viewId].bounds = L.LatLngBounds.createDefault(); + } + + this._onUpdateGraphicViewSelection(viewId); }, _onCellCursorMsg: function (textMsg) { @@ -1153,7 +1147,7 @@ L.TileLayer = L.GridLayer.extend({ }, // Update colored non-blinking view cursor - _onUpdateViewCursor: function(viewId) { + _onUpdateViewCursor: function (viewId) { if (typeof this._viewCursors[viewId] !== 'object' || typeof this._viewCursors[viewId].bounds !== 'object') { return; @@ -1189,6 +1183,31 @@ L.TileLayer = L.GridLayer.extend({ } }, + _onUpdateGraphicViewSelection: function (viewId) { + var viewBounds = this._graphicViewMarkers[viewId].bounds; + var viewMarker = this._graphicViewMarkers[viewId].marker; + var viewPart = this._graphicViewMarkers[viewId].part; + + if (!this._isEmptyRectangle(viewBounds) && + (this._docType === 'text' || this._selectedPart === viewPart)) { + if (!viewMarker) { + viewMarker = L.rectangle(viewBounds, { + pointerEvents: 'none', + fill: false, + color: L.LOUtil.getViewIdHexColor(viewId) + }); + this._graphicViewMarkers[viewId].marker = viewMarker; + } + else { + viewMarker.setBounds(viewBounds); + } + this._map.addLayer(viewMarker); + } + else if (viewMarker) { + this._map.removeLayer(viewMarker); + } + }, + _updateViewCursors: function () { for (var key in this._viewCursors) { this._onUpdateViewCursor(key); @@ -1201,6 +1220,12 @@ L.TileLayer = L.GridLayer.extend({ } }, + _updateGraphicViewSelections: function () { + for (var key in this._graphicViewMarkers) { + this._onUpdateGraphicViewSelection(key); + } + }, + // Update dragged graphics selection resize. _onGraphicEdit: function (e) { if (!e.handle) { return; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits