summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-09 11:51:19 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-09 11:51:19 +0300
commit3f98db4915ab63626a690570c16c133136f48bfc (patch)
treed0ce2d3e5fba5b797d7175798a755f0ec712fbf1
parent1496aeacf167dd647fdd30a6d2687ebcb4b126b1 (diff)
Mobile: Adjusting phone layout of Preferences
-rw-r--r--src/ui/util.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index 9bfe40c9..8424dd65 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1110,7 +1110,7 @@ static iAnyObject *addPanelChild_(iWidget *panel, iAnyObject *child, int64_t fla
1110 enum iPrefsElement precedingElementType) { 1110 enum iPrefsElement precedingElementType) {
1111 /* Erase redundant/unused headings. */ 1111 /* Erase redundant/unused headings. */
1112 if (precedingElementType == heading_PrefsElement && 1112 if (precedingElementType == heading_PrefsElement &&
1113 (!child || elementType == heading_PrefsElement)) { 1113 (!child || (elementType == heading_PrefsElement || elementType == radioButton_PrefsElement))) {
1114 iRelease(removeChild_Widget(panel, lastChild_Widget(panel))); 1114 iRelease(removeChild_Widget(panel, lastChild_Widget(panel)));
1115 if (!cmp_String(id_Widget(constAs_Widget(lastChild_Widget(panel))), "padding")) { 1115 if (!cmp_String(id_Widget(constAs_Widget(lastChild_Widget(panel))), "padding")) {
1116 iRelease(removeChild_Widget(panel, lastChild_Widget(panel))); 1116 iRelease(removeChild_Widget(panel, lastChild_Widget(panel)));
@@ -1122,12 +1122,15 @@ static iAnyObject *addPanelChild_(iWidget *panel, iAnyObject *child, int64_t fla
1122 if (elementType == heading_PrefsElement || 1122 if (elementType == heading_PrefsElement ||
1123 (elementType == toggle_PrefsElement && 1123 (elementType == toggle_PrefsElement &&
1124 precedingElementType != toggle_PrefsElement && 1124 precedingElementType != toggle_PrefsElement &&
1125 precedingElementType != heading_PrefsElement) ||
1126 (elementType == dropdown_PrefsElement &&
1127 precedingElementType != dropdown_PrefsElement &&
1125 precedingElementType != heading_PrefsElement)) { 1128 precedingElementType != heading_PrefsElement)) {
1126 addChild_Widget(panel, iClob(makePadding_Widget(lineHeight_Text(defaultBig_FontId)))); 1129 addChild_Widget(panel, iClob(makePadding_Widget(lineHeight_Text(defaultBig_FontId))));
1127 } 1130 }
1128 } 1131 }
1129 if (elementType == toggle_PrefsElement && 1132 if ((elementType == toggle_PrefsElement && precedingElementType != toggle_PrefsElement) ||
1130 precedingElementType != toggle_PrefsElement) { 1133 (elementType == textInput_PrefsElement && precedingElementType != textInput_PrefsElement)) {
1131 flags |= borderTop_WidgetFlag; 1134 flags |= borderTop_WidgetFlag;
1132 } 1135 }
1133 return addChildFlags_Widget(panel, child, flags); 1136 return addChildFlags_Widget(panel, child, flags);
@@ -1378,7 +1381,7 @@ void finalizeSheet_Widget(iWidget *sheet) {
1378 element = heading_PrefsElement; 1381 element = heading_PrefsElement;
1379 iRelease(value); 1382 iRelease(value);
1380 addPanelChild_(owner, iClob(heading), 0, element, prevElement); 1383 addPanelChild_(owner, iClob(heading), 0, element, prevElement);
1381 setFont_LabelWidget(headingLabel, uiLabelBold_FontId); 1384 setFont_LabelWidget(headingLabel, uiLabel_FontId);
1382 } 1385 }
1383 else if (isMenuButton) { 1386 else if (isMenuButton) {
1384 element = dropdown_PrefsElement; 1387 element = dropdown_PrefsElement;
@@ -1386,36 +1389,26 @@ void finalizeSheet_Widget(iWidget *sheet) {
1386 alignRight_WidgetFlag | noBackground_WidgetFlag | 1389 alignRight_WidgetFlag | noBackground_WidgetFlag |
1387 frameless_WidgetFlag, iTrue); 1390 frameless_WidgetFlag, iTrue);
1388 setFlags_Widget(value, alignLeft_WidgetFlag, iFalse); 1391 setFlags_Widget(value, alignLeft_WidgetFlag, iFalse);
1389 addPanelChild_(owner, iClob(makeValuePaddingWithHeading_(headingLabel, value)), 0, 1392 iWidget *pad = addPanelChild_(owner, iClob(makeValuePaddingWithHeading_(headingLabel, value)), 0,
1390 element, prevElement); 1393 element, prevElement);
1394 pad->padding[2] = gap_UI;
1391 } 1395 }
1392 else if (valueInput) { 1396 else if (valueInput) {
1393 addPanelChild_(owner, iClob(makeValuePaddingWithHeading_(headingLabel, value)), 0, 1397 addPanelChild_(owner, iClob(makeValuePaddingWithHeading_(headingLabel, value)), 0,
1394 element, prevElement); 1398 element, prevElement);
1395 } 1399 }
1396 else { 1400 else {
1401 if (childCount_Widget(value) >= 2) {
1402 element = radioButton_PrefsElement;
1403 /* Always padding before radio buttons. */
1404 addChild_Widget(owner, iClob(makePadding_Widget(lineHeight_Text(defaultBig_FontId))));
1405 }
1397 addChildFlags_Widget(owner, iClob(heading), borderBottom_WidgetFlag); 1406 addChildFlags_Widget(owner, iClob(heading), borderBottom_WidgetFlag);
1398 if (headingLabel) { 1407 if (headingLabel) {
1399 setTextColor_LabelWidget(headingLabel, uiSubheading_ColorId); 1408 setTextColor_LabelWidget(headingLabel, uiSubheading_ColorId);
1400 setText_LabelWidget(headingLabel, 1409 setText_LabelWidget(headingLabel,
1401 collect_String(upper_String(text_LabelWidget(headingLabel)))); 1410 collect_String(upper_String(text_LabelWidget(headingLabel))));
1402 } 1411 }
1403 if (childCount_Widget(value) >= 2) {
1404// if (isInstance_Object(child_Widget(value, 0), &Class_InputWidget)) {
1405// element = textInput_PrefsElement;
1406// setPadding_Widget(value, 0, 0, gap_UI, 0);
1407// valueInput = child_Widget(value, 0);
1408// setFlags_Widget(as_Widget(valueInput), fixedWidth_WidgetFlag, iFalse);
1409// setFlags_Widget(as_Widget(valueInput), expand_WidgetFlag, iTrue);
1410// setFlags_Widget(value, resizeWidthOfChildren_WidgetFlag |
1411// resizeToParentWidth_WidgetFlag, iTrue);
1412// setFont_LabelWidget(child_Widget(value, 1), defaultBig_FontId);
1413// setTextColor_LabelWidget(child_Widget(value, 1), uiAnnotation_ColorId);
1414// }
1415// else {
1416 element = radioButton_PrefsElement;
1417// }
1418 }
1419 addPanelChild_(owner, iClob(value), 0, element, prevElement); 1412 addPanelChild_(owner, iClob(value), 0, element, prevElement);
1420 /* Radio buttons expand to fill the space. */ 1413 /* Radio buttons expand to fill the space. */
1421 if (element == radioButton_PrefsElement) { 1414 if (element == radioButton_PrefsElement) {