From 785e057d7170243bf822912e4d669dab2bbe21de Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 23 Nov 2021 12:19:30 +0200 Subject: SidebarWidget: Redesigned Feeds action toolbar The action toolbar now has a button for marking all as read, and keyboard shortcuts for switching between Unread and All modes. --- src/ui/labelwidget.c | 2 +- src/ui/sidebarwidget.c | 24 +++++++++++++++++++----- src/ui/util.c | 4 ++-- 3 files changed, 22 insertions(+), 8 deletions(-) (limited to 'src/ui') diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index daca05d1..46bdc890 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c @@ -421,7 +421,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) { else { drawCenteredOutline_Text( d->font, - adjusted_Rect(bounds, add_I2(zero_I2(), init_I2(iconPad, 0)), neg_I2(zero_I2())), + adjusted_Rect(bounds, init_I2(iconPad * 1.5f, 0), init_I2(-iconPad, 0)), d->flags.alignVisual, d->flags.drawAsOutline ? fg : none_ColorId, d->flags.drawAsOutline ? d->widget.bgColor : fg, diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 5d627dda..581a7bb2 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c @@ -346,10 +346,24 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { } } /* Actions. */ { - addActionButton_SidebarWidget_(d, "${sidebar.action.feeds.showall}", "feeds.mode arg:0", - d->feedsMode == all_FeedsMode ? selected_WidgetFlag : 0); - addActionButton_SidebarWidget_(d, "${sidebar.action.feeds.showunread}", "feeds.mode arg:1", - d->feedsMode == unread_FeedsMode ? selected_WidgetFlag : 0); + addActionButton_SidebarWidget_( + d, check_Icon " ${feeds.markallread}", "feeds.markallread", expand_WidgetFlag); + addChild_Widget(d->actions, iClob(new_LabelWidget("${sidebar.action.show}", NULL))); + const iMenuItem items[] = { + { "${sidebar.action.feeds.showall}", SDLK_u, KMOD_SHIFT, "feeds.mode arg:0" }, + { "${sidebar.action.feeds.showunread}", SDLK_u, 0, "feeds.mode arg:1" }, + }; + iWidget *dropButton = addChild_Widget( + d->actions, + iClob(makeMenuButton_LabelWidget(items[d->feedsMode].label, items, 2))); + setFixedSize_Widget( + dropButton, + init_I2(measure_Text( + default_FontId, + translateCStr_Lang(items[findWidestLabel_MenuItem(items, 2)].label)) + .advance.x + + 6 * gap_UI, + -1)); } d->menu = makeMenu_Widget( as_Widget(d), @@ -995,7 +1009,7 @@ iBool handleBookmarkEditorCommands_SidebarWidget_(iWidget *editor, const char *c setBookmarkEditorFolder_Widget(editor, arg_Command(cmd)); return iTrue; } - if (equal_Command(cmd, "bmed.accept") || equal_Command(cmd, "cancel")) { + if (equal_Command(cmd, "bmed.accept") || equal_Command(cmd, "bmed.cancel")) { iAssert(startsWith_String(id_Widget(editor), "bmed.")); iSidebarWidget *d = findWidget_App(cstr_String(id_Widget(editor)) + 5); /* bmed.sidebar */ if (equal_Command(cmd, "bmed.accept")) { diff --git a/src/ui/util.c b/src/ui/util.c index ba6a2538..e718631d 100644 --- a/src/ui/util.c +++ b/src/ui/util.c @@ -2811,7 +2811,7 @@ static const iArray *makeBookmarkFolderItems_(void) { iWidget *makeBookmarkEditor_Widget(void) { const iMenuItem actions[] = { - { "${cancel}" }, + { "${cancel}", 0, 0, "bmed.cancel" }, { uiTextCaution_ColorEscape "${dlg.bookmark.save}", SDLK_RETURN, KMOD_PRIMARY, "bmed.accept" } }; if (isUsingPanelLayout_Mobile()) { @@ -2891,7 +2891,7 @@ static iBool handleBookmarkCreationCommands_SidebarWidget_(iWidget *editor, cons setBookmarkEditorFolder_Widget(editor, arg_Command(cmd)); return iTrue; } - if (equal_Command(cmd, "bmed.accept") || equal_Command(cmd, "cancel")) { + if (equal_Command(cmd, "bmed.accept") || equal_Command(cmd, "bmed.cancel")) { if (equal_Command(cmd, "bmed.accept")) { const iString *title = text_InputWidget(findChild_Widget(editor, "bmed.title")); const iString *url = text_InputWidget(findChild_Widget(editor, "bmed.url")); -- cgit v1.2.3