[Libreoffice-commits] online.git: loleaflet/dist loleaflet/plugins loleaflet/src
Henry Castro
hcastro at collabora.com
Wed Jun 17 18:03:21 PDT 2015
loleaflet/dist/leaflet.css | 2
loleaflet/plugins/draw-0.2.4/src/edit/handler/Edit.Rectangle.js | 22 +++++-
loleaflet/plugins/draw-0.2.4/src/edit/handler/Edit.SimpleShape.js | 8 +-
loleaflet/src/layer/marker/Marker.js | 2
loleaflet/src/layer/tile/TileLayer.js | 32 +++++++++-
5 files changed, 53 insertions(+), 13 deletions(-)
New commits:
commit f9b012ae45ed8ac27033a54ff3080d435b5b5d5d
Author: Henry Castro <hcastro at collabora.com>
Date: Wed Jun 17 20:59:33 2015 -0400
loleaflet: grow / shrink the graphic selection.
diff --git a/loleaflet/dist/leaflet.css b/loleaflet/dist/leaflet.css
index 346d9e5..a6a6007 100644
--- a/loleaflet/dist/leaflet.css
+++ b/loleaflet/dist/leaflet.css
@@ -178,11 +178,9 @@
.leaflet-interactive {
cursor: pointer;
- pointer-events: none;
}
.leaflet-container {
cursor: text;
- cursor: text;
}
.leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive {
diff --git a/loleaflet/plugins/draw-0.2.4/src/edit/handler/Edit.Rectangle.js b/loleaflet/plugins/draw-0.2.4/src/edit/handler/Edit.Rectangle.js
index e65e5a4..4ce5a2e 100644
--- a/loleaflet/plugins/draw-0.2.4/src/edit/handler/Edit.Rectangle.js
+++ b/loleaflet/plugins/draw-0.2.4/src/edit/handler/Edit.Rectangle.js
@@ -6,6 +6,7 @@ L.Edit.Rectangle = L.Edit.SimpleShape.extend({
center = bounds.getCenter();
this._moveMarker = this._createMarker(center, this.options.moveIcon);
+ this._moveMarker.setOpacity(0);
},
_createResizeMarker: function () {
@@ -26,9 +27,12 @@ L.Edit.Rectangle = L.Edit.SimpleShape.extend({
// Save a reference to the opposite point
var corners = this._getCorners(),
marker = e.target,
- currentCornerIndex = marker._cornerIndex;
+ currentCornerIndex = marker._cornerIndex,
+ oppositeCornerIndex = (currentCornerIndex + 4) % 8;
- this._oppositeCorner = corners[(currentCornerIndex + 2) % 4];
+ this._oppositeCorner = corners[ oppositeCornerIndex % 2 ? (oppositeCornerIndex + 1) % 8 : oppositeCornerIndex ];
+ this._currentCorner = corners[ currentCornerIndex % 2 ? (currentCornerIndex + 1) % 8 : currentCornerIndex ];
+ this._currentIndex = currentCornerIndex;
this._toggleCornerMarkers(0, currentCornerIndex);
},
@@ -73,6 +77,11 @@ L.Edit.Rectangle = L.Edit.SimpleShape.extend({
_resize: function (latlng) {
var bounds;
+ if (this._currentIndex == 1 || this._currentIndex == 5 )
+ latlng.lng = this._currentCorner.lng;
+ else if (this._currentIndex == 3 || this._currentIndex == 7)
+ latlng.lat = this._currentCorner.lat;
+
// Update the shape based on the current position of this corner and the opposite point
this._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));
@@ -86,9 +95,14 @@ L.Edit.Rectangle = L.Edit.SimpleShape.extend({
nw = bounds.getNorthWest(),
ne = bounds.getNorthEast(),
se = bounds.getSouthEast(),
- sw = bounds.getSouthWest();
+ sw = bounds.getSouthWest(),
+ center = bounds.getCenter(),
+ north = L.latLng(nw.lat, center.lng),
+ south = L.latLng(sw.lat, center.lng),
+ west = L.latLng(center.lat, nw.lng),
+ east = L.latLng(center.lat, ne.lng);
- return [nw, ne, se, sw];
+ return [nw, north, ne, east, se, south, sw, west];
},
_toggleCornerMarkers: function (opacity) {
diff --git a/loleaflet/plugins/draw-0.2.4/src/edit/handler/Edit.SimpleShape.js b/loleaflet/plugins/draw-0.2.4/src/edit/handler/Edit.SimpleShape.js
index f00ce31..7b44351 100644
--- a/loleaflet/plugins/draw-0.2.4/src/edit/handler/Edit.SimpleShape.js
+++ b/loleaflet/plugins/draw-0.2.4/src/edit/handler/Edit.SimpleShape.js
@@ -109,12 +109,12 @@ L.Edit.SimpleShape = L.Handler.extend({
var marker = e.target;
marker.setOpacity(0);
- this._shape.fire('editstart');
+ this._shape.fire('editstart', { handle: e.target });
},
- _fireEdit: function () {
+ _fireEdit: function (e) {
this._shape.edited = true;
- this._shape.fire('edit');
+ this._shape.fire('editend', { handle: e.target });
},
_onMarkerDrag: function (e) {
@@ -134,7 +134,7 @@ L.Edit.SimpleShape = L.Handler.extend({
var marker = e.target;
marker.setOpacity(1);
- this._fireEdit();
+ this._fireEdit(e);
},
_move: function () {
diff --git a/loleaflet/src/layer/marker/Marker.js b/loleaflet/src/layer/marker/Marker.js
index 4f242d8..1d29485 100644
--- a/loleaflet/src/layer/marker/Marker.js
+++ b/loleaflet/src/layer/marker/Marker.js
@@ -11,7 +11,7 @@ L.Marker = L.Layer.extend({
// title: '',
// alt: '',
interactive: true,
- // draggable: false,
+ draggable: false,
keyboard: true,
zIndexOffset: 0,
opacity: 1,
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index c8957d5..a84ee45 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -181,6 +181,7 @@ L.TileLayer = L.GridLayer.extend({
this._twipsToLatLng(topLeftTwips, this._map.getZoom()),
this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
}
+
this._onUpdateGraphicSelection();
}
else if (textMsg.startsWith('invalidatetiles:')) {
@@ -530,6 +531,11 @@ L.TileLayer = L.GridLayer.extend({
' char=' + charcode + ' key=' + keycode);
},
+ _postSelectGraphicEvent: function(type, x, y) {
+ this._map.socket.send('selectgraphic type=' + type +
+ ' x=' + x + ' y=' + y);
+ },
+
_onMouseEvent: function (e) {
if (e.type === 'mousedown') {
this._selecting = true;
@@ -783,14 +789,36 @@ L.TileLayer = L.GridLayer.extend({
}
},
+ // Update graphics resize.
+ _onGraphicEdit: function (e) {
+ if ( !e.handle ) return;
+
+ var aPos = this._latLngToTwips(e.handle.getLatLng());
+ if ( e.type === 'editstart' ) {
+ this._postSelectGraphicEvent('start', aPos.x, aPos.y);
+ }
+ else if ( e.type === 'editend' ) {
+ this._postSelectGraphicEvent('end', aPos.x, aPos.y);
+ }
+ },
+
+ // Update group layer selection handler.
_onUpdateGraphicSelection: function () {
if (!this._isEmptyRectangle(this._aGraphicSelection)) {
- this._graphicMarker = L.rectangle(this._aGraphicSelection, {color: 'red', fill: false});
+ if (this._graphicMarker) {
+ this._graphicMarker.off('editstart editend', this._onGraphicEdit, this);
+ this._map.removeLayer(this._graphicMarker);
+ }
+ this._graphicMarker = L.rectangle(this._aGraphicSelection, {fill: false});
+ this._graphicMarker.editing.enable();
+ this._graphicMarker.on('editstart editend', this._onGraphicEdit, this);
this._map.addLayer(this._graphicMarker);
}
else {
- if (this._graphicMarker)
+ if (this._graphicMarker) {
+ this._graphicMarker.off('editstart editend', this._onGraphicEdit, this);
this._map.removeLayer(this._graphicMarker);
+ }
}
}
});
More information about the Libreoffice-commits
mailing list