[Libreoffice-commits] online.git: Branch 'libreoffice-5-3' - 2 commits - loleaflet/src
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Mon Mar 27 01:17:55 UTC 2017
loleaflet/src/control/Control.Header.js | 23 +++++++++++++++++++--
loleaflet/src/layer/tile/TileLayer.js | 35 +++++++++++++++++++++-----------
loleaflet/src/map/Map.js | 22 ++++++++++----------
3 files changed, 57 insertions(+), 23 deletions(-)
New commits:
commit dd3b68e0f6c66d3091ec13546274fbb72f9c5bce
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Mon Dec 5 21:58:07 2016 +0100
tdf#106595 don't scroll to the cursor position after focus lose/get
Change-Id: Id017c5ea8c162a71a8b4d8ec47a6d9deb7357fca
Reviewed-on: https://gerrit.libreoffice.org/35354
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index d196f046..c4618fb5 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1289,11 +1289,31 @@ L.TileLayer = L.GridLayer.extend({
}
}
- if (this._map._permission === 'edit' && this._isCursorVisible && this._isCursorOverlayVisible
- && !this._isEmptyRectangle(this._visibleCursor)) {
+ this._updateCursorAndOverlay();
+
+ 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);
+ }
+ }, this, true);
+ },
+
+ // enable or disable blinking cursor and the cursor overlay depending on
+ // the state of the document (if the falgs are set)
+ _updateCursorAndOverlay: function (update) {
+ if (this._map._permission === 'edit'
+ && this._isCursorVisible
+ && this._isCursorOverlayVisible
+ && !this._isEmptyRectangle(this._visibleCursor)) {
+
+ var pixBounds = L.bounds(this._map.latLngToLayerPoint(this._visibleCursor.getSouthWest()),
+ this._map.latLngToLayerPoint(this._visibleCursor.getNorthEast()));
+
+ var cursorPos = this._visibleCursor.getNorthWest();
+
if (!this._cursorMarker) {
- this._cursorMarker = L.cursor(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())),
- {blink: true});
+ this._cursorMarker = L.cursor(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())), {blink: true});
}
else {
this._cursorMarker.setLatLng(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())));
@@ -1304,13 +1324,6 @@ L.TileLayer = L.GridLayer.extend({
this._map.removeLayer(this._cursorMarker);
this._isCursorOverlayVisible = false;
}
-
- 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);
- }
- }, this, true);
},
// Update colored non-blinking view cursor
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 7e103244..bc1b2790 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -824,14 +824,16 @@ L.Map = L.Evented.extend({
if (!this._loaded) { return; }
var doclayer = this._docLayer;
- if (!doclayer) {
- return;
- }
- doclayer._isCursorVisibleOnLostFocus = doclayer._isCursorOverlayVisible;
+ 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;
- doclayer._onUpdateCursor();
+ doclayer._updateCursorAndOverlay();
}
this._deactivate();
@@ -841,15 +843,15 @@ L.Map = L.Evented.extend({
if (!this._loaded) { return; }
var doclayer = this._docLayer;
- if (doclayer && doclayer._isCursorVisibleOnLostFocus && doclayer._isCursorOverlayVisibleOnLostFocus) {
+ if (doclayer) {
// 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 () {
- if (doclayer._isCursorOverlayVisible) { return; } // user has clicked inside the document
- doclayer._isCursorOverlayVisible = doclayer._isCursorVisible = true;
- doclayer._visibleCursor = doclayer._visibleCursorOnLostFocus;
- doclayer._onUpdateCursor();
+ // restore the state that was before focus was lost
+ doclayer._isCursorOverlayVisible = doclayer._isCursorOverlayVisibleOnLostFocus;
+ doclayer._isCursorVisible = doclayer._isCursorVisibleOnLostFocus;
+ doclayer._updateCursorAndOverlay();
}, 300);
}
commit a7a2578d4535e8d39dd0beac8a466f9d7f81f864
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Sat Dec 3 14:28:04 2016 +0100
tdf#106598 loleaflet - calc: row/col header unproperly highlighted
Change-Id: I7299dedf8d42e7f185c8977270c4fa8c0d14b820
Reviewed-on: https://gerrit.libreoffice.org/35353
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/loleaflet/src/control/Control.Header.js b/loleaflet/src/control/Control.Header.js
index 7a6c42b1..8d19ec64 100644
--- a/loleaflet/src/control/Control.Header.js
+++ b/loleaflet/src/control/Control.Header.js
@@ -35,6 +35,10 @@ L.Control.Header = L.Control.extend({
this.unselect(childs[iterator]);
}
this._selection.start = this._selection.end = -1;
+ // after clearing selection, we need to select the header entry for the current cursor position,
+ // since we can't be sure that the selection clearing is due to click on a cell
+ // different from the one where the cursor is already placed
+ this.select(childs[this._current]);
},
updateSelection: function(element, start, end) {
@@ -58,6 +62,15 @@ L.Control.Header = L.Control.extend({
break;
}
}
+
+ // we need to unselect the row (column) header entry for the current cell cursor position
+ // since the selection could be due to selecting a whole row (column), so the selection
+ // does not start by clicking on a cell
+ if (this._current !== -1 && itStart !== -1 && itEnd !== -1) {
+ if (this._current < itStart || this._current > itEnd) {
+ this.unselect(childs[this._current]);
+ }
+ }
if (this._selection.start !== -1 && itStart !== -1 && itStart > this._selection.start) {
for (iterator = this._selection.start; iterator < itStart; iterator++) {
this.unselect(childs[iterator]);
@@ -85,8 +98,14 @@ L.Control.Header = L.Control.extend({
x0 = (iterator > 0 ? childs[iterator - 1].size : 0);
x1 = childs[iterator].size;
if (x0 <= start && start <= x1) {
- this.unselect(childs[this._current]);
- this.select(childs[iterator]);
+ // when a whole row (column) is selected the cell cursor is moved to the first column (row)
+ // but this action should not cause to select/unselect anything, on the contrary we end up
+ // with all column (row) header entries selected but the one where the cell cursor was
+ // previously placed
+ if (this._selection.start === -1 && this._selection.end === -1) {
+ this.unselect(childs[this._current]);
+ this.select(childs[iterator]);
+ }
this._current = iterator;
break;
}
More information about the Libreoffice-commits
mailing list