diff options
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r-- | src/ui/widget.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c index 0765bf9f..1c0fb271 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -880,9 +880,9 @@ iInt2 localToWindow_Widget(const iWidget *d, iInt2 localCoord) { | |||
880 | applyVisualOffset_Widget_(w, &pos); | 880 | applyVisualOffset_Widget_(w, &pos); |
881 | addv_I2(&window, pos); | 881 | addv_I2(&window, pos); |
882 | } | 882 | } |
883 | #if defined (iPlatformMobile) | 883 | //#if defined (iPlatformMobile) |
884 | window.y += value_Anim(&get_Window()->rootOffset); | 884 | // window.y += value_Anim(&get_Window()->rootOffset); |
885 | #endif | 885 | //#endif |
886 | return window; | 886 | return window; |
887 | } | 887 | } |
888 | 888 | ||
@@ -1072,23 +1072,33 @@ iBool dispatchEvent_Widget(iWidget *d, const SDL_Event *ev) { | |||
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | iBool scrollOverflow_Widget(iWidget *d, int delta) { | 1074 | iBool scrollOverflow_Widget(iWidget *d, int delta) { |
1075 | iRect bounds = boundsWithoutVisualOffset_Widget(d); | 1075 | iRect bounds = boundsWithoutVisualOffset_Widget(d); |
1076 | const iInt2 rootSize = size_Root(d->root); | 1076 | // const iInt2 rootSize = size_Root(d->root); |
1077 | const iRect winRect = safeRect_Root(d->root); | 1077 | const iRect winRect = adjusted_Rect(safeRect_Root(d->root), |
1078 | const int yTop = top_Rect(winRect); | 1078 | zero_I2(), |
1079 | const int yBottom = bottom_Rect(winRect); | 1079 | init_I2(0, -get_Window()->keyboardHeight)); |
1080 | const int yTop = top_Rect(winRect); | ||
1081 | const int yBottom = bottom_Rect(winRect); | ||
1080 | if (top_Rect(bounds) >= yTop && bottom_Rect(bounds) < yBottom) { | 1082 | if (top_Rect(bounds) >= yTop && bottom_Rect(bounds) < yBottom) { |
1081 | return iFalse; /* fits inside just fine */ | 1083 | return iFalse; /* fits inside just fine */ |
1082 | } | 1084 | } |
1083 | //const int safeBottom = rootSize.y - yBottom; | 1085 | //const int safeBottom = rootSize.y - yBottom; |
1084 | bounds.pos.y += delta; | 1086 | iRangei validPosRange = { bottom_Rect(winRect) - height_Rect(bounds), yTop }; |
1085 | const iRangei range = { bottom_Rect(winRect) - height_Rect(bounds), yTop }; | 1087 | if (validPosRange.start > validPosRange.end) { |
1088 | validPosRange.start = validPosRange.end; /* no room to scroll */ | ||
1089 | } | ||
1090 | if (delta) { | ||
1091 | if (delta < 0 && bounds.pos.y < validPosRange.start) { | ||
1092 | delta = 0; | ||
1093 | } | ||
1094 | if (delta > 0 && bounds.pos.y > validPosRange.end) { | ||
1095 | delta = 0; | ||
1096 | } | ||
1097 | bounds.pos.y += delta; | ||
1086 | // printf("range: %d ... %d\n", range.start, range.end); | 1098 | // printf("range: %d ... %d\n", range.start, range.end); |
1087 | if (range.start >= range.end) { | ||
1088 | bounds.pos.y = range.end; | ||
1089 | } | 1099 | } |
1090 | else { | 1100 | else { |
1091 | bounds.pos.y = iClamp(bounds.pos.y, range.start, range.end); | 1101 | bounds.pos.y = iClamp(bounds.pos.y, validPosRange.start, validPosRange.end); |
1092 | } | 1102 | } |
1093 | // if (delta >= 0) { | 1103 | // if (delta >= 0) { |
1094 | // bounds.pos.y = iMin(bounds.pos.y, yTop); | 1104 | // bounds.pos.y = iMin(bounds.pos.y, yTop); |
@@ -1454,7 +1464,7 @@ void setDrawBufferEnabled_Widget(iWidget *d, iBool enable) { | |||
1454 | 1464 | ||
1455 | static void beginBufferDraw_Widget_(const iWidget *d) { | 1465 | static void beginBufferDraw_Widget_(const iWidget *d) { |
1456 | if (d->drawBuf) { | 1466 | if (d->drawBuf) { |
1457 | printf("[%p] drawbuffer update %d\n", d, d->drawBuf->isValid); | 1467 | // printf("[%p] drawbuffer update %d\n", d, d->drawBuf->isValid); |
1458 | if (d->drawBuf->isValid) { | 1468 | if (d->drawBuf->isValid) { |
1459 | iAssert(!isEqual_I2(d->drawBuf->size, boundsForDraw_Widget_(d).size)); | 1469 | iAssert(!isEqual_I2(d->drawBuf->size, boundsForDraw_Widget_(d).size)); |
1460 | // printf(" drawBuf:%dx%d boundsForDraw:%dx%d\n", | 1470 | // printf(" drawBuf:%dx%d boundsForDraw:%dx%d\n", |
@@ -1503,7 +1513,7 @@ void draw_Widget(const iWidget *d) { | |||
1503 | endBufferDraw_Widget_(d); | 1513 | endBufferDraw_Widget_(d); |
1504 | } | 1514 | } |
1505 | if (d->drawBuf) { | 1515 | if (d->drawBuf) { |
1506 | iAssert(d->drawBuf->isValid); | 1516 | //iAssert(d->drawBuf->isValid); |
1507 | const iRect bounds = bounds_Widget(d); | 1517 | const iRect bounds = bounds_Widget(d); |
1508 | SDL_RenderCopy(renderer_Window(get_Window()), d->drawBuf->texture, NULL, | 1518 | SDL_RenderCopy(renderer_Window(get_Window()), d->drawBuf->texture, NULL, |
1509 | &(SDL_Rect){ bounds.pos.x, bounds.pos.y, | 1519 | &(SDL_Rect){ bounds.pos.x, bounds.pos.y, |