summaryrefslogtreecommitdiff
path: root/src/ui/root.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-27 11:40:50 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-27 11:40:50 +0300
commit170209cf926e2f714d507fefaa6b30fd245811ad (patch)
tree1dd6ff1e7c9ecf69c0857b8524bfdc82f07794b9 /src/ui/root.c
parent83e14d99ba75316da265cfa5f3fd092caa1498cf (diff)
Refactor: Moving RootData so it can become non-global state
Diffstat (limited to 'src/ui/root.c')
-rw-r--r--src/ui/root.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/ui/root.c b/src/ui/root.c
index 50c4992e..f6b93abd 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -234,16 +234,45 @@ static const char *stopSeqCStr_[] = {
234static const int loadAnimIntervalMs_ = 133; 234static const int loadAnimIntervalMs_ = 133;
235static int loadAnimIndex_ = 0; 235static int loadAnimIndex_ = 0;
236 236
237static iWidget * activeRoot_ = NULL; 237static iWidget * activeRoot_ = NULL;
238static iRootData * activeRootData_ = NULL;
238 239
239void setCurrent_Root(iWidget *root) { 240void setCurrent_Root(iWidget *root, iRootData *rootData) {
240 activeRoot_ = root; 241 activeRoot_ = root;
242 activeRootData_ = rootData;
241} 243}
242 244
243iWidget *get_Root(void) { 245iWidget *get_Root(void) {
244 return activeRoot_; 246 return activeRoot_;
245} 247}
246 248
249iRootData *data_Root(void) {
250 return activeRootData_;
251}
252
253void destroyPending_RootData(iRootData *d) {
254 iForEach(PtrSet, i, d->pendingDestruction) {
255 iWidget *widget = *i.value;
256 if (!isFinished_Anim(&widget->visualOffset)) {
257 continue;
258 }
259 if (widget->parent) {
260 removeChild_Widget(widget->parent, widget);
261 }
262 iAssert(widget->parent == NULL);
263 iRelease(widget);
264 remove_PtrSetIterator(&i);
265 }
266}
267
268iPtrArray *onTop_RootData(void) {
269 iAssert(activeRootData_);
270 if (!activeRootData_->onTop) {
271 activeRootData_->onTop = new_PtrArray();
272 }
273 return activeRootData_->onTop;
274}
275
247static iBool handleRootCommands_(iWidget *root, const char *cmd) { 276static iBool handleRootCommands_(iWidget *root, const char *cmd) {
248 iUnused(root); 277 iUnused(root);
249 if (equal_Command(cmd, "menu.open")) { 278 if (equal_Command(cmd, "menu.open")) {
@@ -1031,8 +1060,6 @@ iWidget *createUserInterface_Root(void) {
1031# endif 1060# endif
1032 setAlignVisually_LabelWidget(navMenu, iTrue); 1061 setAlignVisually_LabelWidget(navMenu, iTrue);
1033 setId_Widget(addChildFlags_Widget(navBar, iClob(navMenu), collapse_WidgetFlag), "navbar.menu"); 1062 setId_Widget(addChildFlags_Widget(navBar, iClob(navMenu), collapse_WidgetFlag), "navbar.menu");
1034#else
1035 insertMacMenus_();
1036#endif 1063#endif
1037 } 1064 }
1038 /* Tab bar. */ { 1065 /* Tab bar. */ {