Browse Source

Fix TextView always visible scroll bar not appearing when empty

textarea
Trevor Slocum 1 year ago
parent
commit
7b45918cfa
  1. 1
      CHANGELOG
  2. 19
      textview.go

1
CHANGELOG

@ -5,6 +5,7 @@ v1.5.6 (WIP)
- Add CheckBox.SetCursorRune (cursors are now shown within CheckBoxes when focused by default)
- Add DropDown.SetAlwaysDrawDropDownSymbol (DropDown symbols are now shown only when focused by default)
- Add DropDown.SetDropDownOpenSymbolRune
- Fix TextView always visible scroll bar not appearing when empty
- Draw additional accents when rendering a list divider
- Update Application.Draw and Application.QueueUpdateDraw to accept one or more
primitives to draw instead of the whole screen

19
textview.go

@ -1039,6 +1039,17 @@ func (t *TextView) Draw(screen tcell.Screen) {
t.regionInfos = nil
}
// Draw scroll bar last.
defer func() {
if !showVerticalScrollBar {
return
}
cursor := int(float64(len(t.index)) * (float64(t.lineOffset) / float64(len(t.index)-height)))
for printed := 0; printed < height; printed++ {
RenderScrollBar(screen, t.scrollBarVisibility, x+width, y+printed, height, len(t.index), cursor, printed, t.hasFocus, t.scrollBarColor)
}
}()
// If we don't have an index, there's nothing to draw.
if t.index == nil {
return
@ -1252,14 +1263,6 @@ func (t *TextView) Draw(screen tcell.Screen) {
}
}
// Draw scroll bar.
if showVerticalScrollBar {
cursor := int(float64(len(t.index)) * (float64(t.lineOffset) / float64(len(t.index)-height)))
for printed := 0; printed < height; printed++ {
RenderScrollBar(screen, t.scrollBarVisibility, x+width, y+printed, height, len(t.index), cursor, printed, t.hasFocus, t.scrollBarColor)
}
}
// If this view is not scrollable, we'll purge the buffer of lines that have
// scrolled out of view.
if !t.scrollable && t.lineOffset > 0 {

Loading…
Cancel
Save