summaryrefslogtreecommitdiff
path: root/src/ui/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/util.c')
-rw-r--r--src/ui/util.c83
1 files changed, 67 insertions, 16 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index fe35031b..e653b58c 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -837,7 +837,7 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, iBool postCommands) {
837 if (postCommands) { 837 if (postCommands) {
838 postCommand_Widget(d, "menu.opened"); 838 postCommand_Widget(d, "menu.opened");
839 } 839 }
840 if (isPortraitPhone) { 840 if (deviceType_App() == phone_AppDeviceType) {
841 setVisualOffset_Widget(d, isSlidePanel ? width_Widget(d) : height_Widget(d), 0, 0); 841 setVisualOffset_Widget(d, isSlidePanel ? width_Widget(d) : height_Widget(d), 0, 0);
842 setVisualOffset_Widget(d, 0, 330, easeOut_AnimFlag | softer_AnimFlag); 842 setVisualOffset_Widget(d, 0, 330, easeOut_AnimFlag | softer_AnimFlag);
843 } 843 }
@@ -851,7 +851,7 @@ void closeMenu_Widget(iWidget *d) {
851 setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iTrue); 851 setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iTrue);
852 postRefresh_App(); 852 postRefresh_App();
853 postCommand_Widget(d, "menu.closed"); 853 postCommand_Widget(d, "menu.closed");
854 if (isPortrait_App() && deviceType_App() == phone_AppDeviceType) { 854 if (deviceType_App() == phone_AppDeviceType) {
855 const iBool wasDragged = iAbs(value_Anim(&d->visualOffset) - 0) > 1; 855 const iBool wasDragged = iAbs(value_Anim(&d->visualOffset) - 0) > 1;
856 setVisualOffset_Widget(d, 856 setVisualOffset_Widget(d,
857 flags_Widget(d) & horizontalOffset_WidgetFlag ? 857 flags_Widget(d) & horizontalOffset_WidgetFlag ?
@@ -1206,7 +1206,13 @@ static iBool slidePanelHandler_(iWidget *d, const char *cmd) {
1206 iWidget *panel = userData_Object(button); 1206 iWidget *panel = userData_Object(button);
1207 openMenu_Widget(panel, innerToWindow_Widget(panel, zero_I2())); 1207 openMenu_Widget(panel, innerToWindow_Widget(panel, zero_I2()));
1208 setFlags_Widget(panel, disabled_WidgetFlag, iFalse); 1208 setFlags_Widget(panel, disabled_WidgetFlag, iFalse);
1209// updateTextCStr_LabelWidget(findWidget_App("panel.back"), ); 1209 /*
1210 if (deviceType_App() == phone_AppDeviceType && isPortrait_App()) {
1211 setFlags_Widget(d, visualOffset_WidgetFlag | horizontalOffset_WidgetFlag, iTrue);
1212 d->visualOffset = panel->visualOffset;
1213 d->visualOffset.to = -d->visualOffset.from / 3;
1214 d->visualOffset.from = 0;
1215 }*/
1210 return iTrue; 1216 return iTrue;
1211 } 1217 }
1212 if (equal_Command(cmd, "mouse.clicked") && arg_Command(cmd) && 1218 if (equal_Command(cmd, "mouse.clicked") && arg_Command(cmd) &&
@@ -1220,6 +1226,13 @@ static iBool slidePanelHandler_(iWidget *d, const char *cmd) {
1220 iWidget *child = i.object; 1226 iWidget *child = i.object;
1221 if (!cmp_String(id_Widget(child), "panel") && isVisible_Widget(child)) { 1227 if (!cmp_String(id_Widget(child), "panel") && isVisible_Widget(child)) {
1222 closeMenu_Widget(child); 1228 closeMenu_Widget(child);
1229 /*
1230 if (deviceType_App() == phone_AppDeviceType && isPortrait_App()) {
1231 setFlags_Widget(d, visualOffset_WidgetFlag | horizontalOffset_WidgetFlag, iTrue);
1232 d->visualOffset = child->visualOffset;
1233 d->visualOffset.from = -d->visualOffset.to / 3;
1234 d->visualOffset.to = 0;
1235 }*/
1223 setFlags_Widget(child, disabled_WidgetFlag, iTrue); 1236 setFlags_Widget(child, disabled_WidgetFlag, iTrue);
1224 setFocus_Widget(NULL); 1237 setFocus_Widget(NULL);
1225 updateTextCStr_LabelWidget(findWidget_App("panel.back"), "Back"); 1238 updateTextCStr_LabelWidget(findWidget_App("panel.back"), "Back");
@@ -1373,6 +1386,15 @@ static iWidget *makeValuePaddingWithHeading_(iLabelWidget *heading, iWidget *val
1373 if (isInstance_Object(value, &Class_InputWidget)) { 1386 if (isInstance_Object(value, &Class_InputWidget)) {
1374 addChildFlags_Widget(div, iClob(value), expand_WidgetFlag); 1387 addChildFlags_Widget(div, iClob(value), expand_WidgetFlag);
1375 } 1388 }
1389 else if (isInstance_Object(value, &Class_LabelWidget) &&
1390 cmp_String(command_LabelWidget((iLabelWidget *) value), "toggle")) {
1391 addChildFlags_Widget(div, iClob(value), expand_WidgetFlag);
1392 /* TODO: This doesn't work? */
1393// setCommand_LabelWidget(heading,
1394// collectNewFormat_String("!%s ptr:%p",
1395// cstr_String(command_LabelWidget((iLabelWidget *) value)),
1396// value));
1397 }
1376 else { 1398 else {
1377 addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); 1399 addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag);
1378 addChild_Widget(div, iClob(value)); 1400 addChild_Widget(div, iClob(value));
@@ -1400,7 +1422,8 @@ static iWidget *addChildPanel_(iWidget *sheet, iLabelWidget *panelButton,
1400 focusRoot_WidgetFlag | hidden_WidgetFlag | disabled_WidgetFlag | 1422 focusRoot_WidgetFlag | hidden_WidgetFlag | disabled_WidgetFlag |
1401 arrangeVertical_WidgetFlag | resizeWidthOfChildren_WidgetFlag | 1423 arrangeVertical_WidgetFlag | resizeWidthOfChildren_WidgetFlag |
1402 arrangeHeight_WidgetFlag | overflowScrollable_WidgetFlag | 1424 arrangeHeight_WidgetFlag | overflowScrollable_WidgetFlag |
1403 horizontalOffset_WidgetFlag | commandOnClick_WidgetFlag); 1425 horizontalOffset_WidgetFlag | edgeDraggable_WidgetFlag |
1426 commandOnClick_WidgetFlag);
1404 return owner; 1427 return owner;
1405} 1428}
1406 1429
@@ -1433,7 +1456,8 @@ void finalizeSheet_Widget(iWidget *sheet) {
1433 setFlags_Widget(sheet, 1456 setFlags_Widget(sheet,
1434 commandOnClick_WidgetFlag | 1457 commandOnClick_WidgetFlag |
1435 frameless_WidgetFlag | 1458 frameless_WidgetFlag |
1436 resizeWidthOfChildren_WidgetFlag, 1459 resizeWidthOfChildren_WidgetFlag |
1460 edgeDraggable_WidgetFlag,
1437 iTrue); 1461 iTrue);
1438 iPtrArray * contents = collect_PtrArray(new_PtrArray()); /* two-column pages */ 1462 iPtrArray * contents = collect_PtrArray(new_PtrArray()); /* two-column pages */
1439 iPtrArray * panelButtons = collect_PtrArray(new_PtrArray()); 1463 iPtrArray * panelButtons = collect_PtrArray(new_PtrArray());
@@ -1443,6 +1467,7 @@ void finalizeSheet_Widget(iWidget *sheet) {
1443 const int64_t panelButtonFlags = borderBottom_WidgetFlag | alignLeft_WidgetFlag | 1467 const int64_t panelButtonFlags = borderBottom_WidgetFlag | alignLeft_WidgetFlag |
1444 frameless_WidgetFlag | extraPadding_WidgetFlag; 1468 frameless_WidgetFlag | extraPadding_WidgetFlag;
1445 iWidget *topPanel = new_Widget(); 1469 iWidget *topPanel = new_Widget();
1470 setFlags_Widget(topPanel, topPanelOffset_WidgetFlag, iTrue); /* slide with children */
1446 setId_Widget(topPanel, "panel.top"); 1471 setId_Widget(topPanel, "panel.top");
1447 addChild_Widget(topPanel, iClob(makePadding_Widget(lineHeight_Text(defaultBig_FontId)))); 1472 addChild_Widget(topPanel, iClob(makePadding_Widget(lineHeight_Text(defaultBig_FontId))));
1448 if (prefsTabs) { 1473 if (prefsTabs) {
@@ -1493,7 +1518,8 @@ void finalizeSheet_Widget(iWidget *sheet) {
1493 const iBool useSlidePanels = (size_PtrArray(contents) == size_PtrArray(panelButtons)); 1518 const iBool useSlidePanels = (size_PtrArray(contents) == size_PtrArray(panelButtons));
1494 addChildFlags_Widget(sheet, iClob(topPanel), 1519 addChildFlags_Widget(sheet, iClob(topPanel),
1495 arrangeVertical_WidgetFlag | 1520 arrangeVertical_WidgetFlag |
1496 resizeWidthOfChildren_WidgetFlag | arrangeHeight_WidgetFlag | 1521 resizeWidthOfChildren_WidgetFlag |
1522 arrangeHeight_WidgetFlag |
1497 overflowScrollable_WidgetFlag | 1523 overflowScrollable_WidgetFlag |
1498 commandOnClick_WidgetFlag); 1524 commandOnClick_WidgetFlag);
1499 setCommandHandler_Widget(topPanel, slidePanelHandler_); 1525 setCommandHandler_Widget(topPanel, slidePanelHandler_);
@@ -1636,7 +1662,8 @@ void finalizeSheet_Widget(iWidget *sheet) {
1636#if defined (iPlatformAppleMobile) 1662#if defined (iPlatformAppleMobile)
1637 appendCStr_String(msg, " (" LAGRANGE_IOS_VERSION ")"); 1663 appendCStr_String(msg, " (" LAGRANGE_IOS_VERSION ")");
1638#endif 1664#endif
1639 addChild_Widget(panel, iClob(new_LabelWidget(cstr_String(msg), NULL))); 1665 addChildFlags_Widget(panel, iClob(new_LabelWidget(cstr_String(msg), NULL)),
1666 frameless_WidgetFlag);
1640 addChildFlags_Widget(panel, 1667 addChildFlags_Widget(panel,
1641 iClob(makePanelButton_(globe_Icon " By @jk@skyjake.fi", 1668 iClob(makePanelButton_(globe_Icon " By @jk@skyjake.fi",
1642 "!open url:https://skyjake.fi/@jk")), 1669 "!open url:https://skyjake.fi/@jk")),
@@ -2011,13 +2038,17 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg,
2011 const iMenuItem *item = &items[i]; 2038 const iMenuItem *item = &items[i];
2012 const char first = item->label[0]; 2039 const char first = item->label[0];
2013 if (first == '*' || first == '&') { 2040 if (first == '*' || first == '&') {
2014 addChildFlags_Widget(dlg, 2041 iLabelWidget *option =
2042 addChildFlags_Widget(dlg,
2015 iClob(newKeyMods_LabelWidget(item->label + 1, 2043 iClob(newKeyMods_LabelWidget(item->label + 1,
2016 item->key, 2044 item->key,
2017 item->kmods, 2045 item->kmods,
2018 item->command)), 2046 item->command)),
2019 resizeToParentWidth_WidgetFlag | 2047 resizeToParentWidth_WidgetFlag |
2020 (first == '&' ? selected_WidgetFlag : 0)); 2048 (first == '&' ? selected_WidgetFlag : 0));
2049 if (deviceType_App() != desktop_AppDeviceType) {
2050 setFont_LabelWidget(option, defaultBig_FontId);
2051 }
2021 } 2052 }
2022 } 2053 }
2023 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); 2054 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI)));
@@ -2225,6 +2256,23 @@ static void addPrefsInputWithHeading_(iWidget *headings, iWidget *values,
2225 addDialogInputWithHeading_(headings, values, format_CStr("${%s}", id), id, input); 2256 addDialogInputWithHeading_(headings, values, format_CStr("${%s}", id), id, input);
2226} 2257}
2227 2258
2259void setupSheetTransition_Widget(iWidget *sheet, iBool isIncoming) {
2260 if (deviceType_App() == phone_AppDeviceType && isPortrait_App()) {
2261 identify_Widget(sheet);
2262 /* View transition. */
2263 if (isIncoming) {
2264 setFlags_Widget(sheet, horizontalOffset_WidgetFlag, iTrue);
2265 setVisualOffset_Widget(sheet, size_Root(sheet->root).x, 0, 0);
2266 setVisualOffset_Widget(sheet, 0, 200, easeOut_AnimFlag);
2267 }
2268 else {
2269 const iBool wasDragged = iAbs(value_Anim(&sheet->visualOffset)) > 0;
2270 setVisualOffset_Widget(sheet, size_Root(sheet->root).x, wasDragged ? 100 : 200,
2271 wasDragged ? 0 : easeIn_AnimFlag);
2272 }
2273 }
2274}
2275
2228iWidget *makePreferences_Widget(void) { 2276iWidget *makePreferences_Widget(void) {
2229 iWidget *dlg = makeSheet_Widget("prefs"); 2277 iWidget *dlg = makeSheet_Widget("prefs");
2230 addChildFlags_Widget(dlg, 2278 addChildFlags_Widget(dlg,
@@ -2257,14 +2305,16 @@ iWidget *makePreferences_Widget(void) {
2257 addChild_Widget(values, iClob(makeToggle_Widget("prefs.hoverlink"))); 2305 addChild_Widget(values, iClob(makeToggle_Widget("prefs.hoverlink")));
2258 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.archive.openindex}"))); 2306 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.archive.openindex}")));
2259 addChild_Widget(values, iClob(makeToggle_Widget("prefs.archive.openindex"))); 2307 addChild_Widget(values, iClob(makeToggle_Widget("prefs.archive.openindex")));
2260 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.pinsplit}"))); 2308 if (deviceType_App() != phone_AppDeviceType) {
2261 iWidget *pinSplit = new_Widget(); 2309 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.pinsplit}")));
2262 /* Split mode document pinning. */ { 2310 iWidget *pinSplit = new_Widget();
2263 addRadioButton_(pinSplit, "prefs.pinsplit.0", "${prefs.pinsplit.none}", "pinsplit.set arg:0"); 2311 /* Split mode document pinning. */ {
2264 addRadioButton_(pinSplit, "prefs.pinsplit.1", "${prefs.pinsplit.left}", "pinsplit.set arg:1"); 2312 addRadioButton_(pinSplit, "prefs.pinsplit.0", "${prefs.pinsplit.none}", "pinsplit.set arg:0");
2265 addRadioButton_(pinSplit, "prefs.pinsplit.2", "${prefs.pinsplit.right}", "pinsplit.set arg:2"); 2313 addRadioButton_(pinSplit, "prefs.pinsplit.1", "${prefs.pinsplit.left}", "pinsplit.set arg:1");
2266 } 2314 addRadioButton_(pinSplit, "prefs.pinsplit.2", "${prefs.pinsplit.right}", "pinsplit.set arg:2");
2267 addChildFlags_Widget(values, iClob(pinSplit), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 2315 }
2316 addChildFlags_Widget(values, iClob(pinSplit), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
2317 }
2268 addChild_Widget(headings, iClob(makePadding_Widget(bigGap))); 2318 addChild_Widget(headings, iClob(makePadding_Widget(bigGap)));
2269 addChild_Widget(values, iClob(makePadding_Widget(bigGap))); 2319 addChild_Widget(values, iClob(makePadding_Widget(bigGap)));
2270 /* UI languages. */ { 2320 /* UI languages. */ {
@@ -2486,6 +2536,7 @@ iWidget *makePreferences_Widget(void) {
2486 (iMenuItem[]){ { "${dismiss}", SDLK_ESCAPE, 0, "prefs.dismiss" } }, 1))); 2536 (iMenuItem[]){ { "${dismiss}", SDLK_ESCAPE, 0, "prefs.dismiss" } }, 1)));
2487 addChild_Widget(dlg->root->widget, iClob(dlg)); 2537 addChild_Widget(dlg->root->widget, iClob(dlg));
2488 finalizeSheet_Widget(dlg); 2538 finalizeSheet_Widget(dlg);
2539 setupSheetTransition_Widget(dlg, iTrue);
2489// printTree_Widget(dlg); 2540// printTree_Widget(dlg);
2490 return dlg; 2541 return dlg;
2491} 2542}