diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-20 15:21:38 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-20 15:21:38 +0300 |
commit | 046869954cceb49f106e3a5051517050a5515b31 (patch) | |
tree | 4c821ebade322fd7f7cd01190ffba022524922af /src/ui | |
parent | 84e0c6b13cfc2e73fc58f0f26ec4207fc9b4ca1f (diff) |
SidebarWidget: Highlight identities used on current domain
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/sidebarwidget.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 55c74774..aa58eb45 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -433,6 +433,7 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
433 | } | 433 | } |
434 | case identities_SidebarMode: { | 434 | case identities_SidebarMode: { |
435 | const iString *tabUrl = url_DocumentWidget(document_App()); | 435 | const iString *tabUrl = url_DocumentWidget(document_App()); |
436 | const iRangecc tabHost = urlHost_String(tabUrl); | ||
436 | isEmpty = iTrue; | 437 | isEmpty = iTrue; |
437 | iConstForEach(PtrArray, i, identities_GmCerts(certs_App())) { | 438 | iConstForEach(PtrArray, i, identities_GmCerts(certs_App())) { |
438 | const iGmIdentity *ident = i.ptr; | 439 | const iGmIdentity *ident = i.ptr; |
@@ -467,6 +468,9 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
467 | cstr_String(&ident->notes)); | 468 | cstr_String(&ident->notes)); |
468 | } | 469 | } |
469 | item->listItem.isSelected = isActive; | 470 | item->listItem.isSelected = isActive; |
471 | if (isUsedOnDomain_GmIdentity(ident, tabHost)) { | ||
472 | item->indent = 1; /* will be highlighted */ | ||
473 | } | ||
470 | addItem_ListWidget(d->list, item); | 474 | addItem_ListWidget(d->list, item); |
471 | iRelease(item); | 475 | iRelease(item); |
472 | isEmpty = iFalse; | 476 | isEmpty = iFalse; |
@@ -1540,6 +1544,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1540 | const int itemHeight = height_Rect(itemRect); | 1544 | const int itemHeight = height_Rect(itemRect); |
1541 | const int iconColor = isHover ? (isPressing ? uiTextPressed_ColorId : uiIconHover_ColorId) | 1545 | const int iconColor = isHover ? (isPressing ? uiTextPressed_ColorId : uiIconHover_ColorId) |
1542 | : uiIcon_ColorId; | 1546 | : uiIcon_ColorId; |
1547 | const int altIconColor = isPressing ? uiTextPressed_ColorId : uiTextCaution_ColorId; | ||
1543 | const int font = sidebar->itemFonts[d->isBold ? 1 : 0]; | 1548 | const int font = sidebar->itemFonts[d->isBold ? 1 : 0]; |
1544 | int bg = uiBackgroundSidebar_ColorId; | 1549 | int bg = uiBackgroundSidebar_ColorId; |
1545 | if (isHover) { | 1550 | if (isHover) { |
@@ -1730,6 +1735,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1730 | else if (sidebar->mode == identities_SidebarMode) { | 1735 | else if (sidebar->mode == identities_SidebarMode) { |
1731 | const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId) | 1736 | const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId) |
1732 | : uiTextStrong_ColorId; | 1737 | : uiTextStrong_ColorId; |
1738 | const iBool isUsedOnDomain = (d->indent != 0); | ||
1733 | iString icon; | 1739 | iString icon; |
1734 | initUnicodeN_String(&icon, &d->icon, 1); | 1740 | initUnicodeN_String(&icon, &d->icon, 1); |
1735 | iInt2 cPos = topLeft_Rect(itemRect); | 1741 | iInt2 cPos = topLeft_Rect(itemRect); |
@@ -1741,7 +1747,8 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1741 | const int metaFg = isHover ? permanent_ColorId | (isPressing ? uiTextPressed_ColorId | 1747 | const int metaFg = isHover ? permanent_ColorId | (isPressing ? uiTextPressed_ColorId |
1742 | : uiTextFramelessHover_ColorId) | 1748 | : uiTextFramelessHover_ColorId) |
1743 | : uiTextDim_ColorId; | 1749 | : uiTextDim_ColorId; |
1744 | if (!d->listItem.isSelected) { | 1750 | if (!d->listItem.isSelected && !isUsedOnDomain) { |
1751 | /* Draw an outline of the icon. */ | ||
1745 | for (int off = 0; off < 4; ++off) { | 1752 | for (int off = 0; off < 4; ++off) { |
1746 | drawRange_Text(font, | 1753 | drawRange_Text(font, |
1747 | add_I2(cPos, init_I2(off % 2 == 0 ? -1 : 1, off / 2 == 0 ? -1 : 1)), | 1754 | add_I2(cPos, init_I2(off % 2 == 0 ? -1 : 1, off / 2 == 0 ? -1 : 1)), |
@@ -1749,8 +1756,12 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1749 | range_String(&icon)); | 1756 | range_String(&icon)); |
1750 | } | 1757 | } |
1751 | } | 1758 | } |
1752 | drawRange_Text( | 1759 | drawRange_Text(font, |
1753 | font, cPos, d->listItem.isSelected ? iconColor : uiBackgroundSidebar_ColorId /*metaFg*/, range_String(&icon)); | 1760 | cPos, |
1761 | d->listItem.isSelected ? iconColor | ||
1762 | : isUsedOnDomain ? altIconColor | ||
1763 | : uiBackgroundSidebar_ColorId, | ||
1764 | range_String(&icon)); | ||
1754 | deinit_String(&icon); | 1765 | deinit_String(&icon); |
1755 | drawRange_Text(d->listItem.isSelected ? sidebar->itemFonts[1] : font, | 1766 | drawRange_Text(d->listItem.isSelected ? sidebar->itemFonts[1] : font, |
1756 | add_I2(cPos, init_I2(indent, 0)), | 1767 | add_I2(cPos, init_I2(indent, 0)), |