summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/inputwidget.c23
-rw-r--r--src/ui/labelwidget.c51
-rw-r--r--src/ui/labelwidget.h1
-rw-r--r--src/ui/mobile.c20
-rw-r--r--src/ui/uploadwidget.c6
5 files changed, 79 insertions, 22 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index a1fb8cb5..bd9b63b5 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -2343,10 +2343,29 @@ static void draw_InputWidget_(const iInputWidget *d) {
2343 /* If buffered, just draw the buffered copy. */ 2343 /* If buffered, just draw the buffered copy. */
2344 if (d->buffered && !isFocused) { 2344 if (d->buffered && !isFocused) {
2345 /* Most input widgets will use this, since only one is focused at a time. */ 2345 /* Most input widgets will use this, since only one is focused at a time. */
2346 draw_TextBuf(d->buffered, addY_I2(drawPos, visLineOffsetY), white_ColorId); 2346 if (flags_Widget(w) & alignRight_WidgetFlag) {
2347 draw_TextBuf(
2348 d->buffered,
2349 addY_I2(init_I2(right_Rect(contentBounds) - d->buffered->size.x, drawPos.y),
2350 visLineOffsetY),
2351 white_ColorId);
2352 }
2353 else {
2354 draw_TextBuf(d->buffered, addY_I2(drawPos, visLineOffsetY), white_ColorId);
2355 }
2347 } 2356 }
2348 else if (isHint) { 2357 else if (isHint) {
2349 drawRange_Text(d->font, drawPos, uiAnnotation_ColorId, range_String(&d->hint)); 2358 if (flags_Widget(w) & alignRight_WidgetFlag) {
2359 drawAlign_Text(d->font,
2360 init_I2(right_Rect(contentBounds), drawPos.y),
2361 uiAnnotation_ColorId,
2362 right_Alignment,
2363 "%s",
2364 cstr_String(&d->hint));
2365 }
2366 else {
2367 drawRange_Text(d->font, drawPos, uiAnnotation_ColorId, range_String(&d->hint));
2368 }
2350 } 2369 }
2351 else { 2370 else {
2352 iAssert(~d->inFlags & isSensitive_InputWidgetFlag || size_Range(&visLines) == 1); 2371 iAssert(~d->inFlags & isSensitive_InputWidgetFlag || size_Range(&visLines) == 1);
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index f6ddfd43..9ef62262 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -44,14 +44,15 @@ struct Impl_LabelWidget {
44 iString command; 44 iString command;
45 iClick click; 45 iClick click;
46 struct { 46 struct {
47 uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */ 47 uint16_t alignVisual : 1; /* align according to visible bounds, not font metrics */
48 uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */ 48 uint16_t noAutoMinHeight : 1; /* minimum height is not set automatically */
49 uint8_t drawAsOutline : 1; /* draw as outline, filled with background color */ 49 uint16_t drawAsOutline : 1; /* draw as outline, filled with background color */
50 uint8_t noTopFrame : 1; 50 uint16_t noTopFrame : 1;
51 uint8_t wrap : 1; 51 uint16_t wrap : 1;
52 uint8_t allCaps : 1; 52 uint16_t allCaps : 1;
53 uint8_t removeTrailingColon : 1; 53 uint16_t removeTrailingColon : 1;
54 uint8_t chevron : 1; 54 uint16_t chevron : 1;
55 uint16_t checkMark : 1;
55 } flags; 56 } flags;
56}; 57};
57 58
@@ -204,6 +205,9 @@ static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int
204 *bg = isButton && ~flags & noBackground_WidgetFlag ? (d->widget.bgColor != none_ColorId ? 205 *bg = isButton && ~flags & noBackground_WidgetFlag ? (d->widget.bgColor != none_ColorId ?
205 d->widget.bgColor : uiBackground_ColorId) 206 d->widget.bgColor : uiBackground_ColorId)
206 : none_ColorId; 207 : none_ColorId;
208 if (d->flags.checkMark) {
209 *bg = none_ColorId;
210 }
207 *fg = uiText_ColorId; 211 *fg = uiText_ColorId;
208 *frame1 = isButton ? uiEmboss1_ColorId : d->widget.frameColor; 212 *frame1 = isButton ? uiEmboss1_ColorId : d->widget.frameColor;
209 *frame2 = isButton ? uiEmboss2_ColorId : *frame1; 213 *frame2 = isButton ? uiEmboss2_ColorId : *frame1;
@@ -215,13 +219,15 @@ static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int
215 *meta = uiTextDisabled_ColorId; 219 *meta = uiTextDisabled_ColorId;
216 } 220 }
217 if (isSel) { 221 if (isSel) {
218 *bg = uiBackgroundSelected_ColorId; 222 if (!d->flags.checkMark) {
223 *bg = uiBackgroundSelected_ColorId;
219// if (!isKeyRoot) { 224// if (!isKeyRoot) {
220// *bg = uiEmbossSelected1_ColorId; //uiBackgroundUnfocusedSelection_ColorId; 225// *bg = uiEmbossSelected1_ColorId; //uiBackgroundUnfocusedSelection_ColorId;
221// } 226// }
222 if (!isKeyRoot) { 227 if (!isKeyRoot) {
223 *bg = isDark_ColorTheme(colorTheme_App()) ? uiBackgroundUnfocusedSelection_ColorId 228 *bg = isDark_ColorTheme(colorTheme_App()) ? uiBackgroundUnfocusedSelection_ColorId
224 : uiMarked_ColorId ; 229 : uiMarked_ColorId;
230 }
225 } 231 }
226 *fg = uiTextSelected_ColorId; 232 *fg = uiTextSelected_ColorId;
227 if (isButton) { 233 if (isButton) {
@@ -429,14 +435,23 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
429 "%s", 435 "%s",
430 cstr_String(&d->label)); 436 cstr_String(&d->label));
431 } 437 }
432 if (d->flags.chevron) { 438 if (d->flags.chevron || (flags & selected_WidgetFlag && d->flags.checkMark)) {
433 const iRect chRect = rect; 439 const iRect chRect = rect;
434 const int chSize = lineHeight_Text(d->font); 440 const int chSize = lineHeight_Text(d->font);
441 int offset = 0;
442 if (d->flags.chevron) {
443 offset = -iconPad;
444 }
445 else {
446 offset = -10 * gap_UI;
447 }
435 drawCentered_Text(d->font, 448 drawCentered_Text(d->font,
436 (iRect){ addX_I2(topRight_Rect(chRect), -iconPad), 449 (iRect){ addX_I2(topRight_Rect(chRect), offset),
437 init_I2(chSize, height_Rect(chRect)) }, 450 init_I2(chSize, height_Rect(chRect)) },
438 iTrue, iconColor, rightAngle_Icon); 451 iTrue,
439 } 452 iconColor,
453 d->flags.chevron ? rightAngle_Icon : check_Icon);
454 }
440 unsetClip_Paint(&p); 455 unsetClip_Paint(&p);
441 drawChildren_Widget(w); 456 drawChildren_Widget(w);
442} 457}
@@ -580,6 +595,10 @@ void setChevron_LabelWidget(iLabelWidget *d, iBool chevron) {
580 d->flags.chevron = chevron; 595 d->flags.chevron = chevron;
581} 596}
582 597
598void setCheckMark_LabelWidget(iLabelWidget *d, iBool checkMark) {
599 d->flags.checkMark = checkMark;
600}
601
583void setWrap_LabelWidget(iLabelWidget *d, iBool wrap) { 602void setWrap_LabelWidget(iLabelWidget *d, iBool wrap) {
584 d->flags.wrap = wrap; 603 d->flags.wrap = wrap;
585} 604}
diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h
index 6542ae12..6f1b7902 100644
--- a/src/ui/labelwidget.h
+++ b/src/ui/labelwidget.h
@@ -33,6 +33,7 @@ void setAlignVisually_LabelWidget(iLabelWidget *, iBool alignVisual);
33void setNoAutoMinHeight_LabelWidget (iLabelWidget *, iBool noAutoMinHeight); 33void setNoAutoMinHeight_LabelWidget (iLabelWidget *, iBool noAutoMinHeight);
34void setNoTopFrame_LabelWidget (iLabelWidget *, iBool noTopFrame); 34void setNoTopFrame_LabelWidget (iLabelWidget *, iBool noTopFrame);
35void setChevron_LabelWidget (iLabelWidget *, iBool chevron); 35void setChevron_LabelWidget (iLabelWidget *, iBool chevron);
36void setCheckMark_LabelWidget (iLabelWidget *, iBool checkMark);
36void setWrap_LabelWidget (iLabelWidget *, iBool wrap); 37void setWrap_LabelWidget (iLabelWidget *, iBool wrap);
37void setOutline_LabelWidget (iLabelWidget *, iBool drawAsOutline); 38void setOutline_LabelWidget (iLabelWidget *, iBool drawAsOutline);
38void setAllCaps_LabelWidget (iLabelWidget *, iBool allCaps); 39void setAllCaps_LabelWidget (iLabelWidget *, iBool allCaps);
diff --git a/src/ui/mobile.c b/src/ui/mobile.c
index 7b34d389..c7b75d3f 100644
--- a/src/ui/mobile.c
+++ b/src/ui/mobile.c
@@ -511,6 +511,7 @@ void makePanelItem_Mobile(iWidget *panel, const iMenuItem *item) {
511 setId_Widget(as_Widget(drop), id); 511 setId_Widget(as_Widget(drop), id);
512 widget = makeValuePaddingWithHeading_(heading = makeHeading_Widget(label), as_Widget(drop)); 512 widget = makeValuePaddingWithHeading_(heading = makeHeading_Widget(label), as_Widget(drop));
513 setCommandHandler_Widget(widget, dropdownHeadingHandler_); 513 setCommandHandler_Widget(widget, dropdownHeadingHandler_);
514 widget->padding[2] = gap_UI;
514 setUserData_Object(widget, drop); 515 setUserData_Object(widget, drop);
515 } 516 }
516 else if (equal_Command(spec, "radio") || equal_Command(spec, "buttons")) { 517 else if (equal_Command(spec, "radio") || equal_Command(spec, "buttons")) {
@@ -534,7 +535,20 @@ void makePanelItem_Mobile(iWidget *panel, const iMenuItem *item) {
534 resizeWidthOfChildren_WidgetFlag, 535 resizeWidthOfChildren_WidgetFlag,
535 iTrue); 536 iTrue);
536 setId_Widget(widget, id); 537 setId_Widget(widget, id);
538 iBool isFirst = iTrue;
537 for (const iMenuItem *radioItem = item->data; radioItem->label; radioItem++) { 539 for (const iMenuItem *radioItem = item->data; radioItem->label; radioItem++) {
540 if (!isHorizontal && !isFirst) {
541 /* The separator is padded from the left so we need two. */
542 iWidget *sep = new_Widget();
543 iWidget *sep2 = new_Widget();
544 addChildFlags_Widget(sep, iClob(sep2), 0);
545 setFlags_Widget(sep, arrangeHeight_WidgetFlag | resizeWidthOfChildren_WidgetFlag, iTrue);
546 setBackgroundColor_Widget(sep2, uiSeparator_ColorId);
547 setFixedSize_Widget(sep2, init_I2(-1, gap_UI / 4));
548 setPadding_Widget(sep, 5 * gap_UI, 0, 0, 0);
549 addChildFlags_Widget(widget, iClob(sep), 0);
550 }
551 isFirst = iFalse;
538 const char * radId = cstr_Rangecc(range_Command(radioItem->label, "id")); 552 const char * radId = cstr_Rangecc(range_Command(radioItem->label, "id"));
539 int64_t flags = noBackground_WidgetFlag | frameless_WidgetFlag; 553 int64_t flags = noBackground_WidgetFlag | frameless_WidgetFlag;
540 if (!isHorizontal) { 554 if (!isHorizontal) {
@@ -554,10 +568,13 @@ void makePanelItem_Mobile(iWidget *panel, const iMenuItem *item) {
554 button = (iLabelWidget *) makeToggle_Widget(radId); 568 button = (iLabelWidget *) makeToggle_Widget(radId);
555 setTextCStr_LabelWidget(button, format_CStr("${%s}", radId)); 569 setTextCStr_LabelWidget(button, format_CStr("${%s}", radId));
556 setFlags_Widget(as_Widget(button), fixedWidth_WidgetFlag, iFalse); 570 setFlags_Widget(as_Widget(button), fixedWidth_WidgetFlag, iFalse);
557 updateSize_LabelWidget(button);
558 } 571 }
559 setId_Widget(as_Widget(button), radId); 572 setId_Widget(as_Widget(button), radId);
560 setFont_LabelWidget(button, isHorizontal ? uiLabelMedium_FontId : uiLabelBig_FontId); 573 setFont_LabelWidget(button, isHorizontal ? uiLabelMedium_FontId : uiLabelBig_FontId);
574 setCheckMark_LabelWidget(button, !isHorizontal);
575 setPadding_Widget(as_Widget(button), gap_UI, 1 * gap_UI, 0, 1 * gap_UI);
576 updateSize_LabelWidget(button);
577 setPadding_Widget(widget, 0, 0, 0, 0);
561 addChildFlags_Widget(widget, iClob(button), flags); 578 addChildFlags_Widget(widget, iClob(button), flags);
562 } 579 }
563 } 580 }
@@ -575,6 +592,7 @@ void makePanelItem_Mobile(iWidget *panel, const iMenuItem *item) {
575 setFlags_Widget(widget, expand_WidgetFlag, iTrue); 592 setFlags_Widget(widget, expand_WidgetFlag, iTrue);
576 } 593 }
577 else { 594 else {
595 setFlags_Widget(as_Widget(input), alignRight_WidgetFlag, iTrue);
578 setContentPadding_InputWidget(input, 3 * gap_UI, 0); 596 setContentPadding_InputWidget(input, 3 * gap_UI, 0);
579 if (hasLabel_Command(spec, "unit")) { 597 if (hasLabel_Command(spec, "unit")) {
580 iWidget *unit = addChildFlags_Widget( 598 iWidget *unit = addChildFlags_Widget(
diff --git a/src/ui/uploadwidget.c b/src/ui/uploadwidget.c
index bad00071..c22bfe86 100644
--- a/src/ui/uploadwidget.c
+++ b/src/ui/uploadwidget.c
@@ -185,9 +185,9 @@ void init_UploadWidget(iUploadWidget *d) {
185 { "label id:upload.info" }, 185 { "label id:upload.info" },
186 { "panel id:dlg.upload.text icon:0x1f5b9 noscroll:1", 0, 0, (const void *) textItems }, 186 { "panel id:dlg.upload.text icon:0x1f5b9 noscroll:1", 0, 0, (const void *) textItems },
187 { "panel id:dlg.upload.file icon:0x1f4c1", 0, 0, (const void *) fileItems }, 187 { "panel id:dlg.upload.file icon:0x1f4c1", 0, 0, (const void *) fileItems },
188 { "padding" }, 188 { "heading text:${heading.upload.id}" },
189 { "dropdown id:upload.id icon:0x1f464", 0, 0, constData_Array(makeIdentityItems_UploadWidget_(d)) }, 189 { "dropdown id:upload.id icon:0x1f464 text:", 0, 0, constData_Array(makeIdentityItems_UploadWidget_(d)) },
190 { "input id:upload.token hint:hint.upload.token icon:0x1f511" }, 190 { "input id:upload.token hint:hint.upload.token.long icon:0x1f516 text:" },
191 { NULL } 191 { NULL }
192 }, actions, iElemCount(actions)); 192 }, actions, iElemCount(actions));
193 d->info = findChild_Widget(w, "upload.info"); 193 d->info = findChild_Widget(w, "upload.info");