loleaflet/src/control/Control.ColumnHeader.js |   30 ++++++++++++++++++++------
 loleaflet/src/control/Control.Header.js       |   12 +++-------
 loleaflet/src/control/Control.RowHeader.js    |   30 ++++++++++++++++++++------
 3 files changed, 52 insertions(+), 20 deletions(-)

New commits:
commit 5c75f31305319070b059cccd1a4d65a6ba1fba2b
Author: Henry Castro <hcas...@collabora.com>
Date:   Tue Aug 9 15:13:51 2016 -0400

    loleaflet: add Vertical/Horizontal line when dragging Column/Row

diff --git a/loleaflet/src/control/Control.ColumnHeader.js 
b/loleaflet/src/control/Control.ColumnHeader.js
index cd0460f..525d881 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -170,15 +170,33 @@ L.Control.ColumnHeader = L.Control.Header.extend({
                this._map.sendUnoCommand('.uno:SelectAll');
        },
 
-       onDragStart: function (item, start, end) {
-               // add vertical line
+       _getVertLatLng: function (e) {
+               var drag = this._map.mouseEventToContainerPoint(e);
+               return [
+                       this._map.containerPointToLatLng(new L.Point(drag.x, 
0)),
+                       this._map.containerPointToLatLng(new L.Point(drag.x, 
this._map.getSize().y))
+               ];
        },
 
-       onDragMove: function (item, start, end) {
-               // move vertical line
+       onDragStart: function (item, start, e) {
+               if (!this._vertLine) {
+                       this._vertLine = L.polyline(this._getVertLatLng(e), 
{color: 'darkblue', weight: 1});
+               }
+               else {
+                       this._vertLine.setLatLngs(this._getVertLatLng(e));
+               }
+
+               this._map.addLayer(this._vertLine);
+       },
+
+       onDragMove: function (item, start, e) {
+               if (this._vertLine) {
+                       this._vertLine.setLatLngs(this._getVertLatLng(e));
+               }
        },
 
-       onDragEnd: function (item, start, end) {
+       onDragEnd: function (item, start, e) {
+               var end = new L.Point(e.clientX, e.clientY);
                var distance = 
this._map._docLayer._pixelsToTwips(end.subtract(start));
 
                if (distance.x > 0 && item.width != distance.x) {
@@ -196,7 +214,7 @@ L.Control.ColumnHeader = L.Control.Header.extend({
                        this._map.sendUnoCommand('.uno:ColumnWidth', command);
                }
 
-               // remove vertical line
+               this._map.removeLayer(this._vertLine);
        },
 
        _onUpdatePermission: function (e) {
diff --git a/loleaflet/src/control/Control.Header.js 
b/loleaflet/src/control/Control.Header.js
index 58856f5..753fc52 100644
--- a/loleaflet/src/control/Control.Header.js
+++ b/loleaflet/src/control/Control.Header.js
@@ -28,13 +28,11 @@ L.Control.Header = L.Control.extend({
                var rectangle = target.parentNode.getBoundingClientRect();
                this._item = target;
                this._start = new L.Point(rectangle.left, rectangle.top);
-               this._end = new L.Point(e.clientX, e.clientY);
 
-               this.onDragStart(this.item, this._start, this._end);
+               this.onDragStart(this.item, this._start, e);
        },
 
        _onMouseMove: function (e) {
-               this._end = new L.Point(e.clientX, e.clientY);
                this._dragging = true;
 
                var target = e.target || e.srcElement;
@@ -48,12 +46,10 @@ L.Control.Header = L.Control.extend({
 
                L.DomEvent.preventDefault(e);
 
-               this.onDragMove(this._item, this._start, this._end);
+               this.onDragMove(this._item, this._start, e);
        },
 
        _onMouseUp: function (e) {
-               this._end = new L.Point(e.clientX, e.clientY);
-
                if (this._target) {
                        this._target.style.cursor = this._oldCursor;
                }
@@ -64,8 +60,8 @@ L.Control.Header = L.Control.extend({
                L.DomUtil.enableImageDrag();
                L.DomUtil.enableTextSelection();
 
-               this.onDragEnd(this._item, this._start, this._end);
-               this._target = this._cursor = this._item = this._start = 
this._end = null;
+               this.onDragEnd(this._item, this._start, e);
+               this._target = this._cursor = this._item = this._start = null;
                this._dragging = false;
        },
 
diff --git a/loleaflet/src/control/Control.RowHeader.js 
b/loleaflet/src/control/Control.RowHeader.js
index cef7482..2e9d4a4 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -151,15 +151,33 @@ L.Control.RowHeader = L.Control.Header.extend({
                this._selectRow(row, modifier);
        },
 
-       onDragStart: function (item, start, end) {
-               // add horizontal line
+       _getHorzLatLng: function (e) {
+               var drag = this._map.mouseEventToContainerPoint(e);
+               return [
+                       this._map.containerPointToLatLng(new L.Point(0, 
drag.y)),
+                       this._map.containerPointToLatLng(new 
L.Point(this._map.getSize().x, drag.y))
+               ];
        },
 
-       onDragMove: function (item, start, end) {
-               // move horizontal line
+       onDragStart: function (item, start, e) {
+               if (!this._horzLine) {
+                       this._horzLine = L.polyline(this._getHorzLatLng(e), 
{color: 'darkblue', weight: 1});
+               }
+               else {
+                       this._horzLine.setLatLngs(this._getHorzLatLng(e));
+               }
+
+               this._map.addLayer(this._horzLine);
+       },
+
+       onDragMove: function (item, start, e) {
+               if (this._horzLine) {
+                       this._horzLine.setLatLngs(this._getHorzLatLng(e));
+               }
        },
 
-       onDragEnd: function (item, start, end) {
+       onDragEnd: function (item, start, e) {
+               var end = new L.Point(e.clientX, e.clientY);
                var distance = 
this._map._docLayer._pixelsToTwips(end.subtract(start));
 
                if (distance.y > 0 && item.height != distance.y) {
@@ -177,7 +195,7 @@ L.Control.RowHeader = L.Control.Header.extend({
                        this._map.sendUnoCommand('.uno:RowHeight', command);
                }
 
-               // remove horizontal line
+               this._map.removeLayer(this._horzLine);
        },
 
        _onUpdatePermission: function (e) {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to