summaryrefslogtreecommitdiff
path: root/src/ui/widget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r--src/ui/widget.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c
index b509cbe2..1ab16b4f 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -1142,11 +1142,9 @@ static iBool isOverflowScrollPossible_Widget_(const iWidget *d, int delta) {
1142 return iFalse; 1142 return iFalse;
1143 } 1143 }
1144 iRect bounds = boundsWithoutVisualOffset_Widget(d); 1144 iRect bounds = boundsWithoutVisualOffset_Widget(d);
1145 const iRect winRect = adjusted_Rect(safeRect_Root(d->root), 1145 const iRect winRect = visibleRect_Root(d->root);
1146 zero_I2(), 1146 const int yTop = top_Rect(winRect);
1147 init_I2(0, -get_MainWindow()->keyboardHeight)); 1147 const int yBottom = bottom_Rect(winRect);
1148 const int yTop = top_Rect(winRect);
1149 const int yBottom = bottom_Rect(winRect);
1150 if (delta == 0) { 1148 if (delta == 0) {
1151 if (top_Rect(bounds) >= yTop && bottom_Rect(bounds) <= yBottom) { 1149 if (top_Rect(bounds) >= yTop && bottom_Rect(bounds) <= yBottom) {
1152 return iFalse; /* fits inside just fine */ 1150 return iFalse; /* fits inside just fine */
@@ -1162,11 +1160,9 @@ iBool scrollOverflow_Widget(iWidget *d, int delta) {
1162 if (!isOverflowScrollPossible_Widget_(d, delta)) { 1160 if (!isOverflowScrollPossible_Widget_(d, delta)) {
1163 return iFalse; 1161 return iFalse;
1164 } 1162 }
1165 iRect bounds = boundsWithoutVisualOffset_Widget(d); 1163 iRect bounds = boundsWithoutVisualOffset_Widget(d);
1166 const iRect winRect = adjusted_Rect(safeRect_Root(d->root), 1164 const iRect winRect = visibleRect_Root(d->root);
1167 zero_I2(), 1165 iRangei validPosRange = { bottom_Rect(winRect) - height_Rect(bounds), top_Rect(winRect) };
1168 init_I2(0, -get_MainWindow()->keyboardHeight));
1169 iRangei validPosRange = { bottom_Rect(winRect) - height_Rect(bounds), top_Rect(winRect) };
1170 if (validPosRange.start > validPosRange.end) { 1166 if (validPosRange.start > validPosRange.end) {
1171 validPosRange.start = validPosRange.end; /* no room to scroll */ 1167 validPosRange.start = validPosRange.end; /* no room to scroll */
1172 } 1168 }
@@ -1244,18 +1240,26 @@ iBool processEvent_Widget(iWidget *d, const SDL_Event *ev) {
1244 /* TODO: Motion events occur frequently. Maybe it would help if these were handled 1240 /* TODO: Motion events occur frequently. Maybe it would help if these were handled
1245 via audiences that specifically register to listen for motion, to minimize the 1241 via audiences that specifically register to listen for motion, to minimize the
1246 number of widgets that need to process them. */ 1242 number of widgets that need to process them. */
1247 const int hoverScrollLimit = 2 * lineHeight_Text(default_FontId); 1243 const int hoverScrollLimit = 1.5f * lineHeight_Text(default_FontId);
1248 float speed = 0.0f; 1244 float speed = 0.0f;
1249 if (ev->motion.y < hoverScrollLimit) { 1245 if (ev->motion.y < hoverScrollLimit) {
1250 speed = (hoverScrollLimit - ev->motion.y) / (float) hoverScrollLimit; 1246 speed = (hoverScrollLimit - ev->motion.y) / (float) hoverScrollLimit;
1251 } 1247 }
1252 else { 1248 else {
1253 const int bottomLimit = bottom_Rect(rect_Root(d->root)) - hoverScrollLimit; 1249 const iWindow *win = window_Widget(d);
1254 if (ev->motion.y > bottomLimit ) { 1250 SDL_Rect usable;
1251 SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(win->win),
1252 &usable);
1253 const int bottomLimit =
1254 iMin(bottom_Rect(rect_Root(d->root)), usable.h * win->pixelRatio) -
1255 hoverScrollLimit;
1256 if (ev->motion.y > bottomLimit) {
1255 speed = -(ev->motion.y - bottomLimit) / (float) hoverScrollLimit; 1257 speed = -(ev->motion.y - bottomLimit) / (float) hoverScrollLimit;
1256 } 1258 }
1257 } 1259 }
1258 if (speed != 0.0f && isOverflowScrollPossible_Widget_(d, speed > 0 ? 1 : -1)) { 1260 const int dir = speed > 0 ? 1 : -1;
1261 if (speed != 0.0f && isOverflowScrollPossible_Widget_(d, dir)) {
1262// speed = dir * powf(speed, 1.5f);
1259 const uint32_t nowTime = SDL_GetTicks(); 1263 const uint32_t nowTime = SDL_GetTicks();
1260 uint32_t elapsed = nowTime - lastHoverOverflowMotionTime_; 1264 uint32_t elapsed = nowTime - lastHoverOverflowMotionTime_;
1261 if (elapsed > 100) { 1265 if (elapsed > 100) {