[Libreoffice-commits] online.git: loleaflet/src
Henry Castro
hcastro at collabora.com
Tue Nov 1 01:38:19 UTC 2016
loleaflet/src/control/Control.ColumnHeader.js | 5 +++++
loleaflet/src/control/Control.Header.js | 22 ++++++++++++++++++++++
loleaflet/src/control/Control.RowHeader.js | 5 +++++
loleaflet/src/layer/tile/CalcTileLayer.js | 9 +++++++++
4 files changed, 41 insertions(+)
New commits:
commit 2c5cbe6555a1e195b55d21baf39bb7625c5c7366
Author: Henry Castro <hcastro at collabora.com>
Date: Mon Oct 31 21:37:27 2016 -0400
loleaflet: row/column highlighting to reflect the cell cursor
diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index e6e1351..4629de7 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -21,6 +21,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({
this._map.on('viewrowcolumnheaders', this.viewRowColumnHeaders, this);
this._map.on('updateselectionheader', this._onUpdateSelection, this);
this._map.on('clearselectionheader', this._onClearSelection, this);
+ this._map.on('updatecurrentheader', this._onUpdateCurrentColumn, this);
var docContainer = this._map.options.documentContainer;
var cornerHeader = L.DomUtil.create('div', 'spreadsheet-header-corner', docContainer.parentElement);
L.DomEvent.addListener(cornerHeader, 'click', this._onCornerHeaderClick, this);
@@ -154,6 +155,10 @@ L.Control.ColumnHeader = L.Control.Header.extend({
this.updateSelection(this._columns, e.start.x, e.end.x);
},
+ _onUpdateCurrentColumn: function (e) {
+ this.updateCurrent(this._columns, e.x);
+ },
+
viewRowColumnHeaders: function (e) {
this.fillColumns(e.data.columns, e.converter, e.context);
},
diff --git a/loleaflet/src/control/Control.Header.js b/loleaflet/src/control/Control.Header.js
index c56e554..7c33148 100644
--- a/loleaflet/src/control/Control.Header.js
+++ b/loleaflet/src/control/Control.Header.js
@@ -9,6 +9,7 @@ L.Control.Header = L.Control.extend({
initialize: function () {
this._clicks = 0;
+ this._current = -1;
this._selection = {start: -1, end: -1};
},
@@ -71,6 +72,27 @@ L.Control.Header = L.Control.extend({
this._selection.end = itEnd;
},
+ updateCurrent: function (element, start) {
+ var childs = element.children;
+ if (start < 0) {
+ this.unselect(childs[this._current]);
+ this._current = -1;
+ return;
+ }
+
+ var x0 = 0, x1 = 0;
+ for (var iterator = 0, len = childs.length; iterator < len; iterator++) {
+ 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]);
+ this._current = iterator;
+ break;
+ }
+ }
+ },
+
_onMouseDown: function (e) {
var target = e.target || e.srcElement;
diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js
index 8575a24..d14e45c 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -21,6 +21,7 @@ L.Control.RowHeader = L.Control.Header.extend({
this._map.on('viewrowcolumnheaders', this.viewRowColumnHeaders, this);
this._map.on('updateselectionheader', this._onUpdateSelection, this);
this._map.on('clearselectionheader', this._onClearSelection, this);
+ this._map.on('updatecurrentheader', this._onUpdateCurrentRow, this);
var docContainer = this._map.options.documentContainer;
var headersContainer = L.DomUtil.create('div', 'spreadsheet-header-rows-container', docContainer.parentElement);
this._rows = L.DomUtil.create('div', 'spreadsheet-header-rows', headersContainer);
@@ -150,6 +151,10 @@ L.Control.RowHeader = L.Control.Header.extend({
this.updateSelection(this._rows, e.start.y, e.end.y);
},
+ _onUpdateCurrentRow: function (e) {
+ this.updateCurrent(this._rows, e.y);
+ },
+
viewRowColumnHeaders: function (e) {
this.fillRows(e.data.rows, e.converter, e.context);
},
diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index 237fb92..b66a657 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -233,5 +233,14 @@ L.CalcTileLayer = L.TileLayer.extend({
_onTextSelectionMsg: function (textMsg) {
L.TileLayer.prototype._onTextSelectionMsg.call(this, textMsg);
this._onUpdateSelectionHeader();
+ },
+
+ _onCellCursorMsg: function (textMsg) {
+ var pos = new L.Point(-1, -1);
+ L.TileLayer.prototype._onCellCursorMsg.call(this, textMsg);
+ if (this._cellCursor && !this._isEmptyRectangle(this._cellCursor)) {
+ pos = this._cellCursorTwips.min.add([1, 1]);
+ }
+ this._map.fire('updatecurrentheader', pos);
}
});
More information about the Libreoffice-commits
mailing list