浏览代码

wxGUI/mapdisp: Overlay properties in context menu (#1077)

Properties of legends and other overlays are now also available from the context
menu on right click (not just double click). So, you don't need to know about the
double click to edit them.

Tooltip is simplified, more general, and does not advertise the double click anymore
resulting in shorter, easier to read text.

Raster legend resize is renamed to resize and move because that's what it is.
Vaclav Petras 4 年之前
父节点
当前提交
6165efe0d2
共有 2 个文件被更改,包括 21 次插入4 次删除
  1. 9 3
      gui/wxpython/mapwin/buffered.py
  2. 12 1
      gui/wxpython/mapwin/decorations.py

+ 9 - 3
gui/wxpython/mapwin/buffered.py

@@ -284,12 +284,19 @@ class BufferedMapWindow(MapWindowBase, Window):
                       id=removeId)
             menu.Append(removeId, self.overlays[idlist[0]].removeLabel)
 
+            # raster legend can be resized
             if self.overlays[idlist[0]].name == 'legend':
                 resizeLegendId = NewId()
                 self.Bind(wx.EVT_MENU,
                           lambda evt: self.overlays[idlist[0]].StartResizing(),
                           id=resizeLegendId)
-                menu.Append(resizeLegendId, _("Resize legend"))
+                menu.Append(resizeLegendId, _("Resize and move legend"))
+
+            activateId = NewId()
+            self.Bind(wx.EVT_MENU,
+                      lambda evt: self.overlayActivated.emit(overlayId=idlist[0]),
+                      id=activateId)
+            menu.Append(removeId, self.overlays[idlist[0]].activateLabel)
         self.PopupMenu(menu)
         menu.Destroy()
 
@@ -1688,8 +1695,7 @@ class BufferedMapWindow(MapWindowBase, Window):
         pos = event.GetPosition()
         idlist = self.pdc.FindObjects(pos[0], pos[1], self.hitradius)
         if self.overlays and idlist and [i for i in idlist if i in list(self.overlays.keys())]:  # legend, scale bar, north arrow, dtext
-            self.SetToolTip("Double click in Pointer mode to set object"
-                            " properties,\nright click to remove")
+            self.SetToolTip("Right click to modify or remove")
         else:
             self.SetToolTip(None)
         event.Skip()

+ 12 - 1
gui/wxpython/mapwin/decorations.py

@@ -46,6 +46,7 @@ class OverlayController(object):
         self._cmd = None   # to be set by user
         self._name = None  # to be defined by subclass
         self._removeLabel = None  # to be defined by subclass
+        self._activateLabel = None  # to be defined by subclass
         self._id = NewId()
         self._dialog = None
 
@@ -96,6 +97,11 @@ class OverlayController(object):
 
     removeLabel = property(fget=GetRemoveLabel)
 
+    def GetActivateLabel(self):
+        return self._activateLabel
+
+    activateLabel = property(fget=GetActivateLabel)
+
     def GetId(self):
         return self._id
 
@@ -195,6 +201,7 @@ class DtextController(OverlayController):
         OverlayController.__init__(self, renderer, giface)
         self._name = 'text'
         self._removeLabel = _("Remove text")
+        self._activateLabel = _("Text properties")
         self._defaultAt = 'at=50,50'
         self._cmd = ['d.text', self._defaultAt]
 
@@ -218,6 +225,7 @@ class BarscaleController(OverlayController):
         OverlayController.__init__(self, renderer, giface)
         self._name = 'barscale'
         self._removeLabel = _("Remove scale bar")
+        self._activateLabel = _("Scale bar properties")
         # different from default because the reference point is not in the
         # middle
         self._defaultAt = 'at=0,98'
@@ -230,6 +238,7 @@ class ArrowController(OverlayController):
         OverlayController.__init__(self, renderer, giface)
         self._name = 'arrow'
         self._removeLabel = _("Remove north arrow")
+        self._activateLabel = _("North arrow properties")
         # different from default because the reference point is not in the
         # middle
         self._defaultAt = 'at=85.0,25.0'
@@ -241,7 +250,8 @@ class LegendVectController(OverlayController):
     def __init__(self, renderer, giface):
         OverlayController.__init__(self, renderer, giface)
         self._name = 'vectleg'
-        self._removeLabel = _("Remove vector legend")
+        self._removeLabel = _("Remove legend")
+        self._activateLabel = _("Vector legend properties")
         # different from default because the reference point is not in the
         # middle
         self._defaultAt = 'at=20.0,80.0'
@@ -254,6 +264,7 @@ class LegendController(OverlayController):
         OverlayController.__init__(self, renderer, giface)
         self._name = 'legend'
         self._removeLabel = _("Remove legend")
+        self._activateLabel = _("Raster legend properties")
         # default is in the center to avoid trimmed legend on the edge
         self._defaultAt = 'at=5,50,47,50'
         self._cmd = ['d.legend', self._defaultAt]