Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
Enable horizontal scrolling
Browse files Browse the repository at this point in the history
By putting the Control into a ScrolledWindow, we get scroll bars whenever the Control's container is smaller than its minimum size.

Vertical scrolling of the ScrolledWindow currently is deactivated, as we still have our custom implementation for vertical scrolling.

This, however, raises some issues: At first, the vertical scroll bar gets scrolled away along with the Screenplay Control while scrolling horizontally, as it is part of the contents of the ScrolledWindow.

Also, the hand-made scrollbar lacks some features, such as auto-hiding or the "precise scrolling mode" on Gtk.

Eventually, the custom scrolling implementation is probably going to get in our way when implementing  #20 anyway, so we should try to port vertical scrolling to the ScrolledWindow scrolling mechanism.
  • Loading branch information
janopae committed Apr 7, 2023
1 parent 9940e99 commit a422e15
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/trelby.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ def save(self):
def saveScDict(self):
util.writeToFile(self.scDictFilename, self.scDict.save(), mainFrame)

class MyPanel(wx.Panel):
class MyPanel(wx.ScrolledWindow):

def __init__(self, parent, id):
wx.Panel.__init__(
wx.ScrolledWindow.__init__(
self, parent, id,
# wxMSW/Windows does not seem to support
# wx.NO_BORDER, which sucks
style = wx.WANTS_CHARS | wx.NO_BORDER)
style = wx.WANTS_CHARS | wx.NO_BORDER | wx.HSCROLL)

hsizer = wx.BoxSizer(wx.HORIZONTAL)

Expand All @@ -178,6 +178,8 @@ def __init__(self, parent, id):
self.scrollBarVertical.Bind(wx.EVT_SET_FOCUS, self.OnScrollbarFocus)

self.SetSizer(hsizer)
self.SetScrollRate(int(self.ctrl.chX), int(self.ctrl.chY))
self.EnableScrolling(True, False)

# we never want the scrollbar to get the keyboard focus, pass it on to
# the main widget
Expand Down Expand Up @@ -435,6 +437,8 @@ def isUntouched(self):

def updateScreen(self, redraw = True, setCommon = True):
self.adjustScrollBar()
self.SetMinSize(wx.Size(int(self.pageW), 10)) # the vertical min size is irrelevant currently, as vertical scrolling is still self-implemented
self.PostSizeEventToParent()

if setCommon:
self.updateCommon()
Expand Down

0 comments on commit a422e15

Please sign in to comment.