loleaflet/src/map/handler/Map.TouchGesture.js |   36 +++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 4 deletions(-)

New commits:
commit c7b1159f36dea4ee3524a0ed71885388b721d520
Author:     Tor Lillqvist <t...@collabora.com>
AuthorDate: Tue Jul 23 16:44:41 2019 +0300
Commit:     Tor Lillqvist <t...@collabora.com>
CommitDate: Tue Aug 20 10:53:05 2019 +0200

    tdf#122572: Temporarily resurrect the context toolbar, for the iOS app only
    
    It will be superseded by the context menu, but that doesn't work even
    in normal Online in this branch currently. Once it works, I can then
    try to use the same styling for it in the iOS app as for the context
    toolbar, to make it look like the native iOS "edit menu".
    
    This reverts a3d9cf8999ac25bb2b2a5d6332d7ac6e2f7c7350, but for the iOS
    app only.
    
    Note that there are other problems related to copy and paste in this
    branch in the iOS app. The copy/paste changes for normal Online have
    caused regressions in the app.
    
    Reviewed-on: https://gerrit.libreoffice.org/76192
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tor Lillqvist <t...@collabora.com>
    Tested-by: Tor Lillqvist <t...@collabora.com>
    (cherry picked from commit 5448916f98c1480cfbc64f58e6d4f1cdb3fd133f)
    
    Change-Id: I5c13cd0a5ece9038aba774b229dd86ec9c6678fc
    Reviewed-on: https://gerrit.libreoffice.org/77781
    Reviewed-by: Tor Lillqvist <t...@collabora.com>
    Tested-by: Tor Lillqvist <t...@collabora.com>

diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js 
b/loleaflet/src/map/handler/Map.TouchGesture.js
index c5735c670..f51da0286 100644
--- a/loleaflet/src/map/handler/Map.TouchGesture.js
+++ b/loleaflet/src/map/handler/Map.TouchGesture.js
@@ -19,6 +19,10 @@ L.Map.TouchGesture = L.Handler.extend({
                L.Handler.prototype.initialize.call(this, map);
                this._state = L.Map.TouchGesture.MAP;
 
+               if (window.ThisIsTheiOSApp && !this._toolbar) {
+                       this._toolbar = L.control.contextToolbar();
+               }
+
                if (!this._hammer) {
                        this._hammer = new Hammer(this._map._mapPane);
                        this._hammer.get('swipe').set({
@@ -83,6 +87,8 @@ L.Map.TouchGesture = L.Handler.extend({
                this._hammer.on('pinchstart pinchmove', L.bind(this._onPinch, 
this));
                this._hammer.on('pinchend', L.bind(this._onPinchEnd, this));
                this._hammer.on('tripletap', L.bind(this._onTripleTap, this));
+               if (window.ThisIsTheiOSApp)
+                       this._map.on('input.press', this._onInputPressiOSOnly, 
this);
                this._map.on('updatepermission', this._onPermission, this);
                this._onPermission({perm: this._map._permission});
        },
@@ -150,10 +156,23 @@ L.Map.TouchGesture = L.Handler.extend({
                    latlng = this._map.layerPointToLatLng(layerPoint),
                    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
-               this._map._contextMenu._onMouseDown({originalEvent: 
e.srcEvent});
-               // send right click to trigger context menus
-               this._map._docLayer._postMouseEvent('buttondown', mousePos.x, 
mousePos.y, 1, 4, 0);
-               this._map._docLayer._postMouseEvent('buttonup', mousePos.x, 
mousePos.y, 1, 4, 0);
+               if (window.ThisIsTheiOSApp) {
+                       if (!this._toolbar._map && 
this._map._docLayer.containsSelection(latlng)) {
+                               this._toolbar._pos = containerPoint;
+                               this._toolbar.addTo(this._map);
+                       } else {
+                               this._toolbar.remove();
+                               
this._map._contextMenu._onMouseDown({originalEvent: e.srcEvent});
+                               // send right click to trigger context menus
+                               
this._map._docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1, 4, 
0);
+                               this._map._docLayer._postMouseEvent('buttonup', 
mousePos.x, mousePos.y, 1, 4, 0);
+                       }
+               } else {
+                       this._map._contextMenu._onMouseDown({originalEvent: 
e.srcEvent});
+                       // send right click to trigger context menus
+                       this._map._docLayer._postMouseEvent('buttondown', 
mousePos.x, mousePos.y, 1, 4, 0);
+                       this._map._docLayer._postMouseEvent('buttonup', 
mousePos.x, mousePos.y, 1, 4, 0);
+               }
 
                e.preventDefault();
        },
@@ -165,6 +184,8 @@ L.Map.TouchGesture = L.Handler.extend({
                    latlng = this._map.layerPointToLatLng(layerPoint),
                    mousePos = this._map._docLayer._latLngToTwips(latlng);
 
+               if (window.ThisIsTheiOSApp)
+                       this._toolbar.remove();
                this._map._contextMenu._onMouseDown({originalEvent: 
e.srcEvent});
                this._map._docLayer._postMouseEvent('buttondown', mousePos.x, 
mousePos.y, 1, 1, 0);
                this._map._docLayer._postMouseEvent('buttonup', mousePos.x, 
mousePos.y, 1, 1, 0);
@@ -291,6 +312,13 @@ L.Map.TouchGesture = L.Handler.extend({
                }
        },
 
+       _onInputPressiOSOnly: function (e) {
+               var pos = this._map.latLngToContainerPoint(e);
+               this._toolbar.remove();
+               this._toolbar._pos = pos;
+               this._toolbar.addTo(this._map);
+       },
+
        _constructFakeEvent: function (evt, type) {
                var fakeEvt = {
                        type: type,
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to