loleaflet/src/control/Parts.js | 2 - loleaflet/src/layer/tile/TileLayer.js | 55 +++++++++++++++++++++------------- loleaflet/src/map/Map.js | 22 ++++--------- test/data/hello-world.odp |binary test/data/hello-world.ods |binary 5 files changed, 43 insertions(+), 36 deletions(-)
New commits: commit 8211bef32fa5ffb97dff620398eae8ce69750852 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Sat Oct 6 23:17:13 2018 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Tue Oct 9 21:48:17 2018 +0100 Hide other view cursors on zoom. Change-Id: I9e953f841b5c526b499f9170aef9b2682011947e diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index ac601994b..573b46d76 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -1523,12 +1523,14 @@ L.TileLayer = L.GridLayer.extend({ _onZoomStart: function () { this._isZooming = true; this._onUpdateCursor(); + this.updateAllViewCursors(); }, _onZoomEnd: function () { this._isZooming = false; this._onUpdateCursor(); + this.updateAllViewCursors(); }, _updateCursorPos: function () { @@ -1604,8 +1606,11 @@ L.TileLayer = L.GridLayer.extend({ var viewCursorVisible = this._viewCursors[viewId].visible; var viewPart = this._viewCursors[viewId].part; - if (!this._map.isViewReadOnly(viewId) && viewCursorVisible && !this._isEmptyRectangle(this._viewCursors[viewId].bounds) && - (this._docType === 'text' || this._selectedPart === viewPart)) { + if (!this._map.isViewReadOnly(viewId) && + viewCursorVisible && + !this._isZooming && + !this._isEmptyRectangle(this._viewCursors[viewId].bounds) && + (this._docType === 'text' || this._selectedPart === viewPart)) { if (!viewCursorMarker) { var viewCursorOptions = { color: L.LOUtil.rgbToHex(this._map.getViewColor(viewId)), @@ -1629,6 +1634,12 @@ L.TileLayer = L.GridLayer.extend({ } }, + updateAllViewCursors : function() { + for (var key in this._viewCursors) { + this._onUpdateViewCursor(key); + } + }, + isCursorVisible: function() { return this._map.hasLayer(this._cursorMarker); }, diff --git a/test/data/hello-world.odp b/test/data/hello-world.odp index 9918755ef..774b8e3c9 100644 Binary files a/test/data/hello-world.odp and b/test/data/hello-world.odp differ diff --git a/test/data/hello-world.ods b/test/data/hello-world.ods index 37ddf33f1..eccadf96a 100644 Binary files a/test/data/hello-world.ods and b/test/data/hello-world.ods differ commit 70a99202fa47557ece32b0edae946934e68c12d0 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Sat Oct 6 23:01:56 2018 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Tue Oct 9 21:48:17 2018 +0100 cursor simplify. Don't show cursor when graphics are selected either. Change-Id: I0a604d73bd1818317a2b04d8bdd392d1d6472627 diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js index ff95def89..2b2ac80f6 100644 --- a/loleaflet/src/control/Parts.js +++ b/loleaflet/src/control/Parts.js @@ -22,7 +22,7 @@ L.Map.include({ else { return; } - if (docLayer._isCursorOverlayVisible) { + if (docLayer.isCursorVisible()) { // a click outside the slide to clear any selection this._socket.sendMessage('resetselection'); } diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index edc5183c3..ac601994b 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -87,8 +87,6 @@ L.TileLayer = L.GridLayer.extend({ this._documentInfo = ''; // Position and size of the visible cursor. this._visibleCursor = new L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(0, 0)); - // Cursor overlay is visible or hidden (for blinking). - this._isCursorOverlayVisible = false; // Do we have focus - ie. should we render a cursor this._isFocused = true; // Are we zooming currently ? - if so, no cursor. @@ -545,7 +543,6 @@ L.TileLayer = L.GridLayer.extend({ _onCursorVisibleMsg: function(textMsg) { var command = textMsg.match('cursorvisible: true'); this._isCursorVisible = command ? true : false; - this._isCursorOverlayVisible = true; this._onUpdateCursor(); }, @@ -759,8 +756,6 @@ L.TileLayer = L.GridLayer.extend({ this._visibleCursor = new L.LatLngBounds( this._twipsToLatLng(topLeftTwips, this._map.getZoom()), this._twipsToLatLng(bottomRightTwips, this._map.getZoom())); - this._visibleCursorOnLostFocus = this._visibleCursor; - this._isCursorOverlayVisible = true; if ((docLayer._followEditor || docLayer._followUser) && this._map.lastActionByUser) { this._map.fire('setFollowOff'); } @@ -1449,8 +1444,7 @@ L.TileLayer = L.GridLayer.extend({ }, _clearSelections: function () { - // hide the cursor - this._isCursorOverlayVisible = false; + // hide the cursor if not editable this._onUpdateCursor(); // hide the text selection this._selections.clearLayers(); @@ -1575,7 +1569,7 @@ L.TileLayer = L.GridLayer.extend({ this.eachView(this._viewCursors, function (item) { var viewCursorMarker = item.marker; if (viewCursorMarker) { - viewCursorMarker.setOpacity(this._map.hasLayer(this._cursorMarker) && this._cursorMarker.getLatLng().equals(viewCursorMarker.getLatLng()) ? 0 : 1); + viewCursorMarker.setOpacity(this.isCursorVisible() && this._cursorMarker.getLatLng().equals(viewCursorMarker.getLatLng()) ? 0 : 1); } }, this, true); }, @@ -1585,16 +1579,14 @@ L.TileLayer = L.GridLayer.extend({ _updateCursorAndOverlay: function (/*update*/) { if (this._map._permission === 'edit' && this._isCursorVisible // only when LOK has told us it is ok - && this._isCursorOverlayVisible && this._isFocused // not when document is not focused && !this._isZooming // not when zooming - && !this._graphicMarker._bounds // not when sizing / positioning graphics + && !this.isGraphicVisible() // not when sizing / positioning graphics && !this._isEmptyRectangle(this._visibleCursor)) { this._updateCursorPos(); } else if (this._cursorMarker) { this._map.removeLayer(this._cursorMarker); - this._isCursorOverlayVisible = false; } }, @@ -1629,7 +1621,7 @@ L.TileLayer = L.GridLayer.extend({ else { viewCursorMarker.setLatLng(viewCursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom()))); } - viewCursorMarker.setOpacity(this._map.hasLayer(this._cursorMarker) && this._cursorMarker.getLatLng().equals(viewCursorMarker.getLatLng()) ? 0 : 1); + viewCursorMarker.setOpacity(this.isCursorVisible() && this._cursorMarker.getLatLng().equals(viewCursorMarker.getLatLng()) ? 0 : 1); this._viewLayerGroup.addLayer(viewCursorMarker); } else if (viewCursorMarker) { @@ -1637,6 +1629,14 @@ L.TileLayer = L.GridLayer.extend({ } }, + isCursorVisible: function() { + return this._map.hasLayer(this._cursorMarker); + }, + + isGraphicVisible: function() { + return this._graphicMarker && this._map.hasLayer(this._graphicMarker); + }, + goToViewCursor: function(viewId) { if (viewId === this._viewId) { this._onUpdateCursor(); @@ -1803,7 +1803,6 @@ L.TileLayer = L.GridLayer.extend({ this._graphicMarker = L.rectangle(this._graphicSelection, { pointerEvents: 'none', fill: false}); - this._visibleCursor = this._visibleCursorOnLostFocus = this._graphicMarker._bounds; if (!this._graphicMarker) { this._map.fire('error', {msg: 'Graphic marker initialization', cmd: 'marker', kind: 'failed', id: 1}); return; @@ -1818,7 +1817,7 @@ L.TileLayer = L.GridLayer.extend({ this._map.removeLayer(this._graphicMarker); this._graphicMarker.isDragged = false; } - _updateCursorAndOverlay(); + this._updateCursorAndOverlay(); }, _onUpdateCellCursor: function (horizontalDirection, verticalDirection, onPgUpDn) { commit 1f54217261ecd1c73752b0d60e69515f344b76b1 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Sat Oct 6 22:37:50 2018 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Tue Oct 9 21:48:17 2018 +0100 First attempt to simplify cursor visibility. Removes race conditions between kit messages and browser. Avoid storing old state wherever possible. Change-Id: I56aa57df22a4190881c8d197df8445ca542d4fc1 diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 0410bc935..edc5183c3 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -89,8 +89,10 @@ L.TileLayer = L.GridLayer.extend({ this._visibleCursor = new L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(0, 0)); // Cursor overlay is visible or hidden (for blinking). this._isCursorOverlayVisible = false; - // Cursor overlay visibility flag to store last state during zooming - this._oldCursorOverlayVisibility = false; + // Do we have focus - ie. should we render a cursor + this._isFocused = true; + // Are we zooming currently ? - if so, no cursor. + this._isZooming = false; // Cursor is visible or hidden (e.g. for graphic selection). this._isCursorVisible = true; // Original rectangle graphic selection in twips @@ -757,7 +759,7 @@ L.TileLayer = L.GridLayer.extend({ this._visibleCursor = new L.LatLngBounds( this._twipsToLatLng(topLeftTwips, this._map.getZoom()), this._twipsToLatLng(bottomRightTwips, this._map.getZoom())); - this._visibleCursorOnLostFocus = this._visibleCursor; + this._visibleCursorOnLostFocus = this._visibleCursor; this._isCursorOverlayVisible = true; if ((docLayer._followEditor || docLayer._followUser) && this._map.lastActionByUser) { this._map.fire('setFollowOff'); @@ -1525,14 +1527,13 @@ L.TileLayer = L.GridLayer.extend({ }, _onZoomStart: function () { - this._oldCursorOverlayVisibility = this._isCursorOverlayVisible; - this._isCursorOverlayVisible = false; + this._isZooming = true; this._onUpdateCursor(); }, _onZoomEnd: function () { - this._isCursorOverlayVisible = this._oldCursorOverlayVisibility; + this._isZooming = false; this._onUpdateCursor(); }, @@ -1583,8 +1584,11 @@ L.TileLayer = L.GridLayer.extend({ // the state of the document (if the falgs are set) _updateCursorAndOverlay: function (/*update*/) { if (this._map._permission === 'edit' - && this._isCursorVisible + && this._isCursorVisible // only when LOK has told us it is ok && this._isCursorOverlayVisible + && this._isFocused // not when document is not focused + && !this._isZooming // not when zooming + && !this._graphicMarker._bounds // not when sizing / positioning graphics && !this._isEmptyRectangle(this._visibleCursor)) { this._updateCursorPos(); } @@ -1814,6 +1818,7 @@ L.TileLayer = L.GridLayer.extend({ this._map.removeLayer(this._graphicMarker); this._graphicMarker.isDragged = false; } + _updateCursorAndOverlay(); }, _onUpdateCellCursor: function (horizontalDirection, verticalDirection, onPgUpDn) { diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js index 7d0937f97..63d8fa194 100644 --- a/loleaflet/src/map/Map.js +++ b/loleaflet/src/map/Map.js @@ -988,15 +988,9 @@ L.Map = L.Evented.extend({ console.debug('_onLostFocus: '); var doclayer = this._docLayer; - if (!doclayer) { return; } - - // save state of cursor (blinking marker) and the cursor overlay - doclayer._isCursorVisibleOnLostFocus = doclayer._isCursorVisible; - doclayer._isCursorOverlayVisibleOnLostFocus = doclayer._isCursorOverlayVisible; - - // if the blinking cursor is visible, disable the overlay when we go out of focus - if (doclayer._isCursorVisible && doclayer._isCursorOverlayVisible) { - doclayer._isCursorOverlayVisible = false; + if (doclayer) + { + doclayer._isFocused = false; doclayer._updateCursorAndOverlay(); } @@ -1008,16 +1002,14 @@ L.Map = L.Evented.extend({ if (!this._loaded) { return; } var doclayer = this._docLayer; - if (doclayer && - typeof doclayer._isCursorOverlayVisibleOnLostFocus !== 'undefined' && - typeof doclayer._isCursorVisibleOnLostFocus !== 'undefined') { + if (doclayer) + { + doclayer._isFocused = true; // we restore the old cursor position by a small delay, so that if the user clicks // inside the document we skip to restore it, so that the user does not see the cursor // jumping from the old position to the new one setTimeout(function () { - // restore the state that was before focus was lost - doclayer._isCursorOverlayVisible = doclayer._isCursorOverlayVisibleOnLostFocus; - doclayer._isCursorVisible = doclayer._isCursorVisibleOnLostFocus; + console.debug('apply focus change in timeout'); doclayer._updateCursorAndOverlay(); }, 300); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits