diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-22 06:09:14 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-22 06:09:14 +0200 |
commit | a042332c14d4710009638d83c87088fbc44c2ab4 (patch) | |
tree | 71ccec08e4a0d7ea5a52136d8fc229558c9ae9ba | |
parent | 4175ca0db94fafcf18072187c462e0b61e71016b (diff) |
SidebarWidget: Feed entry appearance
-rw-r--r-- | src/ui/listwidget.c | 8 | ||||
-rw-r--r-- | src/ui/sidebarwidget.c | 19 |
2 files changed, 18 insertions, 9 deletions
diff --git a/src/ui/listwidget.c b/src/ui/listwidget.c index 28a19b9c..d31ac2f5 100644 --- a/src/ui/listwidget.c +++ b/src/ui/listwidget.c | |||
@@ -136,11 +136,13 @@ void updateVisible_ListWidget(iListWidget *d) { | |||
136 | } | 136 | } |
137 | 137 | ||
138 | void setItemHeight_ListWidget(iListWidget *d, int itemHeight) { | 138 | void setItemHeight_ListWidget(iListWidget *d, int itemHeight) { |
139 | d->itemHeight = itemHeight; | ||
140 | if (deviceType_App() != desktop_AppDeviceType) { | 139 | if (deviceType_App() != desktop_AppDeviceType) { |
141 | d->itemHeight += 1.5 * gap_UI; | 140 | itemHeight += 1.5 * gap_UI; |
141 | } | ||
142 | if (d->itemHeight != itemHeight) { | ||
143 | d->itemHeight = itemHeight; | ||
144 | invalidate_ListWidget(d); | ||
142 | } | 145 | } |
143 | invalidate_ListWidget(d); | ||
144 | } | 146 | } |
145 | 147 | ||
146 | int scrollBarWidth_ListWidget(const iListWidget *d) { | 148 | int scrollBarWidth_ListWidget(const iListWidget *d) { |
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index bbd65268..4857f025 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -191,10 +191,10 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
191 | d->menu = makeMenu_Widget( | 191 | d->menu = makeMenu_Widget( |
192 | as_Widget(d), | 192 | as_Widget(d), |
193 | (iMenuItem[]){ { "Open Entry in New Tab", 0, 0, "feed.entry.opentab" }, | 193 | (iMenuItem[]){ { "Open Entry in New Tab", 0, 0, "feed.entry.opentab" }, |
194 | { "Open Feed Page", 0, 0, "feed.entry.openfeed" }, | ||
195 | { "Mark as Read", 0, 0, "feed.entry.toggleread" }, | 194 | { "Mark as Read", 0, 0, "feed.entry.toggleread" }, |
196 | { "Add Bookmark...", 0, 0, "feed.entry.bookmark" }, | 195 | { "Add Bookmark...", 0, 0, "feed.entry.bookmark" }, |
197 | { "---", 0, 0, NULL }, | 196 | { "---", 0, 0, NULL }, |
197 | { "Open Feed Page", 0, 0, "feed.entry.openfeed" }, | ||
198 | { "Edit Feed...", 0, 0, "feed.entry.edit" }, | 198 | { "Edit Feed...", 0, 0, "feed.entry.edit" }, |
199 | { uiTextCaution_ColorEscape "Unsubscribe...", 0, 0, "feed.entry.unsubscribe" }, | 199 | { uiTextCaution_ColorEscape "Unsubscribe...", 0, 0, "feed.entry.unsubscribe" }, |
200 | { "---", 0, 0, NULL }, | 200 | { "---", 0, 0, NULL }, |
@@ -406,6 +406,11 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | static void updateItemHeight_SidebarWidget_(iSidebarWidget *d) { | ||
410 | const float heights[max_SidebarMode] = { 1.333f, 2.333f, 1.333f, 3.5f, 1.2f }; | ||
411 | setItemHeight_ListWidget(d->list, heights[d->mode] * lineHeight_Text(uiContent_FontId)); | ||
412 | } | ||
413 | |||
409 | iBool setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) { | 414 | iBool setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) { |
410 | if (d->mode == mode) { | 415 | if (d->mode == mode) { |
411 | return iFalse; | 416 | return iFalse; |
@@ -417,11 +422,10 @@ iBool setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) { | |||
417 | for (enum iSidebarMode i = 0; i < max_SidebarMode; i++) { | 422 | for (enum iSidebarMode i = 0; i < max_SidebarMode; i++) { |
418 | setFlags_Widget(as_Widget(d->modeButtons[i]), selected_WidgetFlag, i == d->mode); | 423 | setFlags_Widget(as_Widget(d->modeButtons[i]), selected_WidgetFlag, i == d->mode); |
419 | } | 424 | } |
420 | const float heights[max_SidebarMode] = { 1.333f, 2.333f, 1.333f, 3.5f, 1.2f }; | ||
421 | setBackgroundColor_Widget(as_Widget(d->list), | 425 | setBackgroundColor_Widget(as_Widget(d->list), |
422 | d->mode == documentOutline_SidebarMode ? tmBannerBackground_ColorId | 426 | d->mode == documentOutline_SidebarMode ? tmBannerBackground_ColorId |
423 | : uiBackground_ColorId); | 427 | : uiBackground_ColorId); |
424 | setItemHeight_ListWidget(d->list, heights[mode] * lineHeight_Text(uiContent_FontId)); | 428 | updateItemHeight_SidebarWidget_(d); |
425 | /* Restore previous scroll position. */ | 429 | /* Restore previous scroll position. */ |
426 | setScrollPos_ListWidget(d->list, d->modeScroll[mode]); | 430 | setScrollPos_ListWidget(d->list, d->modeScroll[mode]); |
427 | return iTrue; | 431 | return iTrue; |
@@ -652,6 +656,7 @@ void setWidth_SidebarWidget(iSidebarWidget *d, int width) { | |||
652 | } | 656 | } |
653 | arrange_Widget(findWidget_App("stack")); | 657 | arrange_Widget(findWidget_App("stack")); |
654 | checkModeButtonLayout_SidebarWidget_(d); | 658 | checkModeButtonLayout_SidebarWidget_(d); |
659 | updateItemHeight_SidebarWidget_(d); | ||
655 | if (!isRefreshPending_App()) { | 660 | if (!isRefreshPending_App()) { |
656 | updateSize_DocumentWidget(document_App()); | 661 | updateSize_DocumentWidget(document_App()); |
657 | invalidate_ListWidget(d->list); | 662 | invalidate_ListWidget(d->list); |
@@ -1245,6 +1250,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1245 | else if (sidebar->mode == feeds_SidebarMode) { | 1250 | else if (sidebar->mode == feeds_SidebarMode) { |
1246 | const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId) | 1251 | const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId) |
1247 | : uiText_ColorId; | 1252 | : uiText_ColorId; |
1253 | const int iconPad = 11 * gap_UI; | ||
1248 | if (d->listItem.isSeparator) { | 1254 | if (d->listItem.isSeparator) { |
1249 | if (d != constItem_ListWidget(list, 0)) { | 1255 | if (d != constItem_ListWidget(list, 0)) { |
1250 | drawHLine_Paint(p, | 1256 | drawHLine_Paint(p, |
@@ -1265,7 +1271,6 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1265 | const int titleFont = isUnread ? uiContentBold_FontId : uiContent_FontId; | 1271 | const int titleFont = isUnread ? uiContentBold_FontId : uiContent_FontId; |
1266 | const int h1 = lineHeight_Text(uiLabel_FontId); | 1272 | const int h1 = lineHeight_Text(uiLabel_FontId); |
1267 | const int h2 = lineHeight_Text(titleFont); | 1273 | const int h2 = lineHeight_Text(titleFont); |
1268 | const int iconPad = 9 * gap_UI; | ||
1269 | iRect iconArea = { addY_I2(pos, 0), init_I2(iconPad, itemHeight) }; | 1274 | iRect iconArea = { addY_I2(pos, 0), init_I2(iconPad, itemHeight) }; |
1270 | if (isUnread) { | 1275 | if (isUnread) { |
1271 | fillRect_Paint( | 1276 | fillRect_Paint( |
@@ -1277,12 +1282,14 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1277 | /* TODO: Use the primary hue from the theme of this site. */ | 1282 | /* TODO: Use the primary hue from the theme of this site. */ |
1278 | iString str; | 1283 | iString str; |
1279 | initUnicodeN_String(&str, &d->icon, 1); | 1284 | initUnicodeN_String(&str, &d->icon, 1); |
1280 | drawCentered_Text(uiContent_FontId, | 1285 | drawCentered_Text(uiLabelLarge_FontId, |
1281 | adjusted_Rect(iconArea, init_I2(gap_UI, 0), zero_I2()), | 1286 | adjusted_Rect(iconArea, init_I2(gap_UI, 0), zero_I2()), |
1282 | iTrue, | 1287 | iTrue, |
1283 | isHover && isPressing | 1288 | isHover && isPressing |
1284 | ? iconColor | 1289 | ? iconColor |
1285 | : (isUnread ? uiTextCaution_ColorId : iconColor), | 1290 | : isUnread ? uiTextCaution_ColorId |
1291 | : d->listItem.isSelected ? iconColor | ||
1292 | : uiText_ColorId, | ||
1286 | "%s", | 1293 | "%s", |
1287 | cstr_String(&str)); | 1294 | cstr_String(&str)); |
1288 | deinit_String(&str); | 1295 | deinit_String(&str); |