Skip to content

Commit

Permalink
wxGUI: Remove statusbar combobox and instead add statusbar settings t…
Browse files Browse the repository at this point in the history
…o Map Display Settings (#2153)

Creates several radiobuttons in Map Display settings that control which item will be shown in statusbar.
  • Loading branch information
lindakarlovska committed Mar 2, 2022
1 parent 4548327 commit 28a86c9
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 92 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/gcp/statusbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SbGoToGCP(SbItem):
def __init__(self, mapframe, statusbar, position=0):
SbItem.__init__(self, mapframe, statusbar, position)
self.name = "gotoGCP"
self.label = _("Go to GCP No.")
self.label = _("Pan to GCP by number")

self.widget = SpinCtrl(parent=self.statusbar, id=wx.ID_ANY, value="", min=0)
self.widget.Hide()
Expand Down
5 changes: 4 additions & 1 deletion gui/wxpython/gui_core/mapdisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,10 @@ def OnMapDisplayProperties(self, event):
from mapdisp.properties import MapDisplayPropertiesDialog

dlg = MapDisplayPropertiesDialog(
parent=self, mapframe=self, properties=self.mapWindowProperties
parent=self,
mapframe=self,
properties=self.mapWindowProperties,
sbmanager=self.statusbarManager,
)
dlg.CenterOnParent()
dlg.Show()
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/image2target/ii2t_statusbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SbGoToGCP(SbItem):
def __init__(self, mapframe, statusbar, position=0):
SbItem.__init__(self, mapframe, statusbar, position)
self.name = "gotoGCP"
self.label = _("Go to GCP No.")
self.label = _("Pan to GCP by number")

self.widget = SpinCtrl(parent=self.statusbar, id=wx.ID_ANY, value="", min=0)
self.widget.Hide()
Expand Down
12 changes: 6 additions & 6 deletions gui/wxpython/mapdisp/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(
sb.SbMapScale,
sb.SbGoTo,
]
self.statusbarItemsHiddenInNviz = (
self.statusbarItemsDisabledInNviz = (
sb.SbDisplayGeometry,
sb.SbMapScale,
)
Expand Down Expand Up @@ -448,8 +448,8 @@ def AddNviz(self):
)
# update status bar

self.statusbarManager.HideStatusbarChoiceItemsByClass(
self.statusbarItemsHiddenInNviz
self.statusbarManager.DisableStatusbarItemsByClass(
self.statusbarItemsDisabledInNviz
)
self.statusbarManager.SetMode(0)

Expand Down Expand Up @@ -548,13 +548,13 @@ def RemoveNviz(self):
pass

# update status bar
self.statusbarManager.ShowStatusbarChoiceItemsByClass(
self.statusbarItemsHiddenInNviz
)
self.statusbarManager.disabledItems = {}
self.statusbarManager.SetMode(
UserSettings.Get(group="display", key="statusbarMode", subkey="selection")
)
self.SetStatusText(_("Please wait, unloading data..."), 0)
self.statusbarManager.Update()

# unloading messages from library cause highlight anyway
self._giface.WriteCmdLog(
_("Switching back to 2D view mode..."),
Expand Down
63 changes: 60 additions & 3 deletions gui/wxpython/mapdisp/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- properties::ChBShowRegion
- properties::ChBAlignExtent
- properties::ChBResolution
- properties::ChBProjection
- properties::RBShowInStatusbar
- properties::MapDisplayPropertiesDialog
(C) 2021 by the GRASS Development Team
Expand Down Expand Up @@ -277,6 +279,50 @@ def _onToggleCheckBox(self, event):
self.widget.SetLabel(self.defaultLabel)


class RBShowInStatusbar:
"""Radiobox managing widgets in statusbar."""

def __init__(self, parent, sbmanager):
self.name = "showInStatusbar"
self.statusbarManager = sbmanager

choices = self.statusbarManager.GetItemLabels()
self.widget = wx.RadioBox(
parent=parent,
id=wx.ID_ANY,
label="Displayed content",
choices=choices,
majorDimension=1,
style=wx.RA_SPECIFY_COLS,
)
self._setValue(self.statusbarManager.GetMode())
self._disableItems()

self.widget.Bind(wx.EVT_RADIOBOX, self._onToggleRadioBox)

def _setValue(self, mode):
self.widget.SetSelection(mode)

def GetValue(self):
return self.widget.GetSelection()

def _disableItems(self):
"""Disables a radiobox options"""
for item in self.statusbarManager.disabledItems.keys():
self.widget.EnableItem(n=item, enable=False)

def GetWidget(self):
"""Returns underlying widget.
:return: widget or None if doesn't exist
"""
return self.widget

def _onToggleRadioBox(self, event):
self.statusbarManager.SetMode(self.GetValue())
self.statusbarManager.Update()


class MapDisplayPropertiesDialog(wx.Dialog):
"""Map Display properties dialog"""

Expand All @@ -285,8 +331,9 @@ def __init__(
parent,
mapframe,
properties,
sbmanager,
title=_("Map Display Settings"),
size=(-1, 250),
size=(-1, 300),
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
):
wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style)
Expand All @@ -296,6 +343,7 @@ def __init__(
self.size = size
self.mapframe = mapframe
self.mapWindowProperties = properties
self.statusbarManager = sbmanager

# notebook
self.notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT)
Expand Down Expand Up @@ -382,10 +430,19 @@ def _createStatusBarPage(self, parent):
panel.SetupScrolling(scroll_x=False, scroll_y=True)
parent.AddPage(page=panel, text=_("Status bar"))

# General settings
sizer = wx.BoxSizer(wx.VERTICAL)

# Auto-rendering
self.shownInStatusbar = RBShowInStatusbar(
parent=panel, sbmanager=self.statusbarManager
)
sizer.Add(
self.shownInStatusbar.GetWidget(),
proportion=0,
flag=wx.EXPAND | wx.ALL,
border=3,
)

# Display coordinates in different CRS
self.projection = ChBProjection(panel, self.mapWindowProperties)
sizer.Add(
self.projection.GetWidget(),
Expand Down

0 comments on commit 28a86c9

Please sign in to comment.