summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-21 13:48:15 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-21 13:48:15 +0300
commit7fefd2ca4f1be52c1bef3bc87cc8972a57cab396 (patch)
tree111a6a295072eb89ab49d21add9e44e496447733 /src/ui
parentbbbbc8e18879a5495be1cff78ca78be7a44ac25b (diff)
Mobile: Autoreload intervals are missing
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c25
-rw-r--r--src/ui/labelwidget.c2
-rw-r--r--src/ui/util.c17
-rw-r--r--src/ui/widget.c6
4 files changed, 36 insertions, 14 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index be831829..53f44868 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -2380,20 +2380,19 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
2380 } 2380 }
2381 } 2381 }
2382 else if (equal_Command(cmd, "document.autoreload.menu") && document_App() == d) { 2382 else if (equal_Command(cmd, "document.autoreload.menu") && document_App() == d) {
2383 iWidget *dlg = makeQuestion_Widget(uiTextAction_ColorEscape "${heading.autoreload}", 2383 iArray *items = collectNew_Array(sizeof(iMenuItem));
2384 "${dlg.autoreload}",
2385 (iMenuItem[]){ { "${cancel}", 0, 0, NULL } },
2386 1);
2387 for (int i = 0; i < max_ReloadInterval; ++i) { 2384 for (int i = 0; i < max_ReloadInterval; ++i) {
2388 insertChildAfterFlags_Widget( 2385 pushBack_Array(items, &(iMenuItem){
2389 dlg, 2386 format_CStr("%s%s", ((int) d->mod.reloadInterval == i ? "=" : "-"),
2390 iClob(new_LabelWidget(label_ReloadInterval_(i), 2387 label_ReloadInterval_(i)),
2391 format_CStr("document.autoreload.set arg:%d", i))), 2388 0,
2392 i + 1, 2389 0,
2393 resizeToParentWidth_WidgetFlag | 2390 format_CStr("document.autoreload.set arg:%d", i) });
2394 ((int) d->mod.reloadInterval == i ? selected_WidgetFlag : 0)); 2391 }
2395 } 2392 pushBack_Array(items, &(iMenuItem){ "${cancel}", 0, 0, NULL });
2396 arrange_Widget(dlg); 2393 makeQuestion_Widget(uiTextAction_ColorEscape "${heading.autoreload}",
2394 "${dlg.autoreload}",
2395 constData_Array(items), size_Array(items));
2397 return iTrue; 2396 return iTrue;
2398 } 2397 }
2399 else if (equal_Command(cmd, "document.autoreload.set") && document_App() == d) { 2398 else if (equal_Command(cmd, "document.autoreload.set") && document_App() == d) {
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index 16fee26d..ee535120 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -39,7 +39,7 @@ struct Impl_LabelWidget {
39 iChar icon; 39 iChar icon;
40 int forceFg; 40 int forceFg;
41 iString command; 41 iString command;
42 iBool alignVisual; /* align according to visible bounds, not typography */ 42 iBool alignVisual; /* align according to visible bounds, not font metrics */
43 iClick click; 43 iClick click;
44}; 44};
45 45
diff --git a/src/ui/util.c b/src/ui/util.c
index c518d5db..fb12dd7c 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1685,6 +1685,9 @@ iWidget *makeDialogButtons_Widget(const iMenuItem *actions, size_t numActions) {
1685 int key = actions[i].key; 1685 int key = actions[i].key;
1686 int kmods = actions[i].kmods; 1686 int kmods = actions[i].kmods;
1687 const iBool isDefault = (i == numActions - 1); 1687 const iBool isDefault = (i == numActions - 1);
1688 if (*label == '=' || *label == '-') {
1689 continue; /* Special value selection items for a Question dialog. */
1690 }
1688 if (!iCmpStr(label, "---")) { 1691 if (!iCmpStr(label, "---")) {
1689 /* Separator.*/ 1692 /* Separator.*/
1690 addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); 1693 addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag);
@@ -1792,6 +1795,20 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg,
1792 setCommandHandler_Widget(dlg, messageHandler_); 1795 setCommandHandler_Widget(dlg, messageHandler_);
1793 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag); 1796 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag);
1794 addChildFlags_Widget(dlg, iClob(new_LabelWidget(msg, NULL)), frameless_WidgetFlag); 1797 addChildFlags_Widget(dlg, iClob(new_LabelWidget(msg, NULL)), frameless_WidgetFlag);
1798 /* Check for value selections. */
1799 for (size_t i = 0; i < numItems; i++) {
1800 const iMenuItem *item = &items[i];
1801 const char first = item->label[0];
1802 if (first == '-' || first == '=') {
1803 addChildFlags_Widget(dlg,
1804 iClob(newKeyMods_LabelWidget(item->label + 1,
1805 item->key,
1806 item->kmods,
1807 item->command)),
1808 resizeToParentWidth_WidgetFlag |
1809 (first == '=' ? selected_WidgetFlag : 0));
1810 }
1811 }
1795 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); 1812 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI)));
1796 addChild_Widget(dlg, iClob(makeDialogButtons_Widget(items, numItems))); 1813 addChild_Widget(dlg, iClob(makeDialogButtons_Widget(items, numItems)));
1797 addChild_Widget(get_Window()->root, iClob(dlg)); 1814 addChild_Widget(get_Window()->root, iClob(dlg));
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 431d93c2..2048867d 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -1161,12 +1161,18 @@ iAny *insertChildAfter_Widget(iWidget *d, iAnyObject *child, size_t afterIndex)
1161 iAssert(!widget->parent); 1161 iAssert(!widget->parent);
1162 iAssert(d->children); 1162 iAssert(d->children);
1163 iAssert(afterIndex < size_ObjectList(d->children)); 1163 iAssert(afterIndex < size_ObjectList(d->children));
1164 iBool wasInserted = iFalse;
1164 iForEach(ObjectList, i, d->children) { 1165 iForEach(ObjectList, i, d->children) {
1165 if (afterIndex-- == 0) { 1166 if (afterIndex-- == 0) {
1166 insertAfter_ObjectList(d->children, i.value, child); 1167 insertAfter_ObjectList(d->children, i.value, child);
1168 wasInserted = iTrue;
1167 break; 1169 break;
1168 } 1170 }
1169 } 1171 }
1172 if (!wasInserted) {
1173 /* Someone is confused about the number of children? We still have to add this. */
1174 pushBack_ObjectList(d->children, child);
1175 }
1170 widget->parent = d; 1176 widget->parent = d;
1171 return child; 1177 return child;
1172} 1178}