summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/labelwidget.c26
-rw-r--r--src/ui/labelwidget.h2
-rw-r--r--src/ui/sidebarwidget.c9
-rw-r--r--src/ui/util.c5
-rw-r--r--src/ui/widget.c2
-rw-r--r--src/ui/widget.h2
6 files changed, 32 insertions, 14 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index 46ef5d1f..b68ab793 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -46,6 +46,7 @@ struct Impl_LabelWidget {
46 uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */ 46 uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */
47 uint8_t drawAsOutline : 1; /* draw as outline, filled with background color */ 47 uint8_t drawAsOutline : 1; /* draw as outline, filled with background color */
48 uint8_t noTopFrame : 1; 48 uint8_t noTopFrame : 1;
49 uint8_t wrap : 1;
49 } flags; 50 } flags;
50}; 51};
51 52
@@ -317,7 +318,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
317 cstr_String(&str)); 318 cstr_String(&str));
318 deinit_String(&str); 319 deinit_String(&str);
319 } 320 }
320 if (flags & wrapText_WidgetFlag) { 321 if (d->flags.wrap) {
321 const iRect inner = adjusted_Rect(innerBounds_Widget(w), init_I2(iconPad, 0), zero_I2()); 322 const iRect inner = adjusted_Rect(innerBounds_Widget(w), init_I2(iconPad, 0), zero_I2());
322 const int wrap = inner.size.x; 323 const int wrap = inner.size.x;
323 drawWrapRange_Text(d->font, topLeft_Rect(inner), wrap, fg, range_String(&d->label)); 324 drawWrapRange_Text(d->font, topLeft_Rect(inner), wrap, fg, range_String(&d->label));
@@ -372,7 +373,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
372 373
373static void sizeChanged_LabelWidget_(iLabelWidget *d) { 374static void sizeChanged_LabelWidget_(iLabelWidget *d) {
374 iWidget *w = as_Widget(d); 375 iWidget *w = as_Widget(d);
375 if (flags_Widget(w) & wrapText_WidgetFlag) { 376 if (d->flags.wrap) {
376 if (flags_Widget(w) & fixedHeight_WidgetFlag) { 377 if (flags_Widget(w) & fixedHeight_WidgetFlag) {
377 /* Calculate a new height based on the wrapping. */ 378 /* Calculate a new height based on the wrapping. */
378 w->rect.size.y = advanceWrapRange_Text( 379 w->rect.size.y = advanceWrapRange_Text(
@@ -410,7 +411,7 @@ void updateSize_LabelWidget(iLabelWidget *d) {
410 w->minSize.y = size.y; /* vertically text must remain visible */ 411 w->minSize.y = size.y; /* vertically text must remain visible */
411 } 412 }
412 /* Wrapped text implies that width must be defined by arrangement. */ 413 /* Wrapped text implies that width must be defined by arrangement. */
413 if (!(flags & (fixedWidth_WidgetFlag | wrapText_WidgetFlag))) { 414 if (~flags & fixedWidth_WidgetFlag && !d->flags.wrap) {
414 w->rect.size.x = size.x; 415 w->rect.size.x = size.x;
415 } 416 }
416 if (~flags & fixedHeight_WidgetFlag) { 417 if (~flags & fixedHeight_WidgetFlag) {
@@ -442,10 +443,11 @@ void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) {
442 d->kmods = 0; 443 d->kmods = 0;
443 init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0); 444 init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0);
444 setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0); 445 setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0);
445 d->flags.alignVisual = iFalse; 446 d->flags.alignVisual = iFalse;
446 d->flags.noAutoMinHeight = iFalse; 447 d->flags.noAutoMinHeight = iFalse;
447 d->flags.drawAsOutline = iFalse; 448 d->flags.drawAsOutline = iFalse;
448 d->flags.noTopFrame = iFalse; 449 d->flags.noTopFrame = iFalse;
450 d->flags.wrap = iFalse;
449 updateSize_LabelWidget(d); 451 updateSize_LabelWidget(d);
450 updateKey_LabelWidget_(d); /* could be bound to another key */ 452 updateKey_LabelWidget_(d); /* could be bound to another key */
451} 453}
@@ -489,8 +491,14 @@ void setNoTopFrame_LabelWidget(iLabelWidget *d, iBool noTopFrame) {
489 d->flags.noTopFrame = noTopFrame; 491 d->flags.noTopFrame = noTopFrame;
490} 492}
491 493
494void setWrap_LabelWidget(iLabelWidget *d, iBool wrap) {
495 d->flags.wrap = wrap;
496}
497
492void setOutline_LabelWidget(iLabelWidget *d, iBool drawAsOutline) { 498void setOutline_LabelWidget(iLabelWidget *d, iBool drawAsOutline) {
493 d->flags.drawAsOutline = drawAsOutline; 499 if (d) {
500 d->flags.drawAsOutline = drawAsOutline;
501 }
494} 502}
495 503
496void updateText_LabelWidget(iLabelWidget *d, const iString *text) { 504void updateText_LabelWidget(iLabelWidget *d, const iString *text) {
@@ -554,6 +562,10 @@ iChar icon_LabelWidget(const iLabelWidget *d) {
554 return d->icon; 562 return d->icon;
555} 563}
556 564
565iBool isWrapped_LabelWidget(const iLabelWidget *d) {
566 return d->flags.wrap;
567}
568
557const iString *text_LabelWidget(const iLabelWidget *d) { 569const iString *text_LabelWidget(const iLabelWidget *d) {
558 if (!d) return collectNew_String(); 570 if (!d) return collectNew_String();
559 return &d->label; 571 return &d->label;
diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h
index f6343273..b8b6fd87 100644
--- a/src/ui/labelwidget.h
+++ b/src/ui/labelwidget.h
@@ -32,6 +32,7 @@ iDeclareObjectConstructionArgs(LabelWidget, const char *label, const char *comma
32void setAlignVisually_LabelWidget(iLabelWidget *, iBool alignVisual); 32void 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 setWrap_LabelWidget (iLabelWidget *, iBool wrap);
35void setOutline_LabelWidget (iLabelWidget *, iBool drawAsOutline); 36void setOutline_LabelWidget (iLabelWidget *, iBool drawAsOutline);
36void setFont_LabelWidget (iLabelWidget *, int fontId); 37void setFont_LabelWidget (iLabelWidget *, int fontId);
37void setTextColor_LabelWidget (iLabelWidget *, int color); 38void setTextColor_LabelWidget (iLabelWidget *, int color);
@@ -53,6 +54,7 @@ const iString * text_LabelWidget (const iLabelWidget *);
53const iString * sourceText_LabelWidget (const iLabelWidget *); /* untranslated */ 54const iString * sourceText_LabelWidget (const iLabelWidget *); /* untranslated */
54const iString * command_LabelWidget (const iLabelWidget *); 55const iString * command_LabelWidget (const iLabelWidget *);
55iChar icon_LabelWidget (const iLabelWidget *); 56iChar icon_LabelWidget (const iLabelWidget *);
57iBool isWrapped_LabelWidget (const iLabelWidget *);
56 58
57iLabelWidget *newKeyMods_LabelWidget(const char *label, int key, int kmods, const char *command); 59iLabelWidget *newKeyMods_LabelWidget(const char *label, int key, int kmods, const char *command);
58iLabelWidget *newColor_LabelWidget (const char *text, int color); 60iLabelWidget *newColor_LabelWidget (const char *text, int color);
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index b4948821..c0a22e99 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -523,15 +523,17 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
523 addChild_Widget(div, iClob(makePadding_Widget(gap_UI))); 523 addChild_Widget(div, iClob(makePadding_Widget(gap_UI)));
524 addChild_Widget(div, iClob(new_LabelWidget("${menu.identity.import}", "ident.import"))); 524 addChild_Widget(div, iClob(new_LabelWidget("${menu.identity.import}", "ident.import")));
525 addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); /* pad */ 525 addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); /* pad */
526 iLabelWidget *linkLabel;
526 setBackgroundColor_Widget( 527 setBackgroundColor_Widget(
527 addChildFlags_Widget( 528 addChildFlags_Widget(
528 div, 529 div,
529 iClob(new_LabelWidget(format_CStr(cstr_Lang("ident.gotohelp"), 530 iClob(linkLabel = new_LabelWidget(format_CStr(cstr_Lang("ident.gotohelp"),
530 uiTextStrong_ColorEscape, 531 uiTextStrong_ColorEscape,
531 restore_ColorEscape), 532 restore_ColorEscape),
532 "!open newtab:1 gotoheading:1.6 url:about:help")), 533 "!open newtab:1 gotoheading:1.6 url:about:help")),
533 frameless_WidgetFlag | fixedHeight_WidgetFlag | wrapText_WidgetFlag), 534 frameless_WidgetFlag | fixedHeight_WidgetFlag),
534 uiBackgroundSidebar_ColorId); 535 uiBackgroundSidebar_ColorId);
536 setWrap_LabelWidget(linkLabel, iTrue);
535 addChild_Widget(d->blank, iClob(div)); 537 addChild_Widget(d->blank, iClob(div));
536 } 538 }
537// arrange_Widget(d->blank); 539// arrange_Widget(d->blank);
@@ -631,7 +633,8 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) {
631 setBackgroundColor_Widget(w, none_ColorId); 633 setBackgroundColor_Widget(w, none_ColorId);
632 setFlags_Widget(w, 634 setFlags_Widget(w,
633 collapse_WidgetFlag | hidden_WidgetFlag | arrangeHorizontal_WidgetFlag | 635 collapse_WidgetFlag | hidden_WidgetFlag | arrangeHorizontal_WidgetFlag |
634 resizeWidthOfChildren_WidgetFlag, 636 resizeWidthOfChildren_WidgetFlag | noFadeBackground_WidgetFlag |
637 noShadowBorder_WidgetFlag,
635 iTrue); 638 iTrue);
636 iZap(d->modeScroll); 639 iZap(d->modeScroll);
637 d->side = side; 640 d->side = side;
diff --git a/src/ui/util.c b/src/ui/util.c
index 3a9bc400..e0b05a44 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -710,7 +710,8 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) {
710 menu, 710 menu,
711 iClob(newKeyMods_LabelWidget(labelText, item->key, item->kmods, item->command)), 711 iClob(newKeyMods_LabelWidget(labelText, item->key, item->kmods, item->command)),
712 noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag | 712 noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag |
713 drawKey_WidgetFlag | (isInfo ? wrapText_WidgetFlag : 0) | itemFlags); 713 drawKey_WidgetFlag | itemFlags);
714 setWrap_LabelWidget(label, isInfo);
714 haveIcons |= checkIcon_LabelWidget(label); 715 haveIcons |= checkIcon_LabelWidget(label);
715 updateSize_LabelWidget(label); /* drawKey was set */ 716 updateSize_LabelWidget(label); /* drawKey was set */
716 if (isInfo) { 717 if (isInfo) {
@@ -776,7 +777,7 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, iBool postCommands) {
776 if (isInstance_Object(i.object, &Class_LabelWidget)) { 777 if (isInstance_Object(i.object, &Class_LabelWidget)) {
777 iLabelWidget *label = i.object; 778 iLabelWidget *label = i.object;
778 const iBool isCaution = startsWith_String(text_LabelWidget(label), uiTextCaution_ColorEscape); 779 const iBool isCaution = startsWith_String(text_LabelWidget(label), uiTextCaution_ColorEscape);
779 if (flags_Widget(as_Widget(label)) & wrapText_WidgetFlag) { 780 if (isWrapped_LabelWidget(label)) {
780 continue; 781 continue;
781 } 782 }
782 if (deviceType_App() == desktop_AppDeviceType) { 783 if (deviceType_App() == desktop_AppDeviceType) {
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 4e1c9119..992f115d 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -1164,7 +1164,7 @@ void drawBackground_Widget(const iWidget *d) {
1164 shadowBorder = iFalse; 1164 shadowBorder = iFalse;
1165 } 1165 }
1166 } 1166 }
1167 if (shadowBorder) { 1167 if (shadowBorder && ~d->flags & noShadowBorder_WidgetFlag) {
1168 iPaint p; 1168 iPaint p;
1169 init_Paint(&p); 1169 init_Paint(&p);
1170 drawSoftShadow_Paint(&p, bounds_Widget(d), 12 * gap_UI, black_ColorId, 30); 1170 drawSoftShadow_Paint(&p, bounds_Widget(d), 12 * gap_UI, black_ColorId, 30);
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 79565483..41784b99 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -92,7 +92,7 @@ enum iWidgetFlag {
92#define centerHorizontal_WidgetFlag iBit64(33) 92#define centerHorizontal_WidgetFlag iBit64(33)
93#define moveToParentLeftEdge_WidgetFlag iBit64(34) 93#define moveToParentLeftEdge_WidgetFlag iBit64(34)
94#define moveToParentRightEdge_WidgetFlag iBit64(35) 94#define moveToParentRightEdge_WidgetFlag iBit64(35)
95#define wrapText_WidgetFlag iBit64(36) 95#define noShadowBorder_WidgetFlag iBit64(36)
96#define borderTop_WidgetFlag iBit64(37) 96#define borderTop_WidgetFlag iBit64(37)
97#define overflowScrollable_WidgetFlag iBit64(38) 97#define overflowScrollable_WidgetFlag iBit64(38)
98#define focusRoot_WidgetFlag iBit64(39) 98#define focusRoot_WidgetFlag iBit64(39)