summaryrefslogtreecommitdiff
path: root/src/ui/touch.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-06 14:44:17 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-06 14:44:17 +0200
commiteddc86b7b0795fe7c7a82d86f6ee151ccdca229f (patch)
tree7eea8ac70aa37d068adfc2d06dc066367a10572c /src/ui/touch.c
parent7fa64b95d0c63b243f50b23c5551a7e04fe90c30 (diff)
Mobile: Dealing with keyboard height
The software keyboard obstructs part of the UI, so need to offset the view if the focused input widget would not be visible.
Diffstat (limited to 'src/ui/touch.c')
-rw-r--r--src/ui/touch.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c
index 27db0073..f15eda6f 100644
--- a/src/ui/touch.c
+++ b/src/ui/touch.c
@@ -190,6 +190,10 @@ static void update_TouchState_(void *ptr) {
190 iForEach(Array, m, d->moms) { 190 iForEach(Array, m, d->moms) {
191 if (numSteps == 0) break; 191 if (numSteps == 0) break;
192 iMomentum *mom = m.value; 192 iMomentum *mom = m.value;
193 if (!mom->affinity) {
194 remove_ArrayIterator(&m);
195 continue;
196 }
193 for (int step = 0; step < numSteps; step++) { 197 for (int step = 0; step < numSteps; step++) {
194 mulvf_F3(&mom->velocity, momFriction); 198 mulvf_F3(&mom->velocity, momFriction);
195 addv_F3(&mom->accum, mulf_F3(mom->velocity, stepDurationMs / 1000.0f)); 199 addv_F3(&mom->accum, mulf_F3(mom->velocity, stepDurationMs / 1000.0f));
@@ -248,8 +252,11 @@ static void dispatchButtonUp_Touch_(iFloat3 pos) {
248static iWidget *findOverflowScrollable_Widget_(iWidget *d) { 252static iWidget *findOverflowScrollable_Widget_(iWidget *d) {
249 const iInt2 rootSize = rootSize_Window(get_Window()); 253 const iInt2 rootSize = rootSize_Window(get_Window());
250 for (iWidget *w = d; w; w = parent_Widget(w)) { 254 for (iWidget *w = d; w; w = parent_Widget(w)) {
251 if (flags_Widget(w) & overflowScrollable_WidgetFlag && height_Widget(w) > rootSize.y) { 255 if (flags_Widget(w) & overflowScrollable_WidgetFlag) {
252 return w; 256 if (height_Widget(w) > rootSize.y && !hasVisibleChildOnTop_Widget(w)) {
257 return w;
258 }
259 return NULL;
253 } 260 }
254 } 261 }
255 return NULL; 262 return NULL;
@@ -262,9 +269,13 @@ iBool processEvent_Touch(const SDL_Event *ev) {
262 } 269 }
263 iTouchState *d = touchState_(); 270 iTouchState *d = touchState_();
264 iWindow *window = get_Window(); 271 iWindow *window = get_Window();
272 if (!isFinished_Anim(&window->rootOffset)) {
273 return iFalse;
274 }
265 const iInt2 rootSize = rootSize_Window(window); 275 const iInt2 rootSize = rootSize_Window(window);
266 const SDL_TouchFingerEvent *fing = &ev->tfinger; 276 const SDL_TouchFingerEvent *fing = &ev->tfinger;
267 const iFloat3 pos = init_F3(fing->x * rootSize.x, fing->y * rootSize.y, 0); /* pixels */ 277 const iFloat3 pos = add_F3(init_F3(fing->x * rootSize.x, fing->y * rootSize.y, 0), /* pixels */
278 init_F3(0, -value_Anim(&window->rootOffset), 0));
268 const uint32_t nowTime = SDL_GetTicks(); 279 const uint32_t nowTime = SDL_GetTicks();
269 if (ev->type == SDL_FINGERDOWN) { 280 if (ev->type == SDL_FINGERDOWN) {
270 /* Register the new touch. */ 281 /* Register the new touch. */