loleaflet/css/loleaflet.css | 11 ++++++++++ loleaflet/src/layer/marker/Annotation.js | 32 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
New commits: commit 552462cecd225b5d12f40fea410686a2f3a40ba0 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Jun 26 09:04:35 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sun Jun 28 08:51:15 2020 +0200 Add support to show annotation marker for draw/impress Change-Id: Ibaeaed97de5b5a87f4a46c4da593a3ee861e2399 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97335 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/loleaflet/css/loleaflet.css b/loleaflet/css/loleaflet.css index 41e9459fc..dccd4b4b5 100644 --- a/loleaflet/css/loleaflet.css +++ b/loleaflet/css/loleaflet.css @@ -236,6 +236,17 @@ body { margin-right: 10px; } +.annotation-marker { + margin-left: 0px; + margin-top: 0px; + width: 24px; + height: 24px; + background-image: url('images/note.svg'); + background-size: 100% 100%; + background-repeat: no-repeat; + outline: none; +} + .loleaflet-scrolled { overflow: auto; } diff --git a/loleaflet/src/layer/marker/Annotation.js b/loleaflet/src/layer/marker/Annotation.js index 6224007f8..730396ab9 100644 --- a/loleaflet/src/layer/marker/Annotation.js +++ b/loleaflet/src/layer/marker/Annotation.js @@ -19,6 +19,7 @@ L.Annotation = L.Layer.extend({ this._latlng = L.latLng(latlng); this._data = data; this._skipCheckBounds = false; + this._annotationMarker = null; }, onAdd: function (map) { @@ -51,6 +52,7 @@ L.Annotation = L.Layer.extend({ this._updateContent(); this._updateLayout(); this._updatePosition(); + this._updateAnnotationMarker(); }, setData: function (data) { @@ -89,6 +91,9 @@ L.Annotation = L.Layer.extend({ if (this._data.textSelected && this._map.hasLayer && !this._map.hasLayer(this._data.textSelected)) { this._map.addLayer(this._data.textSelected); } + if (this._annotationMarker != null) { + this._map.addLayer(this._annotationMarker); + } }, hide: function () { @@ -99,6 +104,9 @@ L.Annotation = L.Layer.extend({ if (this._data.textSelected && this._map.hasLayer(this._data.textSelected)) { this._map.removeLayer(this._data.textSelected); } + if (this._annotationMarker != null) { + this._map.removeLayer(this._annotationMarker); + } }, isVisible: function () { @@ -441,6 +449,30 @@ L.Annotation = L.Layer.extend({ var authorImageHeight = Math.round(this.options.imgSize.y * scaleFactor); this._authorAvatarImg.setAttribute('width', authorImageWidth); this._authorAvatarImg.setAttribute('height', authorImageHeight); + }, + + _updateAnnotationMarker: function () { + if (this._data == null) + return; + + if (this._annotationMarker == null) { + this._annotationMarker = L.marker(new L.LatLng(0, 0), { + icon: L.divIcon({ + className: 'annotation-marker', + iconSize: null + }), + draggable: true + }); + this._map.addLayer(this._annotationMarker); + } + var stringTwips = this._data.rectangle.match(/\d+/g); + var topLeftTwips = new L.Point(parseInt(stringTwips[0]), parseInt(stringTwips[1])); + var offset = new L.Point(parseInt(stringTwips[2]), parseInt(stringTwips[3])); + var bottomRightTwips = topLeftTwips.add(offset); + var bounds = new L.LatLngBounds( + this._map._docLayer._twipsToLatLng(topLeftTwips, this._map.getZoom()), + this._map._docLayer._twipsToLatLng(bottomRightTwips, this._map.getZoom())); + this._annotationMarker.setLatLng(bounds.getSouthWest()); } }); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits