summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/lookupwidget.c15
-rw-r--r--src/ui/sidebarwidget.c30
-rw-r--r--src/ui/text.c11
-rw-r--r--src/ui/text.h1
4 files changed, 45 insertions, 12 deletions
diff --git a/src/ui/lookupwidget.c b/src/ui/lookupwidget.c
index 3eafd4bd..254aad93 100644
--- a/src/ui/lookupwidget.c
+++ b/src/ui/lookupwidget.c
@@ -127,10 +127,11 @@ static void draw_LookupItem_(iLookupItem *d, iPaint *p, iRect rect, const iListW
127 pos.y = bottom_Rect(rect) - lineHeight_Text(d->font); 127 pos.y = bottom_Rect(rect) - lineHeight_Text(d->font);
128 } 128 }
129 if (!isEmpty_String(&d->icon)) { 129 if (!isEmpty_String(&d->icon)) {
130 const iRect iconRect = { pos, init_I2(gap_UI * 5, height_Rect(rect)) }; 130 const iRect iconRect = { init_I2(pos.x, top_Rect(rect)),
131 const iInt2 iconSize = measureRange_Text(d->font, range_String(&d->icon)); 131 init_I2(gap_UI * 5, height_Rect(rect)) };
132 const iRect iconVis = visualBounds_Text(d->font, range_String(&d->icon));
132 drawRange_Text(d->font, 133 drawRange_Text(d->font,
133 addX_I2(pos, width_Rect(iconRect) / 2 - iconSize.x / 2), 134 sub_I2(mid_Rect(iconRect), mid_Rect(iconVis)),
134 fg, 135 fg,
135 range_String(&d->icon)); 136 range_String(&d->icon));
136 pos.x += width_Rect(iconRect) + gap_UI * 3 / 2; 137 pos.x += width_Rect(iconRect) + gap_UI * 3 / 2;
@@ -301,7 +302,7 @@ static void searchIdentities_LookupJob_(iLookupJob *d) {
301 iLookupResult *res = new_LookupResult(); 302 iLookupResult *res = new_LookupResult();
302 res->type = identity_LookupResultType; 303 res->type = identity_LookupResultType;
303 res->relevance = identityRelevance_LookupJob_(d, identity); 304 res->relevance = identityRelevance_LookupJob_(d, identity);
304 res->icon = identity->icon; 305 res->icon = 0x1f464; /* identity->icon; */
305 iString *cn = subject_TlsCertificate(identity->cert); 306 iString *cn = subject_TlsCertificate(identity->cert);
306 set_String(&res->label, cn); 307 set_String(&res->label, cn);
307 delete_String(cn); 308 delete_String(cn);
@@ -701,6 +702,12 @@ static iBool processEvent_LookupWidget_(iLookupWidget *d, const SDL_Event *ev) {
701 } 702 }
702 return iTrue; 703 return iTrue;
703 } 704 }
705 if (ev->type == SDL_MOUSEMOTION) {
706 if (contains_Widget(w, init_I2(ev->motion.x, ev->motion.y))) {
707 setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_HAND);
708 }
709 return iFalse;
710 }
704 if (ev->type == SDL_KEYDOWN) { 711 if (ev->type == SDL_KEYDOWN) {
705 const int mods = keyMods_Sym(ev->key.keysym.mod); 712 const int mods = keyMods_Sym(ev->key.keysym.mod);
706 const int key = ev->key.keysym.sym; 713 const int key = ev->key.keysym.sym;
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 950db596..395138bb 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -1680,7 +1680,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1680 : uiText_ColorId; 1680 : uiText_ColorId;
1681 iString str; 1681 iString str;
1682 init_String(&str); 1682 init_String(&str);
1683 appendChar_String(&str, d->icon ? d->icon : 0x1f588); 1683 appendChar_String(&str, d->icon ? d->icon : 0x1f588);
1684 const iRect iconArea = { addX_I2(pos, gap_UI), 1684 const iRect iconArea = { addX_I2(pos, gap_UI),
1685 init_I2(1.75f * lineHeight_Text(font), itemHeight) }; 1685 init_I2(1.75f * lineHeight_Text(font), itemHeight) };
1686 drawCentered_Text(font, 1686 drawCentered_Text(font,
@@ -1694,9 +1694,13 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1694 deinit_String(&str); 1694 deinit_String(&str);
1695 const iInt2 textPos = addY_I2(topRight_Rect(iconArea), (itemHeight - lineHeight_Text(font)) / 2); 1695 const iInt2 textPos = addY_I2(topRight_Rect(iconArea), (itemHeight - lineHeight_Text(font)) / 2);
1696 drawRange_Text(font, textPos, fg, range_String(&d->label)); 1696 drawRange_Text(font, textPos, fg, range_String(&d->label));
1697 const int metaFont = default_FontId;
1698 const int metaIconWidth = 4.5f * gap_UI;
1697 const iInt2 metaPos = 1699 const iInt2 metaPos =
1698 init_I2(right_Rect(itemRect) - advanceRange_Text(font, range_String(&d->meta)).x - 1700 init_I2(right_Rect(itemRect) -
1699 2 * gap_UI - (scrollBarWidth ? scrollBarWidth - gap_UI : 0), 1701 length_String(&d->meta) *
1702 metaIconWidth
1703 - 2 * gap_UI - (blankWidth ? blankWidth - 1.5f * gap_UI : (gap_UI / 2)),
1700 textPos.y); 1704 textPos.y);
1701 fillRect_Paint(p, 1705 fillRect_Paint(p,
1702 init_Rect(metaPos.x, 1706 init_Rect(metaPos.x,
@@ -1704,10 +1708,22 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1704 right_Rect(itemRect) - metaPos.x, 1708 right_Rect(itemRect) - metaPos.x,
1705 height_Rect(itemRect)), 1709 height_Rect(itemRect)),
1706 bg); 1710 bg);
1707 drawRange_Text(font, 1711 iInt2 mpos = metaPos;
1708 metaPos, 1712 iStringConstIterator iter;
1709 isHover && isPressing ? fg : uiTextCaution_ColorId, 1713 init_StringConstIterator(&iter, &d->meta);
1710 range_String(&d->meta)); 1714 iRangecc range = { cstr_String(&d->meta), iter.pos };
1715 while (iter.value) {
1716 next_StringConstIterator(&iter);
1717 range.end = iter.pos;
1718 iRect iconArea = { mpos, init_I2(metaIconWidth, lineHeight_Text(metaFont)) };
1719 iRect visBounds = visualBounds_Text(metaFont, range);
1720 drawRange_Text(metaFont,
1721 sub_I2(mid_Rect(iconArea), mid_Rect(visBounds)),
1722 isHover && isPressing ? fg : uiTextCaution_ColorId,
1723 range);
1724 mpos.x += metaIconWidth;
1725 range.start = range.end;
1726 }
1711 } 1727 }
1712 else if (sidebar->mode == history_SidebarMode) { 1728 else if (sidebar->mode == history_SidebarMode) {
1713 iBeginCollect(); 1729 iBeginCollect();
diff --git a/src/ui/text.c b/src/ui/text.c
index d35b470c..54b0a9da 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -1237,7 +1237,7 @@ iInt2 advanceN_Text(int fontId, const char *text, size_t n) {
1237 return init_I2(advance, lineHeight_Text(fontId)); 1237 return init_I2(advance, lineHeight_Text(fontId));
1238} 1238}
1239 1239
1240static void drawBounded_Text_(int fontId, iInt2 pos, int xposBound, int color, iRangecc text) { 1240static void drawBoundedN_Text_(int fontId, iInt2 pos, int xposBound, int color, iRangecc text, size_t maxLen) {
1241 iText *d = &text_; 1241 iText *d = &text_;
1242 iFont *font = font_Text_(fontId); 1242 iFont *font = font_Text_(fontId);
1243 const iColor clr = get_Color(color & mask_ColorId); 1243 const iColor clr = get_Color(color & mask_ColorId);
@@ -1248,11 +1248,16 @@ static void drawBounded_Text_(int fontId, iInt2 pos, int xposBound, int color, i
1248 (color & fillBackground_ColorId ? fillBackground_RunMode : 0) | 1248 (color & fillBackground_ColorId ? fillBackground_RunMode : 0) |
1249 runFlagsFromId_(fontId), 1249 runFlagsFromId_(fontId),
1250 .text = text, 1250 .text = text,
1251 .maxLen = maxLen,
1251 .pos = pos, 1252 .pos = pos,
1252 .xposLayoutBound = xposBound, 1253 .xposLayoutBound = xposBound,
1253 .color = color & mask_ColorId }); 1254 .color = color & mask_ColorId });
1254} 1255}
1255 1256
1257static void drawBounded_Text_(int fontId, iInt2 pos, int xposBound, int color, iRangecc text) {
1258 drawBoundedN_Text_(fontId, pos, xposBound, color, text, 0);
1259}
1260
1256static void draw_Text_(int fontId, iInt2 pos, int color, iRangecc text) { 1261static void draw_Text_(int fontId, iInt2 pos, int color, iRangecc text) {
1257 drawBounded_Text_(fontId, pos, 0, color, text); 1262 drawBounded_Text_(fontId, pos, 0, color, text);
1258} 1263}
@@ -1295,6 +1300,10 @@ void drawRange_Text(int fontId, iInt2 pos, int color, iRangecc text) {
1295 draw_Text_(fontId, pos, color, text); 1300 draw_Text_(fontId, pos, color, text);
1296} 1301}
1297 1302
1303void drawRangeN_Text(int fontId, iInt2 pos, int color, iRangecc text, size_t maxChars) {
1304 drawBoundedN_Text_(fontId, pos, 0, color, text, maxChars);
1305}
1306
1298iInt2 advanceWrapRange_Text(int fontId, int maxWidth, iRangecc text) { 1307iInt2 advanceWrapRange_Text(int fontId, int maxWidth, iRangecc text) {
1299 iInt2 size = zero_I2(); 1308 iInt2 size = zero_I2();
1300 const char *endp; 1309 const char *endp;
diff --git a/src/ui/text.h b/src/ui/text.h
index 1bb60e8b..3dc38238 100644
--- a/src/ui/text.h
+++ b/src/ui/text.h
@@ -162,6 +162,7 @@ void drawAlign_Text (int fontId, iInt2 pos, int color, enum iAlignment a
162void drawCentered_Text (int fontId, iRect rect, iBool alignVisual, int color, const char *text, ...); 162void drawCentered_Text (int fontId, iRect rect, iBool alignVisual, int color, const char *text, ...);
163void drawString_Text (int fontId, iInt2 pos, int color, const iString *text); 163void drawString_Text (int fontId, iInt2 pos, int color, const iString *text);
164void drawRange_Text (int fontId, iInt2 pos, int color, iRangecc text); 164void drawRange_Text (int fontId, iInt2 pos, int color, iRangecc text);
165void drawRangeN_Text (int fontId, iInt2 pos, int color, iRangecc text, size_t maxLen);
165void drawBoundRange_Text (int fontId, iInt2 pos, int boundWidth, int color, iRangecc text); /* bound does not wrap */ 166void drawBoundRange_Text (int fontId, iInt2 pos, int boundWidth, int color, iRangecc text); /* bound does not wrap */
166int drawWrapRange_Text (int fontId, iInt2 pos, int maxWidth, int color, iRangecc text); /* returns new Y */ 167int drawWrapRange_Text (int fontId, iInt2 pos, int maxWidth, int color, iRangecc text); /* returns new Y */
167 168