summaryrefslogtreecommitdiff
path: root/src/ui/mobile.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-08 10:52:54 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-08 10:52:54 +0300
commit5db4578e5d8e58ceb32ea0405ac493d1b0ffa592 (patch)
treee4853406eb1334deb5b1a24f81596fdfb617bb47 /src/ui/mobile.c
parent4ce9a07bbd4a4a82ff0b310d9c9e0768febe8d61 (diff)
Mobile: Preferences is completed, improved
Diffstat (limited to 'src/ui/mobile.c')
-rw-r--r--src/ui/mobile.c72
1 files changed, 51 insertions, 21 deletions
diff --git a/src/ui/mobile.c b/src/ui/mobile.c
index 4ccbb0cb..ecfb83ed 100644
--- a/src/ui/mobile.c
+++ b/src/ui/mobile.c
@@ -187,6 +187,7 @@ static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) {
187 return iFalse; 187 return iFalse;
188} 188}
189 189
190#if 0
190static iBool isTwoColumnPage_(iWidget *d) { 191static iBool isTwoColumnPage_(iWidget *d) {
191 if (cmp_String(id_Widget(d), "dialogbuttons") == 0 || 192 if (cmp_String(id_Widget(d), "dialogbuttons") == 0 ||
192 cmp_String(id_Widget(d), "prefs.tabs") == 0) { 193 cmp_String(id_Widget(d), "prefs.tabs") == 0) {
@@ -274,6 +275,7 @@ static void stripTrailingColon_(iLabelWidget *label) {
274 delete_String(mod); 275 delete_String(mod);
275 } 276 }
276} 277}
278#endif
277 279
278static iLabelWidget *makePanelButton_(const char *text, const char *command) { 280static iLabelWidget *makePanelButton_(const char *text, const char *command) {
279 iLabelWidget *btn = new_LabelWidget(text, command); 281 iLabelWidget *btn = new_LabelWidget(text, command);
@@ -299,11 +301,9 @@ static iWidget *makeValuePadding_(iWidget *value) {
299 setPadding_Widget(pad, 0, 1 * gap_UI, 0, 1 * gap_UI); 301 setPadding_Widget(pad, 0, 1 * gap_UI, 0, 1 * gap_UI);
300 addChild_Widget(pad, iClob(value)); 302 addChild_Widget(pad, iClob(value));
301 setFlags_Widget(pad, 303 setFlags_Widget(pad,
302 borderBottom_WidgetFlag | 304 borderTop_WidgetFlag | borderBottom_WidgetFlag | arrangeVertical_WidgetFlag |
303 arrangeVertical_WidgetFlag | 305 resizeToParentWidth_WidgetFlag | resizeWidthOfChildren_WidgetFlag |
304 resizeToParentWidth_WidgetFlag | 306 arrangeHeight_WidgetFlag,
305 resizeWidthOfChildren_WidgetFlag |
306 arrangeHeight_WidgetFlag,
307 iTrue); 307 iTrue);
308 return pad; 308 return pad;
309} 309}
@@ -312,7 +312,7 @@ static iWidget *makeValuePaddingWithHeading_(iLabelWidget *heading, iWidget *val
312 const iBool isInput = isInstance_Object(value, &Class_InputWidget); 312 const iBool isInput = isInstance_Object(value, &Class_InputWidget);
313 iWidget *div = new_Widget(); 313 iWidget *div = new_Widget();
314 setFlags_Widget(div, 314 setFlags_Widget(div,
315 borderBottom_WidgetFlag | arrangeHeight_WidgetFlag | 315 borderTop_WidgetFlag | borderBottom_WidgetFlag | arrangeHeight_WidgetFlag |
316 resizeWidthOfChildren_WidgetFlag | 316 resizeWidthOfChildren_WidgetFlag |
317 arrangeHorizontal_WidgetFlag, iTrue); 317 arrangeHorizontal_WidgetFlag, iTrue);
318 setBackgroundColor_Widget(div, uiBackgroundSidebar_ColorId); 318 setBackgroundColor_Widget(div, uiBackgroundSidebar_ColorId);
@@ -418,7 +418,8 @@ void makePanelItem_Mobile(iWidget *panel, const iMenuItem *item) {
418 setId_Widget(as_Widget(drop), id); 418 setId_Widget(as_Widget(drop), id);
419 widget = makeValuePaddingWithHeading_(heading = makeHeading_Widget(label), as_Widget(drop)); 419 widget = makeValuePaddingWithHeading_(heading = makeHeading_Widget(label), as_Widget(drop));
420 } 420 }
421 else if (equal_Command(spec, "radio")) { 421 else if (equal_Command(spec, "radio") || equal_Command(spec, "buttons")) {
422 const iBool isRadio = equal_Command(spec, "radio");
422 addChild_Widget(panel, iClob(makePadding_Widget(lineHeight_Text(labelFont_())))); 423 addChild_Widget(panel, iClob(makePadding_Widget(lineHeight_Text(labelFont_()))));
423 iLabelWidget *head = makeHeading_Widget(label); 424 iLabelWidget *head = makeHeading_Widget(label);
424 setAllCaps_LabelWidget(head, iTrue); 425 setAllCaps_LabelWidget(head, iTrue);
@@ -427,9 +428,9 @@ void makePanelItem_Mobile(iWidget *panel, const iMenuItem *item) {
427 widget = new_Widget(); 428 widget = new_Widget();
428 setBackgroundColor_Widget(widget, uiBackgroundSidebar_ColorId); 429 setBackgroundColor_Widget(widget, uiBackgroundSidebar_ColorId);
429 setPadding_Widget(widget, 4 * gap_UI, 2 * gap_UI, 4 * gap_UI, 2 * gap_UI); 430 setPadding_Widget(widget, 4 * gap_UI, 2 * gap_UI, 4 * gap_UI, 2 * gap_UI);
430// setFlags_Widget(widget, arrangeWidth_WidgetFlag, iFalse);
431 setFlags_Widget(widget, 431 setFlags_Widget(widget,
432 borderBottom_WidgetFlag | 432 borderTop_WidgetFlag |
433 borderBottom_WidgetFlag |
433 arrangeHorizontal_WidgetFlag | 434 arrangeHorizontal_WidgetFlag |
434 arrangeHeight_WidgetFlag | 435 arrangeHeight_WidgetFlag |
435 resizeToParentWidth_WidgetFlag | 436 resizeToParentWidth_WidgetFlag |
@@ -437,24 +438,53 @@ void makePanelItem_Mobile(iWidget *panel, const iMenuItem *item) {
437 iTrue); 438 iTrue);
438 setId_Widget(widget, id); 439 setId_Widget(widget, id);
439 for (const iMenuItem *radioItem = item->data; radioItem->label; radioItem++) { 440 for (const iMenuItem *radioItem = item->data; radioItem->label; radioItem++) {
440 const char * radId = cstr_Rangecc(range_Command(radioItem->label, "id")); 441 const char * radId = cstr_Rangecc(range_Command(radioItem->label, "id"));
441 const char * radLabel = hasLabel_Command(radioItem->label, "label") 442 int64_t flags = noBackground_WidgetFlag;
442 ? format_CStr("${%s}", cstr_Rangecc(range_Command(radioItem->label, "label"))) 443 iLabelWidget *button;
443 : suffixPtr_Command(radioItem->label, "text"); 444 if (isRadio) {
444 iLabelWidget *radButton = new_LabelWidget(radLabel, radioItem->command); 445 const char *radLabel =
445 setId_Widget(as_Widget(radButton), radId); 446 hasLabel_Command(radioItem->label, "label")
446 setFont_LabelWidget(radButton, defaultMedium_FontId); 447 ? format_CStr("${%s}",
447 addChildFlags_Widget(widget, iClob(radButton), radio_WidgetFlag | noBackground_WidgetFlag); 448 cstr_Rangecc(range_Command(radioItem->label, "label")))
449 : suffixPtr_Command(radioItem->label, "text");
450 button = new_LabelWidget(radLabel, radioItem->command);
451 flags |= radio_WidgetFlag;
452 }
453 else {
454 button = (iLabelWidget *) makeToggle_Widget(radId);
455 setTextCStr_LabelWidget(button, format_CStr("${%s}", radId));
456 setFlags_Widget(as_Widget(button), fixedWidth_WidgetFlag, iFalse);
457 updateSize_LabelWidget(button);
458 }
459 setId_Widget(as_Widget(button), radId);
460 setFont_LabelWidget(button, defaultMedium_FontId);
461 addChildFlags_Widget(widget, iClob(button), flags);
448 } 462 }
449 } 463 }
450 else if (equal_Command(spec, "input")) { 464 else if (equal_Command(spec, "input")) {
451 iInputWidget *input = new_InputWidget(argU32Label_Command(spec, "maxlen")); 465 iInputWidget *input = new_InputWidget(argU32Label_Command(spec, "maxlen"));
452 setId_Widget(as_Widget(input), id); 466 setId_Widget(as_Widget(input), id);
453 setFont_InputWidget(input, labelFont_());
454 setContentPadding_InputWidget(input, 3 * gap_UI, 0);
455 setUrlContent_InputWidget(input, argLabel_Command(spec, "url")); 467 setUrlContent_InputWidget(input, argLabel_Command(spec, "url"));
456 widget = makeValuePaddingWithHeading_(heading = makeHeading_Widget(label), 468 setSelectAllOnFocus_InputWidget(input, argLabel_Command(spec, "selectall"));
457 as_Widget(input)); 469 setFont_InputWidget(input, labelFont_());
470 if (argLabel_Command(spec, "noheading")) {
471 widget = makeValuePadding_(as_Widget(input));
472 setFlags_Widget(widget, expand_WidgetFlag, iTrue);
473 }
474 else {
475 setContentPadding_InputWidget(input, 3 * gap_UI, 0);
476 if (hasLabel_Command(spec, "unit")) {
477 iWidget *unit = addChildFlags_Widget(
478 as_Widget(input),
479 iClob(new_LabelWidget(
480 format_CStr("${%s}", cstr_Rangecc(range_Command(spec, "unit"))), NULL)),
481 frameless_WidgetFlag | moveToParentRightEdge_WidgetFlag |
482 resizeToParentHeight_WidgetFlag);
483 setContentPadding_InputWidget(input, -1, width_Widget(unit) - 4 * gap_UI);
484 }
485 widget = makeValuePaddingWithHeading_(heading = makeHeading_Widget(label),
486 as_Widget(input));
487 }
458 } 488 }
459 else if (equal_Command(spec, "padding")) { 489 else if (equal_Command(spec, "padding")) {
460 widget = makePadding_Widget(lineHeight_Text(labelFont_()) * 1.5f); 490 widget = makePadding_Widget(lineHeight_Text(labelFont_()) * 1.5f);