[Libreoffice-commits] online.git: loleaflet/css loleaflet/src

Marco Cecchetti (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 6 13:48:22 UTC 2020


 loleaflet/css/leaflet.css                  |   13 ++++++++
 loleaflet/src/control/Control.LokDialog.js |   42 +++++++++++++++++++++++++++++
 loleaflet/src/layer/tile/GridLayer.js      |   10 ++++--
 loleaflet/src/layer/tile/TileLayer.js      |    7 ++++
 4 files changed, 68 insertions(+), 4 deletions(-)

New commits:
commit ec2ec241d2ef48e6846f87318e6f176348b2d238
Author:     Marco Cecchetti <marco.cecchetti at collabora.com>
AuthorDate: Tue Jan 14 16:02:09 2020 +0100
Commit:     Marco Cecchetti <marco.cecchetti at collabora.com>
CommitDate: Thu Feb 6 14:48:00 2020 +0100

    loleaflet: calc: input bar text selection layer
    
    Change-Id: Id143c3c0b5f0bb6a99bd9e8ce7f953f95e3a65bd
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86791
    Reviewed-by: Marco Cecchetti <marco.cecchetti at collabora.com>
    Tested-by: Marco Cecchetti <marco.cecchetti at collabora.com>

diff --git a/loleaflet/css/leaflet.css b/loleaflet/css/leaflet.css
index 24592c7b7..04ea07362 100644
--- a/loleaflet/css/leaflet.css
+++ b/loleaflet/css/leaflet.css
@@ -608,6 +608,7 @@ a.leaflet-control-buttons:hover:first-child {
 .leaflet-cursor-container {
 	position: absolute;
 	text-align: center;
+	pointer-events: none;
 	}
 
 .leaflet-cursor {
@@ -682,6 +683,18 @@ div.leaflet-cursor-container:hover > .leaflet-cursor-header {
 	}
 }
 
+.leaflet-text-selection-container {
+	position: absolute;
+	text-align: center;
+	pointer-events: none;
+}
+
+.leaflet-text-selection {
+	background: #43ACE8B5;
+	pointer-events: none;
+	display: block;
+}
+
 .clipboard-container {
 	position: absolute;
 	left: 0px;
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 6afb2d064..a16395258 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -339,6 +339,24 @@ L.Control.LokDialog = L.Control.extend({
 
 				this._updateDialogCursor(e.id, x, y, height);
 			}
+		} else if (e.action === 'text_selection') {
+			if (this._isOpen(e.id)) {
+				var rectangles = [];
+				if (e.rectangles) {
+					var dataList = e.rectangles.match(/\d+/g);
+					if (dataList != null) {
+						for (var i = 0; i < dataList.length; i += 4) {
+							var rect = {};
+							rect.x = parseInt(dataList[i]);
+							rect.y = parseInt(dataList[i + 1]);
+							rect.width = parseInt(dataList[i + 2]);
+							rect.height = parseInt(dataList[i + 3]);
+							rectangles.push(rect);
+						}
+					}
+				}
+				this._updateTextSelection(e.id, rectangles);
+			}
 		} else if (e.action === 'title_changed') {
 			if (e.title && this._dialogs[parseInt(e.id)]) {
 				this._dialogs[parseInt(e.id)].title = e.title;
@@ -390,6 +408,24 @@ L.Control.LokDialog = L.Control.extend({
 		L.DomUtil.addClass(cursor, 'blinking-cursor');
 	},
 
+	_updateTextSelection: function(dlgId, rectangles) {
+		var strId = this._toIntId(dlgId);
+		var selections = this._dialogs[strId].textSelection.rectangles;
+		L.DomUtil.empty(selections);
+		if (!rectangles)
+			return;
+
+		for (var i = 0; i < rectangles.length; ++i) {
+			var container = L.DomUtil.create('div', 'leaflet-text-selection-container', selections);
+			var selection = L.DomUtil.create('div', 'leaflet-text-selection', container);
+			var rect = rectangles[i];
+			L.DomUtil.setStyle(selection, 'width', rect.width + 'px');
+			L.DomUtil.setStyle(selection, 'height', rect.height + 'px');
+			L.DomUtil.setStyle(container, 'left',  rect.x + 'px');
+			L.DomUtil.setStyle(container, 'top', rect.y + 'px');
+		}
+	},
+
 	focus: function(dlgId, acceptInput) {
 		// In case of the sidebar we should be careful about
 		// grabbing the focus from the main window.
@@ -568,12 +604,17 @@ L.Control.LokDialog = L.Control.extend({
 		L.DomUtil.setStyle(container, 'width', '100%');
 		L.DomUtil.setStyle(container, 'height', height + 'px');
 
+		//var eventLayer = L.DomUtil.create('div', '', container);
 		// Create the canvas.
 		var canvas = L.DomUtil.create('canvas', 'inputbar_canvas', container);
 		L.DomUtil.setStyle(canvas, 'position', 'absolute');
 		this._setCanvasWidthHeight(canvas, width, height);
 		canvas.id = strId + '-canvas';
 
+		// create the text selections layer
+		var textSelectionLayer = L.DomUtil.create('div', 'inputbar_selection_layer', container);
+		var selections =  L.DomUtil.create('div', 'inputbar_selections', textSelectionLayer);
+
 		// Don't show the inputbar until we get the contents.
 		$(container).parent().hide();
 
@@ -588,6 +629,7 @@ L.Control.LokDialog = L.Control.extend({
 			width: width,
 			height: height,
 			cursor: null,
+			textSelection: {rectangles: selections},
 			child: null, // never used for inputbar
 			title: null  // never used for inputbar
 		};
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 4ff2d4877..a69741462 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -716,10 +716,12 @@ L.GridLayer = L.Layer.extend({
 			this._map.fire('updatescrolloffset', {x: 0, y: 0, updateHeaders: false});
 			this._map.scrollTop(0);
 			this._map.scrollLeft(0);
-			this._cellCursor = L.LatLngBounds.createDefault();
-			this._prevCellCursor = new L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(1, 1));
-			this._cellCursorXY = new L.Point(-1, -1);
-			this._prevCellCursorXY = new L.Point(0, 0);
+
+			// 2020-01-14 if no side effect occurs remove this code later
+			// this._cellCursor = L.LatLngBounds.createDefault();
+			// this._prevCellCursor = new L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(1, 1));
+			// this._cellCursorXY = new L.Point(-1, -1);
+			// this._prevCellCursorXY = new L.Point(0, 0);
 		}
 	},
 
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 0b4926a43..d3c012bcd 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1958,6 +1958,9 @@ L.TileLayer = L.GridLayer.extend({
 		this._graphicSelection = new L.LatLngBounds(new L.LatLng(0, 0), new L.LatLng(0, 0));
 		this._onUpdateGraphicSelection();
 		this._cellCursor = null;
+		this._cellCursorXY = null;
+		this._prevCellCursor = null;
+		this._prevCellCursorXY = null;
 		this._onUpdateCellCursor();
 		if (this._map._clip)
 			this._map._clip.clearSelection();
@@ -2776,6 +2779,10 @@ L.TileLayer = L.GridLayer.extend({
 	_onUpdateCellCursor: function (horizontalDirection, verticalDirection, onPgUpDn) {
 		this._onUpdateCellResizeMarkers();
 		if (this._cellCursor && !this._isEmptyRectangle(this._cellCursor)) {
+			if (this._map.dialog._calcInputBar && !this._cellCursorXY.equals(this._prevCellCursorXY)) {
+				var inputBarId = this._map.dialog._calcInputBar.id;
+				this._map.dialog._updateTextSelection(inputBarId);
+			}
 			var mapBounds = this._map.getBounds();
 			if (!mapBounds.contains(this._cellCursor) && !this._cellCursorXY.equals(this._prevCellCursorXY)) {
 				var scrollX = 0, scrollY = 0;


More information about the Libreoffice-commits mailing list