diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-21 13:48:34 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-21 13:48:34 +0300 |
commit | b19d76bcb518287e63c6808c6dc1418d349f4ff7 (patch) | |
tree | 85966a79b2c453a8a9ce344a08172e1356982e77 /src/ui/util.c | |
parent | 7fefd2ca4f1be52c1bef3bc87cc8972a57cab396 (diff) |
Mobile: Added Settings > About
Diffstat (limited to 'src/ui/util.c')
-rw-r--r-- | src/ui/util.c | 83 |
1 files changed, 57 insertions, 26 deletions
diff --git a/src/ui/util.c b/src/ui/util.c index fb12dd7c..8e808bd2 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -1070,10 +1070,9 @@ static iBool slidePanelHandler_(iWidget *d, const char *cmd) { | |||
1070 | } | 1070 | } |
1071 | return iTrue; | 1071 | return iTrue; |
1072 | } | 1072 | } |
1073 | if (equal_Command(cmd, "panel.showhelp")) { | 1073 | if (equal_Command(cmd, "document.changed")) { |
1074 | postCommand_App("prefs.dismiss"); | 1074 | postCommand_App("prefs.dismiss"); |
1075 | postCommand_App("open url:about:help"); | 1075 | return iFalse; |
1076 | return iTrue; | ||
1077 | } | 1076 | } |
1078 | if (equal_Command(cmd, "window.resized")) { | 1077 | if (equal_Command(cmd, "window.resized")) { |
1079 | updateSheetPanelMetrics_(parent_Widget(d)); | 1078 | updateSheetPanelMetrics_(parent_Widget(d)); |
@@ -1219,6 +1218,30 @@ static iWidget *makeValuePaddingWithHeading_(iLabelWidget *heading, iWidget *val | |||
1219 | return div; | 1218 | return div; |
1220 | } | 1219 | } |
1221 | 1220 | ||
1221 | static iWidget *addChildPanel_(iWidget *sheet, iLabelWidget *panelButton, | ||
1222 | const iString *titleText) { | ||
1223 | iWidget *owner = new_Widget(); | ||
1224 | setId_Widget(owner, "panel"); | ||
1225 | setUserData_Object(panelButton, owner); | ||
1226 | setBackgroundColor_Widget(owner, uiBackground_ColorId); | ||
1227 | setId_Widget(addChild_Widget(owner, iClob(makePadding_Widget(0))), "panel.toppad"); | ||
1228 | if (titleText) { | ||
1229 | iLabelWidget *title = | ||
1230 | addChildFlags_Widget(owner, | ||
1231 | iClob(new_LabelWidget(cstr_String(titleText), NULL)), | ||
1232 | alignLeft_WidgetFlag | frameless_WidgetFlag); | ||
1233 | setFont_LabelWidget(title, uiLabelLargeBold_FontId); | ||
1234 | setTextColor_LabelWidget(title, uiHeading_ColorId); | ||
1235 | } | ||
1236 | addChildFlags_Widget(sheet, | ||
1237 | iClob(owner), | ||
1238 | focusRoot_WidgetFlag | hidden_WidgetFlag | disabled_WidgetFlag | | ||
1239 | arrangeVertical_WidgetFlag | resizeWidthOfChildren_WidgetFlag | | ||
1240 | arrangeHeight_WidgetFlag | overflowScrollable_WidgetFlag | | ||
1241 | horizontalOffset_WidgetFlag | commandOnClick_WidgetFlag); | ||
1242 | return owner; | ||
1243 | } | ||
1244 | |||
1222 | void finalizeSheet_Widget(iWidget *sheet) { | 1245 | void finalizeSheet_Widget(iWidget *sheet) { |
1223 | /* The sheet contents are completely rearranged and restyled on a phone. | 1246 | /* The sheet contents are completely rearranged and restyled on a phone. |
1224 | We'll set up a linear fullscreen arrangement of the widgets. Sheets are already | 1247 | We'll set up a linear fullscreen arrangement of the widgets. Sheets are already |
@@ -1317,31 +1340,14 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
1317 | if (useSlidePanels) { | 1340 | if (useSlidePanels) { |
1318 | /* Create a new child panel. */ | 1341 | /* Create a new child panel. */ |
1319 | iLabelWidget *button = at_PtrArray(panelButtons, index_PtrArrayIterator(&j)); | 1342 | iLabelWidget *button = at_PtrArray(panelButtons, index_PtrArrayIterator(&j)); |
1320 | owner = new_Widget(); | 1343 | owner = addChildPanel_(sheet, button, |
1321 | setId_Widget(owner, "panel"); | 1344 | collect_String(upper_String(text_LabelWidget(button)))); |
1322 | setUserData_Object(button, owner); | ||
1323 | setBackgroundColor_Widget(owner, uiBackground_ColorId); | ||
1324 | setId_Widget(addChild_Widget(owner, iClob(makePadding_Widget(0))), "panel.toppad"); | ||
1325 | iLabelWidget *title = addChildFlags_Widget(owner, | ||
1326 | iClob(new_LabelWidget(cstrCollect_String(upper_String(text_LabelWidget(button))), NULL)), alignLeft_WidgetFlag | frameless_WidgetFlag); | ||
1327 | setFont_LabelWidget(title, uiLabelLargeBold_FontId); | ||
1328 | setTextColor_LabelWidget(title, uiHeading_ColorId); | ||
1329 | addChildFlags_Widget(sheet, | ||
1330 | iClob(owner), | ||
1331 | focusRoot_WidgetFlag | | ||
1332 | hidden_WidgetFlag | | ||
1333 | disabled_WidgetFlag | | ||
1334 | arrangeVertical_WidgetFlag | | ||
1335 | resizeWidthOfChildren_WidgetFlag | | ||
1336 | arrangeHeight_WidgetFlag | | ||
1337 | overflowScrollable_WidgetFlag | | ||
1338 | horizontalOffset_WidgetFlag | | ||
1339 | commandOnClick_WidgetFlag); | ||
1340 | } | 1345 | } |
1341 | iWidget *pageContent = j.ptr; | 1346 | iWidget *pageContent = j.ptr; |
1342 | iWidget *headings = child_Widget(pageContent, 0); | 1347 | iWidget *headings = child_Widget(pageContent, 0); |
1343 | iWidget *values = child_Widget(pageContent, 1); | 1348 | iWidget *values = child_Widget(pageContent, 1); |
1344 | enum iPrefsElement prevElement = panelTitle_PrefsElement; | 1349 | enum iPrefsElement prevElement = panelTitle_PrefsElement; |
1350 | /* Identify the types of controls in the dialog and restyle/organize them. */ | ||
1345 | while (!isEmpty_ObjectList(children_Widget(headings))) { | 1351 | while (!isEmpty_ObjectList(children_Widget(headings))) { |
1346 | iWidget *heading = child_Widget(headings, 0); | 1352 | iWidget *heading = child_Widget(headings, 0); |
1347 | iWidget *value = child_Widget(values, 0); | 1353 | iWidget *value = child_Widget(values, 0); |
@@ -1455,11 +1461,36 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
1455 | if (isPrefs) { | 1461 | if (isPrefs) { |
1456 | addChild_Widget(topPanel, iClob(makePadding_Widget(lineHeight_Text(defaultBig_FontId)))); | 1462 | addChild_Widget(topPanel, iClob(makePadding_Widget(lineHeight_Text(defaultBig_FontId)))); |
1457 | addChildFlags_Widget(topPanel, | 1463 | addChildFlags_Widget(topPanel, |
1458 | iClob(makePanelButton_(info_Icon " ${menu.help}", "panel.showhelp")), | 1464 | iClob(makePanelButton_(info_Icon " ${menu.help}", "!open url:about:help")), |
1459 | borderTop_WidgetFlag); | 1465 | borderTop_WidgetFlag); |
1460 | addChildFlags_Widget(topPanel, | 1466 | iLabelWidget *aboutButton = addChildFlags_Widget(topPanel, |
1461 | iClob(makePanelButton_(planet_Icon " ${menu.about}", "panel.about")), | 1467 | iClob(makePanelButton_(planet_Icon " ${menu.about}", "panel.open")), |
1462 | chevron_WidgetFlag); | 1468 | chevron_WidgetFlag); |
1469 | /* The About panel. */ { | ||
1470 | iWidget *panel = addChildPanel_(sheet, aboutButton, NULL); | ||
1471 | iString *msg = collectNew_String(); | ||
1472 | setCStr_String(msg, "Lagrange " LAGRANGE_APP_VERSION); | ||
1473 | #if defined (iPlatformAppleMobile) | ||
1474 | appendCStr_String(msg, " (" LAGRANGE_IOS_VERSION ")"); | ||
1475 | #endif | ||
1476 | addChild_Widget(panel, iClob(new_LabelWidget(cstr_String(msg), NULL))); | ||
1477 | addChildFlags_Widget(panel, | ||
1478 | iClob(makePanelButton_(globe_Icon " By @jk@skyjake.fi", | ||
1479 | "!open url:https://skyjake.fi/@jk")), | ||
1480 | borderTop_WidgetFlag); | ||
1481 | addChildFlags_Widget(panel, | ||
1482 | iClob(makePanelButton_(clock_Icon " ${menu.releasenotes}", | ||
1483 | "!open url:about:version")), | ||
1484 | 0); | ||
1485 | addChildFlags_Widget(panel, | ||
1486 | iClob(makePanelButton_(info_Icon " ${menu.aboutpages}", | ||
1487 | "!open url:about:about")), | ||
1488 | 0); | ||
1489 | addChildFlags_Widget(panel, | ||
1490 | iClob(makePanelButton_(bug_Icon " ${menu.debug}", | ||
1491 | "!open url:about:debug")), | ||
1492 | 0); | ||
1493 | } | ||
1463 | } | 1494 | } |
1464 | else { | 1495 | else { |
1465 | setFlags_Widget(topPanel, overflowScrollable_WidgetFlag, iTrue); | 1496 | setFlags_Widget(topPanel, overflowScrollable_WidgetFlag, iTrue); |