summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/labelwidget.c22
-rw-r--r--src/ui/labelwidget.h1
-rw-r--r--src/ui/root.c10
-rw-r--r--src/ui/sidebarwidget.c8
-rw-r--r--src/ui/text.c37
-rw-r--r--src/ui/text.h2
6 files changed, 61 insertions, 19 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index febaa15b..09c5812b 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -44,6 +44,7 @@ struct Impl_LabelWidget {
44 struct { 44 struct {
45 uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */ 45 uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */
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 } flags; 48 } flags;
48}; 49};
49 50
@@ -348,14 +349,14 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
348 cstr_String(&d->label)); 349 cstr_String(&d->label));
349 } 350 }
350 else { 351 else {
351 drawCentered_Text(d->font, 352 drawCenteredOutline_Text(
352 adjusted_Rect(bounds, 353 d->font,
353 add_I2(zero_I2(), init_I2(iconPad, 0)), 354 adjusted_Rect(bounds, add_I2(zero_I2(), init_I2(iconPad, 0)), neg_I2(zero_I2())),
354 neg_I2(zero_I2())), 355 d->flags.alignVisual,
355 d->flags.alignVisual, 356 d->flags.drawAsOutline ? fg : none_ColorId,
356 fg, 357 d->flags.drawAsOutline ? d->widget.bgColor : fg,
357 "%s", 358 "%s",
358 cstr_String(&d->label)); 359 cstr_String(&d->label));
359 } 360 }
360 if (flags & chevron_WidgetFlag) { 361 if (flags & chevron_WidgetFlag) {
361 const iRect chRect = rect; 362 const iRect chRect = rect;
@@ -442,6 +443,7 @@ void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) {
442 setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0); 443 setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0);
443 d->flags.alignVisual = iFalse; 444 d->flags.alignVisual = iFalse;
444 d->flags.noAutoMinHeight = iFalse; 445 d->flags.noAutoMinHeight = iFalse;
446 d->flags.drawAsOutline = iFalse;
445 updateSize_LabelWidget(d); 447 updateSize_LabelWidget(d);
446 updateKey_LabelWidget_(d); /* could be bound to another key */ 448 updateKey_LabelWidget_(d); /* could be bound to another key */
447} 449}
@@ -481,6 +483,10 @@ void setNoAutoMinHeight_LabelWidget(iLabelWidget *d, iBool noAutoMinHeight) {
481 } 483 }
482} 484}
483 485
486void setOutline_LabelWidget(iLabelWidget *d, iBool drawAsOutline) {
487 d->flags.drawAsOutline = drawAsOutline;
488}
489
484void updateText_LabelWidget(iLabelWidget *d, const iString *text) { 490void updateText_LabelWidget(iLabelWidget *d, const iString *text) {
485 set_String(&d->label, text); 491 set_String(&d->label, text);
486 set_String(&d->srcLabel, text); 492 set_String(&d->srcLabel, text);
diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h
index 25cde95c..25c873fc 100644
--- a/src/ui/labelwidget.h
+++ b/src/ui/labelwidget.h
@@ -31,6 +31,7 @@ iDeclareObjectConstructionArgs(LabelWidget, const char *label, const char *comma
31 31
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 setOutline_LabelWidget (iLabelWidget *, iBool drawAsOutline);
34void setFont_LabelWidget (iLabelWidget *, int fontId); 35void setFont_LabelWidget (iLabelWidget *, int fontId);
35void setTextColor_LabelWidget (iLabelWidget *, int color); 36void setTextColor_LabelWidget (iLabelWidget *, int color);
36void setText_LabelWidget (iLabelWidget *, const iString *text); /* resizes widget */ 37void setText_LabelWidget (iLabelWidget *, const iString *text); /* resizes widget */
diff --git a/src/ui/root.c b/src/ui/root.c
index c3a9596f..71f51ef0 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -432,9 +432,9 @@ static void updateNavBarIdentity_(iWidget *navBar) {
432 const iGmIdentity *ident = 432 const iGmIdentity *ident =
433 identityForUrl_GmCerts(certs_App(), url_DocumentWidget(document_App())); 433 identityForUrl_GmCerts(certs_App(), url_DocumentWidget(document_App()));
434 iWidget *button = findChild_Widget(navBar, "navbar.ident"); 434 iWidget *button = findChild_Widget(navBar, "navbar.ident");
435 iWidget *tool = findWidget_App("toolbar.ident"); 435 iLabelWidget *toolButton = findWidget_App("toolbar.ident");
436 setFlags_Widget(button, selected_WidgetFlag, ident != NULL); 436 setFlags_Widget(button, selected_WidgetFlag, ident != NULL);
437 setFlags_Widget(tool, selected_WidgetFlag, ident != NULL); 437 setOutline_LabelWidget(toolButton, ident == NULL);
438 /* Update menu. */ 438 /* Update menu. */
439 iLabelWidget *idItem = child_Widget(findChild_Widget(button, "menu"), 0); 439 iLabelWidget *idItem = child_Widget(findChild_Widget(button, "menu"), 0);
440 const iString *subjectName = ident ? name_GmIdentity(ident) : NULL; 440 const iString *subjectName = ident ? name_GmIdentity(ident) : NULL;
@@ -519,12 +519,14 @@ void updateToolbarColors_Root(iRoot *d) {
519 iWidget *toolBar = findChild_Widget(d->widget, "toolbar"); 519 iWidget *toolBar = findChild_Widget(d->widget, "toolbar");
520 if (toolBar) { 520 if (toolBar) {
521 const iBool isSidebarVisible = isVisible_Widget(findChild_Widget(d->widget, "sidebar")); 521 const iBool isSidebarVisible = isVisible_Widget(findChild_Widget(d->widget, "sidebar"));
522 setBackgroundColor_Widget(toolBar, isSidebarVisible ? uiBackgroundSidebar_ColorId : 522 const int bg = isSidebarVisible ? uiBackgroundSidebar_ColorId :
523 tmBannerBackground_ColorId); 523 tmBannerBackground_ColorId;
524 setBackgroundColor_Widget(toolBar, bg);
524 iForEach(ObjectList, i, children_Widget(toolBar)) { 525 iForEach(ObjectList, i, children_Widget(toolBar)) {
525 iLabelWidget *btn = i.object; 526 iLabelWidget *btn = i.object;
526 setTextColor_LabelWidget(i.object, isSidebarVisible ? uiTextDim_ColorId : 527 setTextColor_LabelWidget(i.object, isSidebarVisible ? uiTextDim_ColorId :
527 tmBannerIcon_ColorId); 528 tmBannerIcon_ColorId);
529 setBackgroundColor_Widget(i.object, bg); /* using noBackground, but ident has outline */
528 } 530 }
529 } 531 }
530#else 532#else
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 5b836670..b4948821 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -1806,13 +1806,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1806 : uiTextFramelessHover_ColorId) 1806 : uiTextFramelessHover_ColorId)
1807 : uiTextDim_ColorId; 1807 : uiTextDim_ColorId;
1808 if (!d->listItem.isSelected && !isUsedOnDomain) { 1808 if (!d->listItem.isSelected && !isUsedOnDomain) {
1809 /* Draw an outline of the icon. */ 1809 drawOutline_Text(font, cPos, metaFg, none_ColorId, range_String(&icon));
1810 for (int off = 0; off < 4; ++off) {
1811 drawRange_Text(font,
1812 add_I2(cPos, init_I2(off % 2 == 0 ? -1 : 1, off / 2 == 0 ? -1 : 1)),
1813 metaFg,
1814 range_String(&icon));
1815 }
1816 } 1810 }
1817 drawRange_Text(font, 1811 drawRange_Text(font,
1818 cPos, 1812 cPos,
diff --git a/src/ui/text.c b/src/ui/text.c
index 27be1bec..8a70e4db 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -1315,6 +1315,18 @@ void drawRangeN_Text(int fontId, iInt2 pos, int color, iRangecc text, size_t max
1315 drawBoundedN_Text_(fontId, pos, 0, color, text, maxChars); 1315 drawBoundedN_Text_(fontId, pos, 0, color, text, maxChars);
1316} 1316}
1317 1317
1318void drawOutline_Text(int fontId, iInt2 pos, int outlineColor, int fillColor, iRangecc text) {
1319 for (int off = 0; off < 4; ++off) {
1320 drawRange_Text(fontId,
1321 add_I2(pos, init_I2(off % 2 == 0 ? -1 : 1, off / 2 == 0 ? -1 : 1)),
1322 outlineColor,
1323 text);
1324 }
1325 if (fillColor != none_ColorId) {
1326 drawRange_Text(fontId, pos, fillColor, text);
1327 }
1328}
1329
1318iInt2 advanceWrapRange_Text(int fontId, int maxWidth, iRangecc text) { 1330iInt2 advanceWrapRange_Text(int fontId, int maxWidth, iRangecc text) {
1319 iInt2 size = zero_I2(); 1331 iInt2 size = zero_I2();
1320 const char *endp; 1332 const char *endp;
@@ -1356,6 +1368,31 @@ void drawCentered_Text(int fontId, iRect rect, iBool alignVisual, int color, con
1356 deinit_Block(&chars); 1368 deinit_Block(&chars);
1357} 1369}
1358 1370
1371void drawCenteredOutline_Text(int fontId, iRect rect, iBool alignVisual, int outlineColor,
1372 int fillColor, const char *format, ...) {
1373 iBlock chars;
1374 init_Block(&chars, 0); {
1375 va_list args;
1376 va_start(args, format);
1377 vprintf_Block(&chars, format, args);
1378 va_end(args);
1379 }
1380 if (outlineColor != none_ColorId) {
1381 for (int off = 0; off < 4; ++off) {
1382 drawCenteredRange_Text(
1383 fontId,
1384 moved_Rect(rect, init_I2(off % 2 == 0 ? -1 : 1, off / 2 == 0 ? -1 : 1)),
1385 alignVisual,
1386 outlineColor,
1387 range_Block(&chars));
1388 }
1389 }
1390 if (fillColor != none_ColorId) {
1391 drawCenteredRange_Text(fontId, rect, alignVisual, fillColor, range_Block(&chars));
1392 }
1393 deinit_Block(&chars);
1394}
1395
1359void drawCenteredRange_Text(int fontId, iRect rect, iBool alignVisual, int color, iRangecc text) { 1396void drawCenteredRange_Text(int fontId, iRect rect, iBool alignVisual, int color, iRangecc text) {
1360 iRect textBounds = alignVisual ? visualBounds_Text(fontId, text) 1397 iRect textBounds = alignVisual ? visualBounds_Text(fontId, text)
1361 : (iRect){ zero_I2(), advanceRange_Text(fontId, text) }; 1398 : (iRect){ zero_I2(), advanceRange_Text(fontId, text) };
diff --git a/src/ui/text.h b/src/ui/text.h
index 2f2bcf3a..64a8352f 100644
--- a/src/ui/text.h
+++ b/src/ui/text.h
@@ -162,9 +162,11 @@ void draw_Text (int fontId, iInt2 pos, int color, const char *t
162void drawAlign_Text (int fontId, iInt2 pos, int color, enum iAlignment align, const char *text, ...); 162void drawAlign_Text (int fontId, iInt2 pos, int color, enum iAlignment align, const char *text, ...);
163void drawCentered_Text (int fontId, iRect rect, iBool alignVisual, int color, const char *text, ...); 163void drawCentered_Text (int fontId, iRect rect, iBool alignVisual, int color, const char *text, ...);
164void drawCenteredRange_Text (int fontId, iRect rect, iBool alignVisual, int color, iRangecc text); 164void drawCenteredRange_Text (int fontId, iRect rect, iBool alignVisual, int color, iRangecc text);
165void drawCenteredOutline_Text(int fontId, iRect rect, iBool alignVisual, int outlineColor, int fillColor, const char *text, ...);
165void drawString_Text (int fontId, iInt2 pos, int color, const iString *text); 166void drawString_Text (int fontId, iInt2 pos, int color, const iString *text);
166void drawRange_Text (int fontId, iInt2 pos, int color, iRangecc text); 167void drawRange_Text (int fontId, iInt2 pos, int color, iRangecc text);
167void drawRangeN_Text (int fontId, iInt2 pos, int color, iRangecc text, size_t maxLen); 168void drawRangeN_Text (int fontId, iInt2 pos, int color, iRangecc text, size_t maxLen);
169void drawOutline_Text (int fontId, iInt2 pos, int outlineColor, int fillColor, iRangecc text);
168void drawBoundRange_Text (int fontId, iInt2 pos, int boundWidth, int color, iRangecc text); /* bound does not wrap */ 170void drawBoundRange_Text (int fontId, iInt2 pos, int boundWidth, int color, iRangecc text); /* bound does not wrap */
169int drawWrapRange_Text (int fontId, iInt2 pos, int maxWidth, int color, iRangecc text); /* returns new Y */ 171int drawWrapRange_Text (int fontId, iInt2 pos, int maxWidth, int color, iRangecc text); /* returns new Y */
170 172