[Libreoffice-commits] online.git: loleaflet/src
Dennis Francis (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 10 14:57:31 UTC 2020
loleaflet/src/control/Control.ColumnHeader.js | 13 ++++---------
loleaflet/src/control/Control.RowHeader.js | 13 ++++---------
loleaflet/src/layer/vector/Polyline.js | 14 +++++++++++---
loleaflet/src/layer/vector/SplitPanesSVG.js | 4 +++-
4 files changed, 22 insertions(+), 22 deletions(-)
New commits:
commit 6981b71a89fb2adb6d464b9c17023df75e49ec9f
Author: Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Thu Jul 9 23:13:35 2020 +0530
Commit: Dennis Francis <dennis.francis at collabora.com>
CommitDate: Fri Jul 10 16:57:11 2020 +0200
split-panes: use document coordinates for paths in "fixed" svg container
and let the grid-resize lines be rendered in this fixed svg container
which makes their position-calculations a lot simpler.
Change-Id: I4b5834c6b00b1ee93b5a633b5cbba4b852608fd7
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98497
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Dennis Francis <dennis.francis at collabora.com>
diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index 8a07f1e86..ea806593c 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -563,21 +563,16 @@ L.Control.ColumnHeader = L.Control.Header.extend({
var size = this._map.getSize();
var drag = this._map.mouseEventToContainerPoint(e);
var entryStart = this._dragEntry.pos - this._dragEntry.size;
- var xdocpos = this._headerInfo.headerToDocPos(Math.max(drag.x, entryStart));
- var ymin = this._map.getPixelBounds().min.y;
- var ymax = ymin + size.y;
- if (this._headerInfo.hasSplits()) {
- ymin = 0;
- }
+ var xpos = Math.max(drag.x, entryStart);
return [
- this._map.unproject(new L.Point(xdocpos, ymin)),
- this._map.unproject(new L.Point(xdocpos, ymax)),
+ this._map.unproject(new L.Point(xpos, 0)),
+ this._map.unproject(new L.Point(xpos, size.y)),
];
},
onDragStart: function (item, start, offset, e) {
if (!this._vertLine) {
- this._vertLine = L.polyline(this._getVertLatLng(start, offset, e), {color: 'darkblue', weight: 1});
+ this._vertLine = L.polyline(this._getVertLatLng(start, offset, e), {color: 'darkblue', weight: 1, fixed: true});
}
else {
this._vertLine.setLatLngs(this._getVertLatLng(start, offset, e));
diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js
index 2e55fc4b7..14f568187 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -519,21 +519,16 @@ L.Control.RowHeader = L.Control.Header.extend({
var size = this._map.getSize();
var drag = this._map.mouseEventToContainerPoint(e);
var entryStart = this._dragEntry.pos - this._dragEntry.size;
- var ydocpos = this._headerInfo.headerToDocPos(Math.max(drag.y, entryStart));
- var xmin = this._map.getPixelBounds().min.x;
- var xmax = xmin + size.x;
- if (this._headerInfo.hasSplits()) {
- xmin = 0;
- }
+ var ypos = Math.max(drag.y, entryStart);
return [
- this._map.unproject(new L.Point(xmin, ydocpos)),
- this._map.unproject(new L.Point(xmax, ydocpos)),
+ this._map.unproject(new L.Point(0, ypos)),
+ this._map.unproject(new L.Point(size.x, ypos)),
];
},
onDragStart: function (item, start, offset, e) {
if (!this._horzLine) {
- this._horzLine = L.polyline(this._getHorzLatLng(start, offset, e), {color: 'darkblue', weight: 1});
+ this._horzLine = L.polyline(this._getHorzLatLng(start, offset, e), {color: 'darkblue', weight: 1, fixed: true});
}
else {
this._horzLine.setLatLngs(this._getHorzLatLng(start, offset, e));
diff --git a/loleaflet/src/layer/vector/Polyline.js b/loleaflet/src/layer/vector/Polyline.js
index 0cab5e463..69f636248 100644
--- a/loleaflet/src/layer/vector/Polyline.js
+++ b/loleaflet/src/layer/vector/Polyline.js
@@ -138,8 +138,8 @@ L.Polyline = L.Path.extend({
if (this._latlngs.length) {
this._pxBounds = new L.Bounds(
- this._map.latLngToLayerPoint(this._bounds.getSouthWest())._subtract(p),
- this._map.latLngToLayerPoint(this._bounds.getNorthEast())._add(p));
+ this._latLngToPoint(this._bounds.getSouthWest())._subtract(p),
+ this._latLngToPoint(this._bounds.getNorthEast())._add(p));
}
},
@@ -153,7 +153,7 @@ L.Polyline = L.Path.extend({
if (flat) {
ring = [];
for (i = 0; i < len; i++) {
- ring[i] = this._map.latLngToLayerPoint(latlngs[i]);
+ ring[i] = this._latLngToPoint(latlngs[i]);
}
result.push(ring);
} else {
@@ -163,6 +163,14 @@ L.Polyline = L.Path.extend({
}
},
+ _latLngToPoint: function (latlng) {
+ if (this.options.fixed) {
+ return this._map.project(latlng);
+ }
+
+ return this._map.latLngToLayerPoint(latlng);
+ },
+
// clip polyline by renderer bounds so that we have less to render for performance
_clipPoints: function () {
if (this.options.noClip || this._renderer instanceof L.SplitPanesSVG) {
diff --git a/loleaflet/src/layer/vector/SplitPanesSVG.js b/loleaflet/src/layer/vector/SplitPanesSVG.js
index 4ad5de6fd..d114c5cb2 100644
--- a/loleaflet/src/layer/vector/SplitPanesSVG.js
+++ b/loleaflet/src/layer/vector/SplitPanesSVG.js
@@ -92,7 +92,9 @@ L.SplitPanesSVG = L.SplitPanesRenderer.extend({
// is always glued to (0, 0) of the document.
// The size is always the map's view size.
pos = this._map.containerPointToLayerPointIgnoreSplits(topLeft).round();
- boundPos = topLeft.subtract(pixelOrigin);
+ // All paths in this should set their DOM node positions in document coordinates rather than in layer coordinates.
+ // This is taken care of if the paths are derived from L.Polyline
+ boundPos = topLeft;
}
else if (rendererId === 'bottomright') {
// this is the default splitPane where are no visible splits (splitPos = (0, 0)).
More information about the Libreoffice-commits
mailing list