|
2 | 2 |
|
3 | 3 | use Terminal::Widgets::Events; |
4 | 4 | use Terminal::Widgets::Widget; |
| 5 | +use Terminal::Widgets::Focusable; |
| 6 | +use Terminal::Widgets::Themable; |
5 | 7 | use Terminal::Widgets::Scrollable; |
6 | 8 |
|
7 | 9 | subset ScrollTarget where Str | Terminal::Widgets::Scrollable; |
8 | 10 |
|
9 | 11 |
|
10 | 12 | #| Role for scrollbars of any orientation |
11 | | -role Terminal::Widgets::Scrollbar { |
| 13 | +role Terminal::Widgets::Scrollbar |
| 14 | +does Terminal::Widgets::Themable |
| 15 | +does Terminal::Widgets::Focusable { |
12 | 16 | has ScrollTarget:D $.scroll-target is required; |
13 | 17 |
|
14 | 18 | has Bool:D $.show-end-arrows = True; |
@@ -101,16 +105,15 @@ class Terminal::Widgets::HScrollBar |
101 | 105 | $right += $layout.left-correction + $.show-end-arrows; |
102 | 106 | $left += $layout.left-correction + $.show-end-arrows; |
103 | 107 |
|
104 | | - # Fade bar if unneeded (everything visible, scroll = 0) |
| 108 | + # Get current color according to theme states, fading the |
| 109 | + # scrollbar if it's unneeded (everything visible, scroll = 0) |
105 | 110 | my $needed = $scroll || $end < $max; |
106 | | - my $g-bar = $needed ?? %!glyphs<bar> |
107 | | - !! $.grid.cell(%!glyphs<bar>, 'faint'); |
108 | | - my $g-handle = $needed ?? %!glyphs<handle> |
109 | | - !! $.grid.cell(%!glyphs<handle>, 'faint'); |
110 | | - my $g-left = $needed ?? %!glyphs<left> |
111 | | - !! $.grid.cell(%!glyphs<left>, 'faint'); |
112 | | - my $g-right = $needed ?? %!glyphs<right> |
113 | | - !! $.grid.cell(%!glyphs<right>, 'faint'); |
| 111 | + my $color = self.current-color; |
| 112 | + $color ~= ' faint' unless $needed; |
| 113 | + my $g-bar = $.grid.cell(%!glyphs<bar>, $color); |
| 114 | + my $g-handle = $.grid.cell(%!glyphs<handle>, $color); |
| 115 | + my $g-left = $.grid.cell(%!glyphs<left>, $color); |
| 116 | + my $g-right = $.grid.cell(%!glyphs<right>, $color); |
114 | 117 |
|
115 | 118 | # Actually draw updated bar and handle |
116 | 119 | my $y = $layout.top-correction; |
@@ -241,16 +244,15 @@ class Terminal::Widgets::VScrollBar |
241 | 244 | $bottom += $layout.top-correction + $.show-end-arrows; |
242 | 245 | $top += $layout.top-correction + $.show-end-arrows; |
243 | 246 |
|
244 | | - # Fade bar if unneeded (everything visible, scroll = 0) |
| 247 | + # Get current color according to theme states, fading the |
| 248 | + # scrollbar if it's unneeded (everything visible, scroll = 0) |
245 | 249 | my $needed = $scroll || $end < $max; |
246 | | - my $g-bar = $needed ?? %!glyphs<bar> |
247 | | - !! $.grid.cell(%!glyphs<bar>, 'faint'); |
248 | | - my $g-handle = $needed ?? %!glyphs<handle> |
249 | | - !! $.grid.cell(%!glyphs<handle>, 'faint'); |
250 | | - my $g-up = $needed ?? %!glyphs<up> |
251 | | - !! $.grid.cell(%!glyphs<up>, 'faint'); |
252 | | - my $g-down = $needed ?? %!glyphs<down> |
253 | | - !! $.grid.cell(%!glyphs<down>, 'faint'); |
| 250 | + my $color = self.current-color; |
| 251 | + $color ~= ' faint' unless $needed; |
| 252 | + my $g-bar = $.grid.cell(%!glyphs<bar>, $color); |
| 253 | + my $g-handle = $.grid.cell(%!glyphs<handle>, $color); |
| 254 | + my $g-up = $.grid.cell(%!glyphs<up>, $color); |
| 255 | + my $g-down = $.grid.cell(%!glyphs<down>, $color); |
254 | 256 |
|
255 | 257 | # Actually draw updated bar and handle |
256 | 258 | my $x = $layout.left-correction; |
|
0 commit comments