summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.c12
-rw-r--r--src/ui/inputwidget.c12
-rw-r--r--src/ui/root.c8
-rw-r--r--src/ui/root.h7
-rw-r--r--src/ui/widget.c1
5 files changed, 39 insertions, 1 deletions
diff --git a/src/app.c b/src/app.c
index 587efd00..52072d39 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1455,11 +1455,17 @@ backToMainLoop:;
1455static void runTickers_App_(iApp *d) { 1455static void runTickers_App_(iApp *d) {
1456 const uint32_t now = SDL_GetTicks(); 1456 const uint32_t now = SDL_GetTicks();
1457 d->elapsedSinceLastTicker = (d->lastTickerTime ? now - d->lastTickerTime : 0); 1457 d->elapsedSinceLastTicker = (d->lastTickerTime ? now - d->lastTickerTime : 0);
1458 d->lastTickerTime = now; 1458 d->lastTickerTime = now;
1459 if (isEmpty_SortedArray(&d->tickers)) { 1459 if (isEmpty_SortedArray(&d->tickers)) {
1460 d->lastTickerTime = 0; 1460 d->lastTickerTime = 0;
1461 return; 1461 return;
1462 } 1462 }
1463 iForIndices(i, d->window->base.roots) {
1464 iRoot *root = d->window->base.roots[i];
1465 if (root) {
1466 root->didAnimateVisualOffsets = iFalse;
1467 }
1468 }
1463 /* Tickers may add themselves again, so we'll run off a copy. */ 1469 /* Tickers may add themselves again, so we'll run off a copy. */
1464 iSortedArray *pending = copy_SortedArray(&d->tickers); 1470 iSortedArray *pending = copy_SortedArray(&d->tickers);
1465 clear_SortedArray(&d->tickers); 1471 clear_SortedArray(&d->tickers);
@@ -1476,6 +1482,10 @@ static void runTickers_App_(iApp *d) {
1476 if (isEmpty_SortedArray(&d->tickers)) { 1482 if (isEmpty_SortedArray(&d->tickers)) {
1477 d->lastTickerTime = 0; 1483 d->lastTickerTime = 0;
1478 } 1484 }
1485 iForIndices(i, d->window->base.roots) {
1486 iRoot *root = d->window->base.roots[i];
1487 notifyVisualOffsetChange_Root(root);
1488 }
1479} 1489}
1480 1490
1481static int resizeWatcher_(void *user, SDL_Event *event) { 1491static int resizeWatcher_(void *user, SDL_Event *event) {
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index bb3851df..e72ed361 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -756,6 +756,16 @@ void deinit_InputWidget(iInputWidget *d) {
756 deinit_Array(&d->lines); 756 deinit_Array(&d->lines);
757} 757}
758 758
759#if defined (LAGRANGE_ENABLE_SYSTEM_INPUT)
760static void updateAfterVisualOffsetChange_InputWidget_(iInputWidget *d, iRoot *root) {
761 iAssert(as_Widget(d)->root == root);
762 iUnused(root);
763 if (d->sysCtrl) {
764 setRect_SystemTextInput(d->sysCtrl, contentBounds_InputWidget_(d));
765 }
766}
767#endif
768
759void setFont_InputWidget(iInputWidget *d, int fontId) { 769void setFont_InputWidget(iInputWidget *d, int fontId) {
760 d->font = fontId; 770 d->font = fontId;
761 updateMetrics_InputWidget_(d); 771 updateMetrics_InputWidget_(d);
@@ -1047,6 +1057,7 @@ void begin_InputWidget(iInputWidget *d) {
1047 setRect_SystemTextInput(d->sysCtrl, contentBounds_InputWidget_(d)); 1057 setRect_SystemTextInput(d->sysCtrl, contentBounds_InputWidget_(d));
1048 setText_SystemTextInput(d->sysCtrl, &d->oldText); 1058 setText_SystemTextInput(d->sysCtrl, &d->oldText);
1049 setTextChangedFunc_SystemTextInput(d->sysCtrl, systemInputChanged_InputWidget_, d); 1059 setTextChangedFunc_SystemTextInput(d->sysCtrl, systemInputChanged_InputWidget_, d);
1060 iConnect(Root, w->root, visualOffsetsChanged, d, updateAfterVisualOffsetChange_InputWidget_);
1050 return; 1061 return;
1051#endif 1062#endif
1052 if (d->mode == overwrite_InputMode) { 1063 if (d->mode == overwrite_InputMode) {
@@ -1080,6 +1091,7 @@ void end_InputWidget(iInputWidget *d, iBool accept) {
1080 return; 1091 return;
1081 } 1092 }
1082 if (d->sysCtrl) { 1093 if (d->sysCtrl) {
1094 iDisconnect(Root, w->root, visualOffsetsChanged, d, updateAfterVisualOffsetChange_InputWidget_);
1083 if (accept) { 1095 if (accept) {
1084 splitToLines_(text_SystemTextInput(d->sysCtrl), &d->lines); 1096 splitToLines_(text_SystemTextInput(d->sysCtrl), &d->lines);
1085 } 1097 }
diff --git a/src/ui/root.c b/src/ui/root.c
index 0e949246..5a579eb4 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -241,6 +241,7 @@ static int loadAnimIndex_ = 0;
241static iRoot * activeRoot_ = NULL; 241static iRoot * activeRoot_ = NULL;
242 242
243iDefineTypeConstruction(Root) 243iDefineTypeConstruction(Root)
244iDefineAudienceGetter(Root, visualOffsetsChanged)
244 245
245void init_Root(iRoot *d) { 246void init_Root(iRoot *d) {
246 iZap(*d); 247 iZap(*d);
@@ -250,6 +251,7 @@ void deinit_Root(iRoot *d) {
250 iReleasePtr(&d->widget); 251 iReleasePtr(&d->widget);
251 delete_PtrArray(d->onTop); 252 delete_PtrArray(d->onTop);
252 delete_PtrSet(d->pendingDestruction); 253 delete_PtrSet(d->pendingDestruction);
254 delete_Audience(d->visualOffsetsChanged);
253} 255}
254 256
255void setCurrent_Root(iRoot *root) { 257void setCurrent_Root(iRoot *root) {
@@ -658,6 +660,12 @@ void updateToolbarColors_Root(iRoot *d) {
658#endif 660#endif
659} 661}
660 662
663void notifyVisualOffsetChange_Root(iRoot *d) {
664 if (d && d->didAnimateVisualOffsets) {
665 iNotifyAudience(d, visualOffsetsChanged, RootVisualOffsetsChanged);
666 }
667}
668
661void dismissPortraitPhoneSidebars_Root(iRoot *d) { 669void dismissPortraitPhoneSidebars_Root(iRoot *d) {
662 if (deviceType_App() == phone_AppDeviceType && isPortrait_App()) { 670 if (deviceType_App() == phone_AppDeviceType && isPortrait_App()) {
663 iWidget *sidebar = findChild_Widget(d->widget, "sidebar"); 671 iWidget *sidebar = findChild_Widget(d->widget, "sidebar");
diff --git a/src/ui/root.h b/src/ui/root.h
index 851d927d..2419b599 100644
--- a/src/ui/root.h
+++ b/src/ui/root.h
@@ -2,11 +2,15 @@
2 2
3#include "widget.h" 3#include "widget.h"
4#include "color.h" 4#include "color.h"
5#include <the_Foundation/audience.h>
5#include <the_Foundation/ptrset.h> 6#include <the_Foundation/ptrset.h>
6#include <the_Foundation/vec2.h> 7#include <the_Foundation/vec2.h>
7 8
8iDeclareType(Root) 9iDeclareType(Root)
9 10
11iDeclareNotifyFunc(Root, VisualOffsetsChanged)
12iDeclareAudienceGetter(Root, visualOffsetsChanged)
13
10struct Impl_Root { 14struct Impl_Root {
11 iWidget * widget; 15 iWidget * widget;
12 iWindow * window; 16 iWindow * window;
@@ -14,6 +18,8 @@ struct Impl_Root {
14 iPtrSet * pendingDestruction; 18 iPtrSet * pendingDestruction;
15 iBool pendingArrange; 19 iBool pendingArrange;
16 int loadAnimTimer; 20 int loadAnimTimer;
21 iBool didAnimateVisualOffsets;
22 iAudience *visualOffsetsChanged; /* called after running tickers */
17 iColor tmPalette[tmMax_ColorId]; /* theme-specific palette */ 23 iColor tmPalette[tmMax_ColorId]; /* theme-specific palette */
18}; 24};
19 25
@@ -36,6 +42,7 @@ void updatePadding_Root (iRoot *); /* TODO: is part of m
36void dismissPortraitPhoneSidebars_Root (iRoot *); 42void dismissPortraitPhoneSidebars_Root (iRoot *);
37void showToolbar_Root (iRoot *, iBool show); 43void showToolbar_Root (iRoot *, iBool show);
38void updateToolbarColors_Root (iRoot *); 44void updateToolbarColors_Root (iRoot *);
45void notifyVisualOffsetChange_Root (iRoot *);
39 46
40iInt2 size_Root (const iRoot *); 47iInt2 size_Root (const iRoot *);
41iRect rect_Root (const iRoot *); 48iRect rect_Root (const iRoot *);
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 0d20cca9..225c0480 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -142,6 +142,7 @@ void init_Widget(iWidget *d) {
142static void visualOffsetAnimation_Widget_(void *ptr) { 142static void visualOffsetAnimation_Widget_(void *ptr) {
143 iWidget *d = ptr; 143 iWidget *d = ptr;
144 postRefresh_App(); 144 postRefresh_App();
145 d->root->didAnimateVisualOffsets = iTrue;
145 if (!isFinished_Anim(&d->visualOffset)) { 146 if (!isFinished_Anim(&d->visualOffset)) {
146 addTicker_App(visualOffsetAnimation_Widget_, ptr); 147 addTicker_App(visualOffsetAnimation_Widget_, ptr);
147 } 148 }