summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/labelwidget.h7
-rw-r--r--src/ui/sidebarwidget.c3
-rw-r--r--src/ui/util.c75
-rw-r--r--src/ui/widget.c3
-rw-r--r--src/ui/widget.h4
-rw-r--r--src/ui/window.c8
-rw-r--r--src/ui/window.h1
7 files changed, 79 insertions, 22 deletions
diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h
index 7a1d4de8..3e3c76fb 100644
--- a/src/ui/labelwidget.h
+++ b/src/ui/labelwidget.h
@@ -51,6 +51,13 @@ iChar icon_LabelWidget (const iLabelWidget *);
51iLabelWidget *newKeyMods_LabelWidget(const char *label, int key, int kmods, const char *command); 51iLabelWidget *newKeyMods_LabelWidget(const char *label, int key, int kmods, const char *command);
52iLabelWidget *newColor_LabelWidget (const char *text, int color); 52iLabelWidget *newColor_LabelWidget (const char *text, int color);
53 53
54iLocalDef iLabelWidget *newFont_LabelWidget(const char *label, const char *command, int fontId) {
55 iLabelWidget *d = new_LabelWidget(label, command);
56 checkIcon_LabelWidget(d);
57 setFont_LabelWidget(d, fontId);
58 return d;
59}
60
54iLocalDef iLabelWidget *newEmpty_LabelWidget(void) { 61iLocalDef iLabelWidget *newEmpty_LabelWidget(void) {
55 return new_LabelWidget("", NULL); 62 return new_LabelWidget("", NULL);
56} 63}
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index c2cfe998..8da09b2f 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -547,7 +547,7 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) {
547 iLabelWidget *heading = new_LabelWidget("Identities", NULL); 547 iLabelWidget *heading = new_LabelWidget("Identities", NULL);
548 setBackgroundColor_Widget(as_Widget(heading), uiBackgroundUnfocusedSelection_ColorId); 548 setBackgroundColor_Widget(as_Widget(heading), uiBackgroundUnfocusedSelection_ColorId);
549 setTextColor_LabelWidget(heading, uiIcon_ColorId); 549 setTextColor_LabelWidget(heading, uiIcon_ColorId);
550 setFont_LabelWidget(addChild_Widget(vdiv, iClob(heading)), 550 setFont_LabelWidget(addChildFlags_Widget(vdiv, iClob(heading), frameless_WidgetFlag),
551 uiLabelLarge_FontId); 551 uiLabelLarge_FontId);
552 } 552 }
553 iWidget *content = new_Widget(); 553 iWidget *content = new_Widget();
@@ -622,6 +622,7 @@ static void itemClicked_SidebarWidget_(iSidebarWidget *d, const iSidebarItem *it
622 const iGmDocument *doc = document_DocumentWidget(document_App()); 622 const iGmDocument *doc = document_DocumentWidget(document_App());
623 const iGmHeading *head = constAt_Array(headings_GmDocument(doc), item->id); 623 const iGmHeading *head = constAt_Array(headings_GmDocument(doc), item->id);
624 postCommandf_App("document.goto loc:%p", head->text.start); 624 postCommandf_App("document.goto loc:%p", head->text.start);
625 dismissPortraitPhoneSidebars_Window(get_Window());
625 break; 626 break;
626 } 627 }
627 case feeds_SidebarMode: { 628 case feeds_SidebarMode: {
diff --git a/src/ui/util.c b/src/ui/util.c
index 47cd3ccd..0d34658e 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -528,7 +528,7 @@ void openMenu_Widget(iWidget *d, iInt2 coord) {
528 setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iFalse); 528 setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iFalse);
529 if (isPortraitPhone) { 529 if (isPortraitPhone) {
530 setFlags_Widget(d, arrangeWidth_WidgetFlag | resizeChildrenToWidestChild_WidgetFlag, iFalse); 530 setFlags_Widget(d, arrangeWidth_WidgetFlag | resizeChildrenToWidestChild_WidgetFlag, iFalse);
531 setFlags_Widget(d, resizeWidthOfChildren_WidgetFlag, iTrue); 531 setFlags_Widget(d, resizeWidthOfChildren_WidgetFlag | drawBackgroundToBottom_WidgetFlag, iTrue);
532 if (!isSlidePanel) { 532 if (!isSlidePanel) {
533 setFlags_Widget(d, borderTop_WidgetFlag, iTrue); 533 setFlags_Widget(d, borderTop_WidgetFlag, iTrue);
534 } 534 }
@@ -912,6 +912,25 @@ static iBool slidePanelHandler_(iWidget *d, const char *cmd) {
912 postCommand_App("panel.close"); 912 postCommand_App("panel.close");
913 return iTrue; 913 return iTrue;
914 } 914 }
915 if (equal_Command(cmd, "window.resized")) {
916 iWidget *sheet = parent_Widget(d);
917#if defined (iPlatformAppleMobile)
918 float left, top, right, bottom;
919 safeAreaInsets_iOS(&left, &top, &right, &bottom);
920 /* TODO: incorrect */
921 if (isLandscape_App()) {
922 setPadding_Widget(sheet, left, 0, right, 0);
923 }
924 else {
925 setPadding1_Widget(sheet, 0);
926 }
927#endif
928 }
929 if (equal_Command(cmd, "panel.showhelp")) {
930 postCommand_App("prefs.dismiss");
931 postCommand_App("open url:about:help");
932 return iTrue;
933 }
915 if (equal_Command(cmd, "panel.close")) { 934 if (equal_Command(cmd, "panel.close")) {
916 iBool wasClosed = iFalse; 935 iBool wasClosed = iFalse;
917 iForEach(ObjectList, i, children_Widget(parent_Widget(d))) { 936 iForEach(ObjectList, i, children_Widget(parent_Widget(d))) {
@@ -975,9 +994,9 @@ static iAnyObject *addPanelChild_(iWidget *panel, iAnyObject *child, int64_t fla
975 /* Erase redundant/unused headings. */ 994 /* Erase redundant/unused headings. */
976 if (precedingElementType == heading_PrefsElement && 995 if (precedingElementType == heading_PrefsElement &&
977 (!child || elementType == heading_PrefsElement)) { 996 (!child || elementType == heading_PrefsElement)) {
978 iRelease(removeChild_Widget(panel, back_ObjectList(children_Widget(panel)))); 997 iRelease(removeChild_Widget(panel, lastChild_Widget(panel)));
979 if (!cmp_String(id_Widget(constAs_Widget(back_ObjectList(children_Widget(panel)))), "padding")) { 998 if (!cmp_String(id_Widget(constAs_Widget(lastChild_Widget(panel))), "padding")) {
980 iRelease(removeChild_Widget(panel, back_ObjectList(children_Widget(panel)))); 999 iRelease(removeChild_Widget(panel, lastChild_Widget(panel)));
981 } 1000 }
982 } 1001 }
983 if (child) { 1002 if (child) {
@@ -1009,6 +1028,18 @@ static void stripTrailingColon_(iLabelWidget *label) {
1009 } 1028 }
1010} 1029}
1011 1030
1031static iLabelWidget *makePanelButton_(const char *text, const char *command) {
1032 iLabelWidget *btn = new_LabelWidget(text, command);
1033 setFlags_Widget(as_Widget(btn),
1034 borderBottom_WidgetFlag | alignLeft_WidgetFlag |
1035 frameless_WidgetFlag | extraPadding_WidgetFlag,
1036 iTrue);
1037 checkIcon_LabelWidget(btn);
1038 setFont_LabelWidget(btn, defaultBig_FontId);
1039 setBackgroundColor_Widget(as_Widget(btn), uiBackgroundSidebar_ColorId);
1040 return btn;
1041}
1042
1012void finalizeSheet_Widget(iWidget *sheet) { 1043void finalizeSheet_Widget(iWidget *sheet) {
1013 if (deviceType_App() == phone_AppDeviceType) { 1044 if (deviceType_App() == phone_AppDeviceType) {
1014 /* The sheet contents are completely rearranged on a phone. We'll set up a linear 1045 /* The sheet contents are completely rearranged on a phone. We'll set up a linear
@@ -1043,12 +1074,16 @@ void finalizeSheet_Widget(iWidget *sheet) {
1043 frameless_WidgetFlag | 1074 frameless_WidgetFlag |
1044 resizeWidthOfChildren_WidgetFlag, 1075 resizeWidthOfChildren_WidgetFlag,
1045 iTrue); 1076 iTrue);
1046 setBackgroundColor_Widget(sheet, green_ColorId); 1077 setBackgroundColor_Widget(sheet, uiBackground_ColorId);
1047 iPtrArray *contents = collect_PtrArray(new_PtrArray()); /* two-column pages */ 1078 iPtrArray *contents = collect_PtrArray(new_PtrArray()); /* two-column pages */
1048 iPtrArray *panelButtons = collect_PtrArray(new_PtrArray()); 1079 iPtrArray *panelButtons = collect_PtrArray(new_PtrArray());
1049 iWidget *tabs = findChild_Widget(sheet, "prefs.tabs"); 1080 iWidget *tabs = findChild_Widget(sheet, "prefs.tabs");
1081 const iBool isPrefs = (tabs != NULL);
1082 const int64_t panelButtonFlags = borderBottom_WidgetFlag | alignLeft_WidgetFlag |
1083 frameless_WidgetFlag | extraPadding_WidgetFlag;
1050 iWidget *topPanel = new_Widget(); 1084 iWidget *topPanel = new_Widget();
1051 setId_Widget(topPanel, "panel.top"); 1085 setId_Widget(topPanel, "panel.top");
1086 addChild_Widget(topPanel, iClob(makePadding_Widget(lineHeight_Text(defaultBig_FontId))));
1052 if (tabs) { 1087 if (tabs) {
1053 iRelease(removeChild_Widget(sheet, child_Widget(sheet, 0))); /* heading */ 1088 iRelease(removeChild_Widget(sheet, child_Widget(sheet, 0))); /* heading */
1054 iRelease(removeChild_Widget(sheet, findChild_Widget(sheet, "dialogbuttons"))); 1089 iRelease(removeChild_Widget(sheet, findChild_Widget(sheet, "dialogbuttons")));
@@ -1063,22 +1098,21 @@ void finalizeSheet_Widget(iWidget *sheet) {
1063 iLabelWidget *panelButton; 1098 iLabelWidget *panelButton;
1064 pushBack_PtrArray(panelButtons, 1099 pushBack_PtrArray(panelButtons,
1065 addChildFlags_Widget(topPanel, 1100 addChildFlags_Widget(topPanel,
1066 iClob(panelButton = new_LabelWidget 1101 iClob(panelButton = makePanelButton_(
1067 (i == 1 ? "User Interface" : cstr_String(text), 1102 i == 1 ? "User Interface" : cstr_String(text),
1068 "panel.open")), 1103 "panel.open")),
1069 alignLeft_WidgetFlag | frameless_WidgetFlag | 1104 (i == 0 ? borderTop_WidgetFlag : 0) |
1070 borderBottom_WidgetFlag | extraPadding_WidgetFlag |
1071 chevron_WidgetFlag)); 1105 chevron_WidgetFlag));
1072 const iChar icons[] = { 1106 const iChar icons[] = {
1073 0x2699, /* gear */ 1107 0x02699, /* gear */
1074 0x1f4f1, /* mobile phone */ 1108 0x1f4f1, /* mobile phone */
1075 0x1f3a8, /* palette */ 1109 0x1f3a8, /* palette */
1076 0x1f523, 1110 0x1f523,
1077 0x1f5a7, /* computer network */ 1111 0x1f5a7, /* computer network */
1078 }; 1112 };
1079 setIcon_LabelWidget(panelButton, icons[i]); 1113 setIcon_LabelWidget(panelButton, icons[i]);
1080 setFont_LabelWidget(panelButton, defaultBig_FontId); 1114// setFont_LabelWidget(panelButton, defaultBig_FontId);
1081 setBackgroundColor_Widget(as_Widget(panelButton), uiBackgroundSidebar_ColorId); 1115// setBackgroundColor_Widget(as_Widget(panelButton), uiBackgroundSidebar_ColorId);
1082 iRelease(page); 1116 iRelease(page);
1083 delete_String(text); 1117 delete_String(text);
1084 } 1118 }
@@ -1259,9 +1293,19 @@ void finalizeSheet_Widget(iWidget *sheet) {
1259 } 1293 }
1260 addPanelChild_(owner, NULL, 0, 0, prevElement); 1294 addPanelChild_(owner, NULL, 0, 0, prevElement);
1261 destroy_Widget(pageContent); 1295 destroy_Widget(pageContent);
1262 addChildFlags_Widget(owner, iClob(new_Widget()), expand_WidgetFlag); 1296 setFlags_Widget(owner, drawBackgroundToBottom_WidgetFlag, iTrue);
1263 } 1297 }
1264 destroyPending_Widget(); 1298 destroyPending_Widget();
1299 /* Additional elements for preferences. */
1300 if (isPrefs) {
1301 addChild_Widget(topPanel, iClob(makePadding_Widget(lineHeight_Text(defaultBig_FontId))));
1302 addChildFlags_Widget(topPanel,
1303 iClob(makePanelButton_(info_Icon " Help", "panel.showhelp")),
1304 borderTop_WidgetFlag);
1305 addChildFlags_Widget(topPanel,
1306 iClob(makePanelButton_(planet_Icon " About", "panel.about")),
1307 chevron_WidgetFlag);
1308 }
1265 /* Navbar. */ { 1309 /* Navbar. */ {
1266 iWidget *navi = new_Widget(); 1310 iWidget *navi = new_Widget();
1267 setSize_Widget(navi, init_I2(-1, navBarHeight)); 1311 setSize_Widget(navi, init_I2(-1, navBarHeight));
@@ -1276,8 +1320,7 @@ void finalizeSheet_Widget(iWidget *sheet) {
1276 setFont_LabelWidget(back, defaultBig_FontId); 1320 setFont_LabelWidget(back, defaultBig_FontId);
1277 addChildFlags_Widget(sheet, iClob(navi), 1321 addChildFlags_Widget(sheet, iClob(navi),
1278 arrangeHeight_WidgetFlag | resizeWidthOfChildren_WidgetFlag | 1322 arrangeHeight_WidgetFlag | resizeWidthOfChildren_WidgetFlag |
1279 resizeToParentWidth_WidgetFlag | arrangeVertical_WidgetFlag | 1323 resizeToParentWidth_WidgetFlag | arrangeVertical_WidgetFlag);
1280 borderBottom_WidgetFlag);
1281 } 1324 }
1282 arrange_Widget(sheet->parent); 1325 arrange_Widget(sheet->parent);
1283 printTree_Widget(sheet); 1326 printTree_Widget(sheet);
diff --git a/src/ui/widget.c b/src/ui/widget.c
index b31b3c08..4dd545b5 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -776,6 +776,9 @@ void drawBackground_Widget(const iWidget *d) {
776 } 776 }
777 if (d->bgColor >= 0 || d->frameColor >= 0) { 777 if (d->bgColor >= 0 || d->frameColor >= 0) {
778 iRect rect = bounds_Widget(d); 778 iRect rect = bounds_Widget(d);
779 if (d->flags & drawBackgroundToBottom_WidgetFlag) {
780 rect.size.y = rootSize_Window(get_Window()).y - top_Rect(rect);
781 }
779 iPaint p; 782 iPaint p;
780 init_Paint(&p); 783 init_Paint(&p);
781 if (d->bgColor >= 0) { 784 if (d->bgColor >= 0) {
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 4b1f42d3..3edcb3f4 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -105,6 +105,7 @@ enum iWidgetFlag {
105#define borderBottom_WidgetFlag iBit64(50) 105#define borderBottom_WidgetFlag iBit64(50)
106#define horizontalOffset_WidgetFlag iBit64(51) /* default is vertical offset */ 106#define horizontalOffset_WidgetFlag iBit64(51) /* default is vertical offset */
107#define chevron_WidgetFlag iBit64(52) 107#define chevron_WidgetFlag iBit64(52)
108#define drawBackgroundToBottom_WidgetFlag iBit64(53)
108 109
109enum iWidgetAddPos { 110enum iWidgetAddPos {
110 back_WidgetAddPos, 111 back_WidgetAddPos,
@@ -196,6 +197,9 @@ iLocalDef iWidget *parent_Widget(const iAnyObject *d) {
196 } 197 }
197 return NULL; 198 return NULL;
198} 199}
200iLocalDef iWidget *lastChild_Widget(iAnyObject *d) {
201 return (iWidget *) back_ObjectList(children_Widget(d));
202}
199 203
200iBool isVisible_Widget (const iAnyObject *); 204iBool isVisible_Widget (const iAnyObject *);
201iBool isDisabled_Widget (const iAnyObject *); 205iBool isDisabled_Widget (const iAnyObject *);
diff --git a/src/ui/window.c b/src/ui/window.c
index af9b20ba..637174b4 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -225,8 +225,6 @@ static const iMenuItem phoneNavMenuItems_[] = {
225 { "List Feed Entries", 0, 0, "!open url:about:feeds" }, 225 { "List Feed Entries", 0, 0, "!open url:about:feeds" },
226 { "---", 0, 0, NULL }, 226 { "---", 0, 0, NULL },
227 { gear_Icon " Settings...", SDLK_COMMA, KMOD_PRIMARY, "preferences" }, 227 { gear_Icon " Settings...", SDLK_COMMA, KMOD_PRIMARY, "preferences" },
228 { "Help", SDLK_F1, 0, "!open url:about:help" },
229 { "Release Notes", 0, 0, "!open url:about:version" },
230}; 228};
231#endif /* AppleMobile */ 229#endif /* AppleMobile */
232#endif 230#endif
@@ -466,7 +464,7 @@ static void updatePadding_Window_(iWindow *d) {
466#endif 464#endif
467} 465}
468 466
469static void dismissPortraitPhoneSidebars_(void) { 467void dismissPortraitPhoneSidebars_Window(iWindow *d) {
470 if (deviceType_App() == phone_AppDeviceType && isPortrait_App()) { 468 if (deviceType_App() == phone_AppDeviceType && isPortrait_App()) {
471 iWidget *sidebar = findWidget_App("sidebar"); 469 iWidget *sidebar = findWidget_App("sidebar");
472 iWidget *sidebar2 = findWidget_App("sidebar2"); 470 iWidget *sidebar2 = findWidget_App("sidebar2");
@@ -621,7 +619,7 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
621 postCommand_App("visited.changed"); /* sidebar will update */ 619 postCommand_App("visited.changed"); /* sidebar will update */
622 setText_InputWidget(url, urlStr); 620 setText_InputWidget(url, urlStr);
623 checkLoadAnimation_Window_(get_Window()); 621 checkLoadAnimation_Window_(get_Window());
624 dismissPortraitPhoneSidebars_(); 622 dismissPortraitPhoneSidebars_Window(get_Window());
625 updateNavBarIdentity_(navBar); 623 updateNavBarIdentity_(navBar);
626 /* Icon updates should be limited to automatically chosen icons if the user 624 /* Icon updates should be limited to automatically chosen icons if the user
627 is allowed to pick their own in the future. */ 625 is allowed to pick their own in the future. */
@@ -639,7 +637,7 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
639 iInputWidget *url = findChild_Widget(navBar, "url"); 637 iInputWidget *url = findChild_Widget(navBar, "url");
640 setTextCStr_InputWidget(url, suffixPtr_Command(cmd, "url")); 638 setTextCStr_InputWidget(url, suffixPtr_Command(cmd, "url"));
641 checkLoadAnimation_Window_(get_Window()); 639 checkLoadAnimation_Window_(get_Window());
642 dismissPortraitPhoneSidebars_(); 640 dismissPortraitPhoneSidebars_Window(get_Window());
643 return iFalse; 641 return iFalse;
644 } 642 }
645 } 643 }
diff --git a/src/ui/window.h b/src/ui/window.h
index dc865277..2ab5d990 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -89,6 +89,7 @@ void setFreezeDraw_Window (iWindow *, iBool freezeDraw);
89void setCursor_Window (iWindow *, int cursor); 89void setCursor_Window (iWindow *, int cursor);
90void setSnap_Window (iWindow *, int snapMode); 90void setSnap_Window (iWindow *, int snapMode);
91void setKeyboardHeight_Window(iWindow *, int height); 91void setKeyboardHeight_Window(iWindow *, int height);
92void dismissPortraitPhoneSidebars_Window (iWindow *);
92 93
93uint32_t id_Window (const iWindow *); 94uint32_t id_Window (const iWindow *);
94iInt2 rootSize_Window (const iWindow *); 95iInt2 rootSize_Window (const iWindow *);