diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/color.c | 2 | ||||
-rw-r--r-- | src/ui/touch.c | 8 | ||||
-rw-r--r-- | src/ui/util.c | 91 |
3 files changed, 81 insertions, 20 deletions
diff --git a/src/ui/color.c b/src/ui/color.c index c751fec2..9776440f 100644 --- a/src/ui/color.c +++ b/src/ui/color.c | |||
@@ -302,6 +302,8 @@ void setThemePalette_Color(enum iColorTheme theme) { | |||
302 | if (deviceType_App() == phone_AppDeviceType) { | 302 | if (deviceType_App() == phone_AppDeviceType) { |
303 | copy_(uiInputBackground_ColorId, uiBackgroundSidebar_ColorId); | 303 | copy_(uiInputBackground_ColorId, uiBackgroundSidebar_ColorId); |
304 | copy_(uiInputFrame_ColorId, uiBackgroundSidebar_ColorId); | 304 | copy_(uiInputFrame_ColorId, uiBackgroundSidebar_ColorId); |
305 | copy_(uiInputFrameFocused_ColorId, uiBackgroundSidebar_ColorId); | ||
306 | copy_(uiInputBackgroundFocused_ColorId, uiBackgroundSidebar_ColorId); | ||
305 | } | 307 | } |
306 | } | 308 | } |
307 | 309 | ||
diff --git a/src/ui/touch.c b/src/ui/touch.c index a55d370d..ea7b6648 100644 --- a/src/ui/touch.c +++ b/src/ui/touch.c | |||
@@ -323,10 +323,10 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
323 | } | 323 | } |
324 | /* TODO: We must retain a reference to the affinity widget, or otherwise it might | 324 | /* TODO: We must retain a reference to the affinity widget, or otherwise it might |
325 | be destroyed during the gesture. */ | 325 | be destroyed during the gesture. */ |
326 | printf("aff:[%p] %s:'%s'\n", aff, aff ? class_Widget(aff)->name : "-", | 326 | // printf("aff:[%p] %s:'%s'\n", aff, aff ? class_Widget(aff)->name : "-", |
327 | cstr_String(id_Widget(aff))); | 327 | // cstr_String(id_Widget(aff))); |
328 | printf("drg:[%p] %s:'%s'\n", dragging, dragging ? class_Widget(dragging)->name : "-", | 328 | // printf("drg:[%p] %s:'%s'\n", dragging, dragging ? class_Widget(dragging)->name : "-", |
329 | cstr_String(id_Widget(dragging))); | 329 | // cstr_String(id_Widget(dragging))); |
330 | if (flags_Widget(aff) & touchDrag_WidgetFlag) { | 330 | if (flags_Widget(aff) & touchDrag_WidgetFlag) { |
331 | dispatchEvent_Widget(window->root, (SDL_Event *) &(SDL_MouseButtonEvent){ | 331 | dispatchEvent_Widget(window->root, (SDL_Event *) &(SDL_MouseButtonEvent){ |
332 | .type = SDL_MOUSEBUTTONDOWN, | 332 | .type = SDL_MOUSEBUTTONDOWN, |
diff --git a/src/ui/util.c b/src/ui/util.c index 826a965c..7feaa703 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -1040,8 +1040,35 @@ static iLabelWidget *makePanelButton_(const char *text, const char *command) { | |||
1040 | return btn; | 1040 | return btn; |
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | static iWidget *makeValuePadding_(iWidget *value) { | ||
1044 | iInputWidget *input = isInstance_Object(value, &Class_InputWidget) ? (iInputWidget *) value : NULL; | ||
1045 | if (input) { | ||
1046 | setFont_InputWidget(input, defaultBig_FontId); | ||
1047 | setContentPadding_InputWidget(input, 3 * gap_UI, 3 * gap_UI); | ||
1048 | } | ||
1049 | iWidget *pad = new_Widget(); | ||
1050 | setBackgroundColor_Widget(pad, uiBackgroundSidebar_ColorId); | ||
1051 | setPadding_Widget(pad, 0, 1 * gap_UI, 0, 1 * gap_UI); | ||
1052 | addChild_Widget(pad, iClob(value)); | ||
1053 | setFlags_Widget(pad, | ||
1054 | borderTop_WidgetFlag | | ||
1055 | borderBottom_WidgetFlag | | ||
1056 | arrangeVertical_WidgetFlag | | ||
1057 | resizeToParentWidth_WidgetFlag | | ||
1058 | resizeWidthOfChildren_WidgetFlag | | ||
1059 | arrangeHeight_WidgetFlag, | ||
1060 | iTrue); | ||
1061 | return pad; | ||
1062 | } | ||
1063 | |||
1043 | void finalizeSheet_Widget(iWidget *sheet) { | 1064 | void finalizeSheet_Widget(iWidget *sheet) { |
1044 | if (deviceType_App() == phone_AppDeviceType) { | 1065 | if (deviceType_App() == phone_AppDeviceType) { |
1066 | if (~flags_Widget(sheet) & keepOnTop_WidgetFlag) { | ||
1067 | /* Already finalized. */ | ||
1068 | arrange_Widget(sheet); | ||
1069 | postRefresh_App(); | ||
1070 | return; | ||
1071 | } | ||
1045 | /* The sheet contents are completely rearranged on a phone. We'll set up a linear | 1072 | /* The sheet contents are completely rearranged on a phone. We'll set up a linear |
1046 | fullscreen arrangement of the widgets. Sheets are already scrollable so they | 1073 | fullscreen arrangement of the widgets. Sheets are already scrollable so they |
1047 | can be taller than the display. In hindsight, it may have been easier to | 1074 | can be taller than the display. In hindsight, it may have been easier to |
@@ -1078,6 +1105,7 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
1078 | iPtrArray *contents = collect_PtrArray(new_PtrArray()); /* two-column pages */ | 1105 | iPtrArray *contents = collect_PtrArray(new_PtrArray()); /* two-column pages */ |
1079 | iPtrArray *panelButtons = collect_PtrArray(new_PtrArray()); | 1106 | iPtrArray *panelButtons = collect_PtrArray(new_PtrArray()); |
1080 | iWidget *tabs = findChild_Widget(sheet, "prefs.tabs"); | 1107 | iWidget *tabs = findChild_Widget(sheet, "prefs.tabs"); |
1108 | iWidget *dialogHeading = (tabs ? NULL : child_Widget(sheet, 0)); | ||
1081 | const iBool isPrefs = (tabs != NULL); | 1109 | const iBool isPrefs = (tabs != NULL); |
1082 | const int64_t panelButtonFlags = borderBottom_WidgetFlag | alignLeft_WidgetFlag | | 1110 | const int64_t panelButtonFlags = borderBottom_WidgetFlag | alignLeft_WidgetFlag | |
1083 | frameless_WidgetFlag | extraPadding_WidgetFlag; | 1111 | frameless_WidgetFlag | extraPadding_WidgetFlag; |
@@ -1121,8 +1149,6 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
1121 | iForEach(ObjectList, i, children_Widget(sheet)) { | 1149 | iForEach(ObjectList, i, children_Widget(sheet)) { |
1122 | iWidget *child = i.object; | 1150 | iWidget *child = i.object; |
1123 | if (isTwoColumnPage_(child)) { | 1151 | if (isTwoColumnPage_(child)) { |
1124 | printf("Non-tabbed two-column page:\n"); | ||
1125 | printTree_Widget(child); | ||
1126 | pushBack_PtrArray(contents, removeChild_Widget(sheet, child)); | 1152 | pushBack_PtrArray(contents, removeChild_Widget(sheet, child)); |
1127 | } | 1153 | } |
1128 | else { | 1154 | else { |
@@ -1131,7 +1157,7 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
1131 | iRelease(child); | 1157 | iRelease(child); |
1132 | } | 1158 | } |
1133 | } | 1159 | } |
1134 | iAssert(size_PtrArray(contents) == size_PtrArray(panelButtons)); | 1160 | const iBool useSlidePanels = (size_PtrArray(contents) == size_PtrArray(panelButtons)); |
1135 | topPanel->rect.pos = init_I2(0, navBarHeight); | 1161 | topPanel->rect.pos = init_I2(0, navBarHeight); |
1136 | addChildFlags_Widget(sheet, iClob(topPanel), | 1162 | addChildFlags_Widget(sheet, iClob(topPanel), |
1137 | arrangeVertical_WidgetFlag | | 1163 | arrangeVertical_WidgetFlag | |
@@ -1141,7 +1167,7 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
1141 | setCommandHandler_Widget(topPanel, slidePanelHandler_); | 1167 | setCommandHandler_Widget(topPanel, slidePanelHandler_); |
1142 | iForEach(PtrArray, j, contents) { | 1168 | iForEach(PtrArray, j, contents) { |
1143 | iWidget *owner = topPanel; | 1169 | iWidget *owner = topPanel; |
1144 | if (!isEmpty_PtrArray(panelButtons)) { | 1170 | if (useSlidePanels) { |
1145 | /* Create a new child panel. */ | 1171 | /* Create a new child panel. */ |
1146 | iLabelWidget *button = at_PtrArray(panelButtons, index_PtrArrayIterator(&j)); | 1172 | iLabelWidget *button = at_PtrArray(panelButtons, index_PtrArrayIterator(&j)); |
1147 | owner = new_Widget(); | 1173 | owner = new_Widget(); |
@@ -1256,15 +1282,11 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
1256 | } | 1282 | } |
1257 | if (element == textInput_PrefsElement || isMenuButton) { | 1283 | if (element == textInput_PrefsElement || isMenuButton) { |
1258 | setFlags_Widget(value, borderBottom_WidgetFlag, iFalse); | 1284 | setFlags_Widget(value, borderBottom_WidgetFlag, iFalse); |
1259 | iWidget *pad = new_Widget(); | 1285 | //iWidget *pad = new_Widget(); |
1260 | setBackgroundColor_Widget(pad, uiBackgroundSidebar_ColorId); | 1286 | //setBackgroundColor_Widget(pad, uiBackgroundSidebar_ColorId); |
1261 | setPadding_Widget(pad, 0, 1 * gap_UI, 0, 1 * gap_UI); | 1287 | //setPadding_Widget(pad, 0, 1 * gap_UI, 0, 1 * gap_UI); |
1262 | addChild_Widget(pad, iClob(value)); | 1288 | //addChild_Widget(pad, iClob(value)); |
1263 | addPanelChild_(owner, iClob(pad), borderBottom_WidgetFlag | | 1289 | addPanelChild_(owner, iClob(makeValuePadding_(value)), 0, |
1264 | arrangeVertical_WidgetFlag | | ||
1265 | resizeToParentWidth_WidgetFlag | | ||
1266 | resizeWidthOfChildren_WidgetFlag | | ||
1267 | arrangeHeight_WidgetFlag, | ||
1268 | element, prevElement); | 1290 | element, prevElement); |
1269 | } | 1291 | } |
1270 | else { | 1292 | else { |
@@ -1306,6 +1328,18 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
1306 | iClob(makePanelButton_(planet_Icon " About", "panel.about")), | 1328 | iClob(makePanelButton_(planet_Icon " About", "panel.about")), |
1307 | chevron_WidgetFlag); | 1329 | chevron_WidgetFlag); |
1308 | } | 1330 | } |
1331 | else { | ||
1332 | /* Update heading style. */ | ||
1333 | setFont_LabelWidget((iLabelWidget *) dialogHeading, uiLabelLargeBold_FontId); | ||
1334 | setFlags_Widget(dialogHeading, alignLeft_WidgetFlag, iTrue); | ||
1335 | } | ||
1336 | if (findChild_Widget(sheet, "valueinput.prompt")) { | ||
1337 | iWidget *prompt = findChild_Widget(sheet, "valueinput.prompt"); | ||
1338 | setFlags_Widget(prompt, alignLeft_WidgetFlag, iTrue); | ||
1339 | iInputWidget *input = findChild_Widget(sheet, "input"); | ||
1340 | removeChild_Widget(parent_Widget(input), input); | ||
1341 | addChild_Widget(topPanel, iClob(makeValuePadding_(as_Widget(input)))); | ||
1342 | } | ||
1309 | /* Navbar. */ { | 1343 | /* Navbar. */ { |
1310 | iWidget *navi = new_Widget(); | 1344 | iWidget *navi = new_Widget(); |
1311 | setSize_Widget(navi, init_I2(-1, navBarHeight)); | 1345 | setSize_Widget(navi, init_I2(-1, navBarHeight)); |
@@ -1315,15 +1349,41 @@ void finalizeSheet_Widget(iWidget *sheet) { | |||
1315 | iClob(new_LabelWidget(leftAngle_Icon " Back", "panel.close")), | 1349 | iClob(new_LabelWidget(leftAngle_Icon " Back", "panel.close")), |
1316 | noBackground_WidgetFlag | frameless_WidgetFlag | | 1350 | noBackground_WidgetFlag | frameless_WidgetFlag | |
1317 | alignLeft_WidgetFlag | extraPadding_WidgetFlag); | 1351 | alignLeft_WidgetFlag | extraPadding_WidgetFlag); |
1318 | setId_Widget(as_Widget(back), "panel.back"); | ||
1319 | checkIcon_LabelWidget(back); | 1352 | checkIcon_LabelWidget(back); |
1353 | setId_Widget(as_Widget(back), "panel.back"); | ||
1320 | setFont_LabelWidget(back, defaultBig_FontId); | 1354 | setFont_LabelWidget(back, defaultBig_FontId); |
1355 | if (!isPrefs) { | ||
1356 | iWidget *buttons = findChild_Widget(sheet, "dialogbuttons"); | ||
1357 | iLabelWidget *cancel = findMenuItem_Widget(buttons, "cancel"); | ||
1358 | if (cancel) { | ||
1359 | updateText_LabelWidget(back, text_LabelWidget(cancel)); | ||
1360 | setCommand_LabelWidget(back, command_LabelWidget(cancel)); | ||
1361 | } | ||
1362 | iLabelWidget *def = (iLabelWidget *) lastChild_Widget(buttons); | ||
1363 | if (def && !cancel) { | ||
1364 | updateText_LabelWidget(back, text_LabelWidget(def)); | ||
1365 | setCommand_LabelWidget(back, command_LabelWidget(def)); | ||
1366 | setFlags_Widget(as_Widget(back), alignLeft_WidgetFlag, iFalse); | ||
1367 | setFlags_Widget(as_Widget(back), alignRight_WidgetFlag, iTrue); | ||
1368 | setIcon_LabelWidget(back, 0); | ||
1369 | setFont_LabelWidget(back, defaultBigBold_FontId); | ||
1370 | } | ||
1371 | else if (def != cancel) { | ||
1372 | removeChild_Widget(buttons, def); | ||
1373 | setFont_LabelWidget(def, defaultBigBold_FontId); | ||
1374 | setFlags_Widget(as_Widget(def), | ||
1375 | frameless_WidgetFlag | extraPadding_WidgetFlag | | ||
1376 | noBackground_WidgetFlag, iTrue); | ||
1377 | addChildFlags_Widget(as_Widget(back), iClob(def), moveToParentRightEdge_WidgetFlag); | ||
1378 | updateSize_LabelWidget(def); | ||
1379 | } | ||
1380 | iRelease(removeChild_Widget(parent_Widget(buttons), buttons)); | ||
1381 | } | ||
1321 | addChildFlags_Widget(sheet, iClob(navi), | 1382 | addChildFlags_Widget(sheet, iClob(navi), |
1322 | arrangeHeight_WidgetFlag | resizeWidthOfChildren_WidgetFlag | | 1383 | arrangeHeight_WidgetFlag | resizeWidthOfChildren_WidgetFlag | |
1323 | resizeToParentWidth_WidgetFlag | arrangeVertical_WidgetFlag); | 1384 | resizeToParentWidth_WidgetFlag | arrangeVertical_WidgetFlag); |
1324 | } | 1385 | } |
1325 | arrange_Widget(sheet->parent); | 1386 | arrange_Widget(sheet->parent); |
1326 | printTree_Widget(sheet); | ||
1327 | } | 1387 | } |
1328 | else { | 1388 | else { |
1329 | arrange_Widget(sheet); | 1389 | arrange_Widget(sheet); |
@@ -1376,7 +1436,6 @@ static void updateValueInputWidth_(iWidget *dlg) { | |||
1376 | iWidget * prompt = findChild_Widget(dlg, "valueinput.prompt"); | 1436 | iWidget * prompt = findChild_Widget(dlg, "valueinput.prompt"); |
1377 | dlg->rect.size.x = iMaxi(iMaxi(rootSize.x / 2, title->rect.size.x), prompt->rect.size.x); | 1437 | dlg->rect.size.x = iMaxi(iMaxi(rootSize.x / 2, title->rect.size.x), prompt->rect.size.x); |
1378 | as_Widget(findChild_Widget(dlg, "input"))->rect.size.x = dlg->rect.size.x; | 1438 | as_Widget(findChild_Widget(dlg, "input"))->rect.size.x = dlg->rect.size.x; |
1379 | finalizeSheet_Widget(dlg); | ||
1380 | } | 1439 | } |
1381 | 1440 | ||
1382 | iBool valueInputHandler_(iWidget *dlg, const char *cmd) { | 1441 | iBool valueInputHandler_(iWidget *dlg, const char *cmd) { |