mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 23:36:36 +00:00
Fix assets management canvas panel scrolling.
libgui/GuiWindow.py: ONCE, THERE WAS A _LETHALLY FUCKING WOUNDED_ WXPYTHON libroar/RoarAssetsWindow.py: ON THE VERY EDGE OF ITS MISERABLE EXISTENCE libroar/RoarCanvasWindow.py: BECAUSE A LION VICIOUSLY MAULED IT AND TORTURED IT FOR 392 DAYS AND TWO (2) SECONDS
This commit is contained in:
parent
209b908fb4
commit
0d5f588108
@ -9,6 +9,7 @@ import wx
|
|||||||
class GuiWindow(wx.ScrolledWindow):
|
class GuiWindow(wx.ScrolledWindow):
|
||||||
# {{{ _updateScrollBars(self)
|
# {{{ _updateScrollBars(self)
|
||||||
def _updateScrollBars(self):
|
def _updateScrollBars(self):
|
||||||
|
if self.size != None:
|
||||||
clientSize = self.GetClientSize()
|
clientSize = self.GetClientSize()
|
||||||
if (self.size[0] > clientSize[0]) or (self.size[1] > clientSize[1]):
|
if (self.size[0] > clientSize[0]) or (self.size[1] > clientSize[1]):
|
||||||
self.scrollFlag = True; super().SetVirtualSize(self.size);
|
self.scrollFlag = True; super().SetVirtualSize(self.size);
|
||||||
@ -59,10 +60,10 @@ class GuiWindow(wx.ScrolledWindow):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
#
|
#
|
||||||
# __init__(self, parent, pos, scrollStep, size, style=0): initialisation method
|
# __init__(self, parent, pos, scrollStep, style=0): initialisation method
|
||||||
def __init__(self, parent, pos, scrollStep, size, style=0):
|
def __init__(self, parent, pos, scrollStep, style=0):
|
||||||
super().__init__(parent, pos=pos, size=size, style=style)
|
super().__init__(parent, pos=pos, style=style) if style != 0 else super().__init__(parent, pos=pos)
|
||||||
self.pos, self.scrollFlag, self.scrollStep, self.size = pos, False, scrollStep, size
|
self.pos, self.scrollFlag, self.scrollStep, self.size = pos, False, scrollStep, None
|
||||||
for eventType, f in (
|
for eventType, f in (
|
||||||
(wx.EVT_CHAR, self.onKeyboardInput), (wx.EVT_CLOSE, self.onClose), (wx.EVT_ENTER_WINDOW, self.onEnterWindow),
|
(wx.EVT_CHAR, self.onKeyboardInput), (wx.EVT_CLOSE, self.onClose), (wx.EVT_ENTER_WINDOW, self.onEnterWindow),
|
||||||
(wx.EVT_LEAVE_WINDOW, self.onLeaveWindow), (wx.EVT_LEFT_DOWN, self.onMouseInput), (wx.EVT_MOTION, self.onMouseInput),
|
(wx.EVT_LEAVE_WINDOW, self.onLeaveWindow), (wx.EVT_LEFT_DOWN, self.onMouseInput), (wx.EVT_MOTION, self.onMouseInput),
|
||||||
|
@ -88,10 +88,16 @@ class RoarAssetsWindow(GuiMiniFrame):
|
|||||||
# {{{ _updateScrollBars(self)
|
# {{{ _updateScrollBars(self)
|
||||||
def _updateScrollBars(self):
|
def _updateScrollBars(self):
|
||||||
clientSize = self.panelCanvas.GetClientSize()
|
clientSize = self.panelCanvas.GetClientSize()
|
||||||
if (self.panelCanvas.size[0] > clientSize[0]) or (self.panelCanvas.size[1] > clientSize[1]):
|
if self.currentIndex != None:
|
||||||
self.scrollFlag = True; super(wx.ScrolledWindow, self.panelCanvas).SetVirtualSize(self.panelCanvas.size);
|
panelSize = [a * b for a, b in zip(self.canvasList[self.currentIndex][0].size, self.backend.cellSize)]
|
||||||
|
elif self.panelCanvas.size != None:
|
||||||
|
panelSize = list(self.panelCanvas.size)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
if (panelSize[0] > clientSize[0]) or (panelSize[1] > clientSize[1]):
|
||||||
|
self.scrollFlag = True; super(wx.ScrolledWindow, self.panelCanvas).SetVirtualSize(panelSize);
|
||||||
elif self.scrollFlag \
|
elif self.scrollFlag \
|
||||||
and ((self.panelCanvas.size[0] <= clientSize[0]) or (self.panelCanvas.size[1] <= clientSize[1])):
|
and ((panelSize[0] <= clientSize[0]) or (panelSize[1] <= clientSize[1])):
|
||||||
self.scrollFlag = False; super(wx.ScrolledWindow, self.panelCanvas).SetVirtualSize((0, 0));
|
self.scrollFlag = False; super(wx.ScrolledWindow, self.panelCanvas).SetVirtualSize((0, 0));
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@ -324,15 +330,16 @@ class RoarAssetsWindow(GuiMiniFrame):
|
|||||||
self.listView.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onListViewItemSelected)
|
self.listView.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onListViewItemSelected)
|
||||||
self.listView.Bind(wx.EVT_RIGHT_DOWN, self.onListViewRightDown)
|
self.listView.Bind(wx.EVT_RIGHT_DOWN, self.onListViewRightDown)
|
||||||
|
|
||||||
self.panelCanvas = GuiWindow(self, (0, 0), cellSize, (int(size[0] / 2), int(size[1] / 2)), wx.BORDER_SUNKEN)
|
self.panelCanvas = GuiWindow(self, (0, 0), cellSize, wx.BORDER_SUNKEN)
|
||||||
self.panelCanvas.Bind(wx.EVT_LEFT_DOWN, self.onPanelLeftDown)
|
self.panelCanvas.Bind(wx.EVT_LEFT_DOWN, self.onPanelLeftDown)
|
||||||
self.panelCanvas.Bind(wx.EVT_PAINT, self.onPanelPaint)
|
self.panelCanvas.Bind(wx.EVT_PAINT, self.onPanelPaint)
|
||||||
self.panelCanvas.Bind(wx.EVT_SIZE, self.onPanelSize)
|
self.panelCanvas.Bind(wx.EVT_SIZE, self.onPanelSize)
|
||||||
self._updateScrollBars()
|
|
||||||
|
|
||||||
self.sizer = wx.BoxSizer(wx.VERTICAL)
|
self.sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
self.sizer.AddMany(((self.listView, 0, wx.ALL | wx.EXPAND, 4), (self.panelCanvas, 1, wx.ALL | wx.EXPAND, 4),))
|
self.sizer.AddMany(((self.listView, 0, wx.ALL | wx.EXPAND, 4), (self.panelCanvas, 1, wx.ALL | wx.EXPAND, 4),))
|
||||||
|
self.panelCanvas.SetMinSize((int(size[0] / 2), int(size[1] / 2)))
|
||||||
self.SetSizerAndFit(self.sizer)
|
self.SetSizerAndFit(self.sizer)
|
||||||
|
self._updateScrollBars()
|
||||||
self.Show(True)
|
self.Show(True)
|
||||||
|
|
||||||
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|
||||||
|
@ -201,7 +201,8 @@ class RoarCanvasWindow(GuiWindow):
|
|||||||
#
|
#
|
||||||
# __init__(self, backend, canvas, cellSize, commands, parent, parentFrame, pos, scrollStep, size): initialisation method
|
# __init__(self, backend, canvas, cellSize, commands, parent, parentFrame, pos, scrollStep, size): initialisation method
|
||||||
def __init__(self, backend, canvas, cellSize, commands, parent, parentFrame, pos, scrollStep, size):
|
def __init__(self, backend, canvas, cellSize, commands, parent, parentFrame, pos, scrollStep, size):
|
||||||
super().__init__(parent, pos, scrollStep, [w * h for w, h in zip(cellSize, size)])
|
super().__init__(parent, pos, scrollStep)
|
||||||
|
self.size = size
|
||||||
self.backend, self.canvas, self.cellSize, self.commands, self.parentFrame = backend(self.size, cellSize), canvas, cellSize, commands(self, parentFrame), parentFrame
|
self.backend, self.canvas, self.cellSize, self.commands, self.parentFrame = backend(self.size, cellSize), canvas, cellSize, commands(self, parentFrame), parentFrame
|
||||||
self.brushColours, self.brushPos, self.brushSize, self.dirty, self.lastCellState = [4, 1], [0, 0], [1, 1], False, None
|
self.brushColours, self.brushPos, self.brushSize, self.dirty, self.lastCellState = [4, 1], [0, 0], [1, 1], False, None
|
||||||
self.popupEventDc = None
|
self.popupEventDc = None
|
||||||
|
Loading…
Reference in New Issue
Block a user