Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions libs/pyTermTk/TermTk/TTkAbstract/abstractscrollarea.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def resizeEvent(self, w: int, h: int):

@pyTTkSlot()
def _viewportChanged(self):
if not self.isVisible(): return
if not self.isVisible() or self._processing: return
w,h = self.size()
fw, fh = self._viewport.viewFullAreaSize()
dw, dh = self._viewport.viewDisplayedSize()
Expand All @@ -102,21 +102,19 @@ def _viewportChanged(self):
self._horizontalScrollBar.setValue(ox)

if self._verticalScrollBarPolicy == TTkK.ScrollBarAsNeeded:
if h<=4 or w<=1 or vrange<=0:
if w<=self._verticalScrollBar.minimumWidth() or vrange<=0:
self._verticalScrollBar.hide()
elif dh>self._verticalScrollBar.minimumHeight()+1:
# we need enough space to display the bar to avoid endless loop
elif dh>=self._verticalScrollBar.minimumHeight():
self._verticalScrollBar.show()
elif self._verticalScrollBarPolicy == TTkK.ScrollBarAlwaysOn:
self._verticalScrollBar.show()
else:
self._verticalScrollBar.hide()

if self._horizontalScrollBarPolicy == TTkK.ScrollBarAsNeeded:
if w<=4 or h<=1 or hrange<=0:
if h<=self._horizontalScrollBar.minimumHeight() or hrange<=0:
self._horizontalScrollBar.hide()
elif dw>self._horizontalScrollBar.minimumWidth()+1:
# we need enough space to display the bar to avoid endless loop
elif dw>=self._horizontalScrollBar.minimumWidth():
self._horizontalScrollBar.show()
elif self._horizontalScrollBarPolicy == TTkK.ScrollBarAlwaysOn:
self._horizontalScrollBar.show()
Expand Down
5 changes: 2 additions & 3 deletions libs/pyTermTk/TermTk/TTkCore/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,15 @@ def drawScroll(self, pos, size, slider, orientation, color=TTkColor.RST):
self._set(y,x+i, TTkCfg.theme.hscroll[1], color)
for i in range(f,t): # Slider
self._set(y,x+i, TTkCfg.theme.hscroll[2], color)
self._set(y,x, TTkCfg.theme.hscroll[0], color) # Left Arrow
self._set(y,x+size-1, TTkCfg.theme.hscroll[3], color) # Right Arrow
self._set(y,x, TTkCfg.theme.hscroll[0], color) # Left Arrow
else:
for i in range(y+1,y+size-1): # V line
self._set(y+i,x, TTkCfg.theme.vscroll[1], color)
for i in range(f,t): # Slider
self._set(y+i,x, TTkCfg.theme.vscroll[2], color)
self._set(y,x, TTkCfg.theme.vscroll[0], color) # Up Arrow
self._set(y+size-1,x, TTkCfg.theme.vscroll[3], color) # Down Arrow
pass
self._set(y,x, TTkCfg.theme.vscroll[0], color) # Up Arrow

def drawTabMenuButton(
self, pos, size, text, slim=False,
Expand Down
9 changes: 2 additions & 7 deletions libs/pyTermTk/TermTk/TTkWidgets/scrollbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ def __init__(self, *,

TTkWidget.__init__(self, **kwargs)

if self._orientation == TTkK.VERTICAL:
self.setMaximumWidth(1)
self.setMinimumSize(1,3)
else:
self.setMaximumHeight(1)
self.setMinimumSize(3,1)
self.setMinimumSize(1,1)
self.setFocusPolicy(TTkK.ClickFocus)

def orientation(self):
Expand Down Expand Up @@ -181,7 +176,7 @@ def mouseDragEvent(self, evt:TTkMouseEvent) -> bool:

size2 = size-2
asciiStep = self._screenScroller[1] - self._screenScroller[0]
asciiDrawingSize = size2 - asciiStep
asciiDrawingSize = max(1, size2 - asciiStep)

a = aa * (self._maximum - self._minimum) // asciiDrawingSize

Expand Down