summaryrefslogtreecommitdiff
path: root/src/ui/mobile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/mobile.c')
-rw-r--r--src/ui/mobile.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/ui/mobile.c b/src/ui/mobile.c
index f3e23e06..daa1fa1a 100644
--- a/src/ui/mobile.c
+++ b/src/ui/mobile.c
@@ -498,16 +498,18 @@ void makePanelItem_Mobile(iWidget *panel, const iMenuItem *item) {
498 } 498 }
499 else if (equal_Command(spec, "button")) { 499 else if (equal_Command(spec, "button")) {
500 widget = as_Widget(heading = makePanelButton_(label, item->command)); 500 widget = as_Widget(heading = makePanelButton_(label, item->command));
501 setFlags_Widget(widget, selected_WidgetFlag, argLabel_Command(spec, "selected") != 0);
501 } 502 }
502 else if (equal_Command(spec, "label")) { 503 else if (equal_Command(spec, "label")) {
503 iLabelWidget *lab = new_LabelWidget(label, NULL); 504 iLabelWidget *lab = new_LabelWidget(label, NULL);
504 widget = as_Widget(lab); 505 widget = as_Widget(lab);
505 setWrap_LabelWidget(lab, iTrue); 506 setWrap_LabelWidget(lab, iTrue);
506 setFlags_Widget(widget, frameless_WidgetFlag, iTrue); 507 setFlags_Widget(widget, fixedHeight_WidgetFlag | frameless_WidgetFlag, iTrue);
507 } 508 }
508 else if (equal_Command(spec, "padding")) { 509 else if (equal_Command(spec, "padding")) {
509 widget = makePadding_Widget(lineHeight_Text(labelFont_()) * 1.5f); 510 widget = makePadding_Widget(lineHeight_Text(labelFont_()) * 1.5f);
510 } 511 }
512 /* Apply common styling to the heading. */
511 if (heading) { 513 if (heading) {
512 setRemoveTrailingColon_LabelWidget(heading, iTrue); 514 setRemoveTrailingColon_LabelWidget(heading, iTrue);
513 const iChar icon = toInt_String(string_Command(item->label, "icon")); 515 const iChar icon = toInt_String(string_Command(item->label, "icon"));
@@ -536,7 +538,7 @@ static const iMenuItem *findDialogCancelAction_(const iMenuItem *items, size_t n
536 if (n <= 1) { 538 if (n <= 1) {
537 return NULL; 539 return NULL;
538 } 540 }
539 for (size_t i = 0; i < n - 1; i++) { 541 for (size_t i = 0; i < n; i++) {
540 if (!iCmpStr(items[i].label, "${cancel}")) { 542 if (!iCmpStr(items[i].label, "${cancel}")) {
541 return &items[i]; 543 return &items[i];
542 } 544 }
@@ -547,6 +549,13 @@ static const iMenuItem *findDialogCancelAction_(const iMenuItem *items, size_t n
547iWidget *makePanels_Mobile(const char *id, 549iWidget *makePanels_Mobile(const char *id,
548 const iMenuItem *itemsNullTerminated, 550 const iMenuItem *itemsNullTerminated,
549 const iMenuItem *actions, size_t numActions) { 551 const iMenuItem *actions, size_t numActions) {
552 return makePanelsParent_Mobile(get_Root()->widget, id, itemsNullTerminated, actions, numActions);
553}
554
555iWidget *makePanelsParent_Mobile(iWidget *parentWidget,
556 const char *id,
557 const iMenuItem *itemsNullTerminated,
558 const iMenuItem *actions, size_t numActions) {
550 /* A multipanel widget has a top panel and one or more detail panels. In a horizontal layout, 559 /* A multipanel widget has a top panel and one or more detail panels. In a horizontal layout,
551 the detail panels slide in from the right and cover the top panel. In a landscape layout, 560 the detail panels slide in from the right and cover the top panel. In a landscape layout,
552 the detail panels are always visible on the side. */ 561 the detail panels are always visible on the side. */
@@ -637,7 +646,7 @@ iWidget *makePanels_Mobile(const char *id,
637 const iMenuItem *cancelItem = findDialogCancelAction_(actions, numActions); 646 const iMenuItem *cancelItem = findDialogCancelAction_(actions, numActions);
638 const iMenuItem *defaultItem = &actions[numActions - 1]; 647 const iMenuItem *defaultItem = &actions[numActions - 1];
639 iAssert(defaultItem); 648 iAssert(defaultItem);
640 if (!cancelItem) { 649 if (defaultItem && !cancelItem) {
641 updateTextCStr_LabelWidget(naviBack, defaultItem->label); 650 updateTextCStr_LabelWidget(naviBack, defaultItem->label);
642 setCommand_LabelWidget(naviBack, collectNewCStr_String(defaultItem->command)); 651 setCommand_LabelWidget(naviBack, collectNewCStr_String(defaultItem->command));
643 setFlags_Widget(as_Widget(naviBack), alignLeft_WidgetFlag, iFalse); 652 setFlags_Widget(as_Widget(naviBack), alignLeft_WidgetFlag, iFalse);
@@ -645,7 +654,7 @@ iWidget *makePanels_Mobile(const char *id,
645 setIcon_LabelWidget(naviBack, 0); 654 setIcon_LabelWidget(naviBack, 0);
646 setFont_LabelWidget(naviBack, labelBoldFont_()); 655 setFont_LabelWidget(naviBack, labelBoldFont_());
647 } 656 }
648 else { 657 else if (defaultItem && defaultItem != cancelItem) {
649 updateTextCStr_LabelWidget(naviBack, cancelItem->label); 658 updateTextCStr_LabelWidget(naviBack, cancelItem->label);
650 setCommand_LabelWidget(naviBack, collectNewCStr_String(cancelItem->command 659 setCommand_LabelWidget(naviBack, collectNewCStr_String(cancelItem->command
651 ? cancelItem->command 660 ? cancelItem->command
@@ -667,8 +676,12 @@ iWidget *makePanels_Mobile(const char *id,
667 if (act == cancelItem || act == defaultItem) { 676 if (act == cancelItem || act == defaultItem) {
668 continue; 677 continue;
669 } 678 }
670 if (!iCmpStr(act->label, "---")) { 679 const char *label = act->label;
671 continue; 680 if (*label == '*' || *label == '&') {
681 continue; /* Special value selection items for a Question dialog. */
682 }
683 if (!iCmpStr(label, "---")) {
684 continue; /* Separator. */
672 } 685 }
673 if (needPadding) { 686 if (needPadding) {
674 makePanelItem_Mobile(topPanel, &(iMenuItem){ "padding" }); 687 makePanelItem_Mobile(topPanel, &(iMenuItem){ "padding" });
@@ -680,7 +693,7 @@ iWidget *makePanels_Mobile(const char *id,
680 } 693 }
681 } 694 }
682 /* Finalize the layout. */ 695 /* Finalize the layout. */
683 addChild_Widget(sheet->root->widget, iClob(sheet)); 696 addChild_Widget(parentWidget, iClob(sheet));
684 mainDetailSplitHandler_(mainDetailSplit, "window.resized"); /* make it resize the split */ 697 mainDetailSplitHandler_(mainDetailSplit, "window.resized"); /* make it resize the split */
685 updatePanelSheetMetrics_(sheet); 698 updatePanelSheetMetrics_(sheet);
686 arrange_Widget(sheet); 699 arrange_Widget(sheet);