summaryrefslogtreecommitdiff
path: root/src/ui/scrollwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/scrollwidget.c')
-rw-r--r--src/ui/scrollwidget.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/ui/scrollwidget.c b/src/ui/scrollwidget.c
index 0bab601a..b6f73b6c 100644
--- a/src/ui/scrollwidget.c
+++ b/src/ui/scrollwidget.c
@@ -90,8 +90,22 @@ static int thumbSize_ScrollWidget_(const iScrollWidget *d) {
90 return iMax(gap_UI * 6, d->thumbSize); 90 return iMax(gap_UI * 6, d->thumbSize);
91} 91}
92 92
93static iRect bounds_ScrollWidget_(const iScrollWidget *d) {
94 const iWidget *w = constAs_Widget(d);
95 iRect bounds = bounds_Widget(w);
96 if (deviceType_App() == phone_AppDeviceType && isPortrait_App()) {
97 /* Account for the hidable toolbar. */
98 int toolbarHeight = lineHeight_Text(uiLabelLarge_FontId) + 3 * gap_UI;
99 int excess = bottom_Rect(bounds) - (bottom_Rect(safeRect_Root(w->root)) - toolbarHeight);
100 if (excess > 0) {
101 adjustEdges_Rect(&bounds, 0, 0, -excess, 0);
102 }
103 }
104 return bounds;
105}
106
93static iRect thumbRect_ScrollWidget_(const iScrollWidget *d) { 107static iRect thumbRect_ScrollWidget_(const iScrollWidget *d) {
94 const iRect bounds = bounds_Widget(constAs_Widget(d)); 108 const iRect bounds = bounds_ScrollWidget_(d);
95 iRect rect = init_Rect(bounds.pos.x, bounds.pos.y, bounds.size.x, 0); 109 iRect rect = init_Rect(bounds.pos.x, bounds.pos.y, bounds.size.x, 0);
96 const int total = size_Range(&d->range); 110 const int total = size_Range(&d->range);
97 if (total > 0) { 111 if (total > 0) {
@@ -181,7 +195,7 @@ static iBool processEvent_ScrollWidget_(iScrollWidget *d, const SDL_Event *ev) {
181 refresh_Widget(w); 195 refresh_Widget(w);
182 return iTrue; 196 return iTrue;
183 case drag_ClickResult: { 197 case drag_ClickResult: {
184 const iRect bounds = bounds_Widget(w); 198 const iRect bounds = bounds_ScrollWidget_(d);
185 const int offset = delta_Click(&d->click).y; 199 const int offset = delta_Click(&d->click).y;
186 const int total = size_Range(&d->range); 200 const int total = size_Range(&d->range);
187 int dpos = (float) offset / (float) (height_Rect(bounds) - thumbSize_ScrollWidget_(d)) * total; 201 int dpos = (float) offset / (float) (height_Rect(bounds) - thumbSize_ScrollWidget_(d)) * total;
@@ -218,7 +232,7 @@ static iBool processEvent_ScrollWidget_(iScrollWidget *d, const SDL_Event *ev) {
218 232
219static void draw_ScrollWidget_(const iScrollWidget *d) { 233static void draw_ScrollWidget_(const iScrollWidget *d) {
220 const iWidget *w = constAs_Widget(d); 234 const iWidget *w = constAs_Widget(d);
221 const iRect bounds = bounds_Widget(w); 235 const iRect bounds = bounds_ScrollWidget_(d);
222 const iBool isPressed = (flags_Widget(w) & pressed_WidgetFlag) != 0; 236 const iBool isPressed = (flags_Widget(w) & pressed_WidgetFlag) != 0;
223 if (bounds.size.x > 0) { 237 if (bounds.size.x > 0) {
224 iPaint p; 238 iPaint p;