diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-13 07:55:14 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-13 07:55:14 +0300 |
commit | ce16c3baf6b43e237627eb0675297a32c03eab9c (patch) | |
tree | bac174a5a31c21a7b538d3ddd44331c1425ce6d6 /src/ui/sidebarwidget.c | |
parent | 767d9b363171b1f86d223dda34bd5ffa8addf072 (diff) |
SidebarWidget: Never disable for context menu
Sidebars were disabled so the hover item wouldn't change while accessing a context menu, but that's no longer necessary because the context item is tracked separately.
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r-- | src/ui/sidebarwidget.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index eae0432f..3d785e0a 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -106,7 +106,8 @@ struct Impl_SidebarWidget { | |||
106 | size_t numUnreadEntries; | 106 | size_t numUnreadEntries; |
107 | iWidget * resizer; | 107 | iWidget * resizer; |
108 | iWidget * menu; | 108 | iWidget * menu; |
109 | iSidebarItem * contextItem; /* list item accessed in the context menu */ | 109 | iSidebarItem * contextItem; /* list item accessed in the context menu */ |
110 | size_t contextIndex; /* index of list item accessed in the context menu */ | ||
110 | }; | 111 | }; |
111 | 112 | ||
112 | iDefineObjectConstructionArgs(SidebarWidget, (enum iSidebarSide side), side) | 113 | iDefineObjectConstructionArgs(SidebarWidget, (enum iSidebarSide side), side) |
@@ -644,6 +645,7 @@ void init_SidebarWidget(iSidebarWidget *d, enum iSidebarSide side) { | |||
644 | "actions"); | 645 | "actions"); |
645 | setBackgroundColor_Widget(d->actions, uiBackgroundSidebar_ColorId); | 646 | setBackgroundColor_Widget(d->actions, uiBackgroundSidebar_ColorId); |
646 | d->contextItem = NULL; | 647 | d->contextItem = NULL; |
648 | d->contextIndex = iInvalidPos; | ||
647 | d->blank = new_Widget(); | 649 | d->blank = new_Widget(); |
648 | addChildFlags_Widget(content, iClob(d->blank), resizeChildren_WidgetFlag); | 650 | addChildFlags_Widget(content, iClob(d->blank), resizeChildren_WidgetFlag); |
649 | addChildFlags_Widget(vdiv, iClob(content), expand_WidgetFlag); | 651 | addChildFlags_Widget(vdiv, iClob(content), expand_WidgetFlag); |
@@ -844,7 +846,6 @@ iBool handleBookmarkEditorCommands_SidebarWidget_(iWidget *editor, const char *c | |||
844 | isSelected_Widget(findChild_Widget(editor, "bmed.tag.linksplit"))); | 846 | isSelected_Widget(findChild_Widget(editor, "bmed.tag.linksplit"))); |
845 | postCommand_App("bookmarks.changed"); | 847 | postCommand_App("bookmarks.changed"); |
846 | } | 848 | } |
847 | setFlags_Widget(as_Widget(d), disabled_WidgetFlag, iFalse); | ||
848 | destroy_Widget(editor); | 849 | destroy_Widget(editor); |
849 | return iTrue; | 850 | return iTrue; |
850 | } | 851 | } |
@@ -985,11 +986,8 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
985 | itemClicked_SidebarWidget_(d, pointerLabel_Command(cmd, "item")); | 986 | itemClicked_SidebarWidget_(d, pointerLabel_Command(cmd, "item")); |
986 | return iTrue; | 987 | return iTrue; |
987 | } | 988 | } |
988 | else if (isCommand_Widget(w, ev, "menu.opened")) { | ||
989 | setFlags_Widget(as_Widget(d->list), disabled_WidgetFlag, iTrue); | ||
990 | } | ||
991 | else if (isCommand_Widget(w, ev, "menu.closed")) { | 989 | else if (isCommand_Widget(w, ev, "menu.closed")) { |
992 | setFlags_Widget(as_Widget(d->list), disabled_WidgetFlag, iFalse); | 990 | // invalidateItem_ListWidget(d->list, d->contextIndex); |
993 | } | 991 | } |
994 | else if (isCommand_Widget(w, ev, "bookmark.open")) { | 992 | else if (isCommand_Widget(w, ev, "bookmark.open")) { |
995 | const iSidebarItem *item = d->contextItem; | 993 | const iSidebarItem *item = d->contextItem; |
@@ -1010,7 +1008,6 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
1010 | else if (isCommand_Widget(w, ev, "bookmark.edit")) { | 1008 | else if (isCommand_Widget(w, ev, "bookmark.edit")) { |
1011 | const iSidebarItem *item = d->contextItem; | 1009 | const iSidebarItem *item = d->contextItem; |
1012 | if (d->mode == bookmarks_SidebarMode && item) { | 1010 | if (d->mode == bookmarks_SidebarMode && item) { |
1013 | setFlags_Widget(w, disabled_WidgetFlag, iTrue); | ||
1014 | iWidget *dlg = makeBookmarkEditor_Widget(); | 1011 | iWidget *dlg = makeBookmarkEditor_Widget(); |
1015 | setId_Widget(dlg, format_CStr("bmed.%s", cstr_String(id_Widget(w)))); | 1012 | setId_Widget(dlg, format_CStr("bmed.%s", cstr_String(id_Widget(w)))); |
1016 | iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id); | 1013 | iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id); |
@@ -1038,7 +1035,6 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
1038 | else if (isCommand_Widget(w, ev, "bookmark.dup")) { | 1035 | else if (isCommand_Widget(w, ev, "bookmark.dup")) { |
1039 | const iSidebarItem *item = d->contextItem; | 1036 | const iSidebarItem *item = d->contextItem; |
1040 | if (d->mode == bookmarks_SidebarMode && item) { | 1037 | if (d->mode == bookmarks_SidebarMode && item) { |
1041 | setFlags_Widget(w, disabled_WidgetFlag, iTrue); | ||
1042 | iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id); | 1038 | iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id); |
1043 | const iBool isRemote = hasTag_Bookmark(bm, remote_BookmarkTag); | 1039 | const iBool isRemote = hasTag_Bookmark(bm, remote_BookmarkTag); |
1044 | iChar icon = isRemote ? 0x1f588 : bm->icon; | 1040 | iChar icon = isRemote ? 0x1f588 : bm->icon; |
@@ -1131,7 +1127,6 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
1131 | return iTrue; | 1127 | return iTrue; |
1132 | } | 1128 | } |
1133 | if (isCommand_Widget(w, ev, "feed.entry.edit")) { | 1129 | if (isCommand_Widget(w, ev, "feed.entry.edit")) { |
1134 | setFlags_Widget(w, disabled_WidgetFlag, iTrue); | ||
1135 | makeFeedSettings_Widget(id_Bookmark(feedBookmark)); | 1130 | makeFeedSettings_Widget(id_Bookmark(feedBookmark)); |
1136 | return iTrue; | 1131 | return iTrue; |
1137 | } | 1132 | } |
@@ -1307,6 +1302,10 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
1307 | setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW); | 1302 | setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW); |
1308 | } | 1303 | } |
1309 | } | 1304 | } |
1305 | if (d->contextIndex != iInvalidPos) { | ||
1306 | invalidateItem_ListWidget(d->list, d->contextIndex); | ||
1307 | d->contextIndex = iInvalidPos; | ||
1308 | } | ||
1310 | } | 1309 | } |
1311 | if (d->menu && ev->type == SDL_MOUSEBUTTONDOWN) { | 1310 | if (d->menu && ev->type == SDL_MOUSEBUTTONDOWN) { |
1312 | if (ev->button.button == SDL_BUTTON_RIGHT) { | 1311 | if (ev->button.button == SDL_BUTTON_RIGHT) { |
@@ -1315,7 +1314,12 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
1315 | updateMouseHover_ListWidget(d->list); | 1314 | updateMouseHover_ListWidget(d->list); |
1316 | } | 1315 | } |
1317 | if (constHoverItem_ListWidget(d->list) || isVisible_Widget(d->menu)) { | 1316 | if (constHoverItem_ListWidget(d->list) || isVisible_Widget(d->menu)) { |
1318 | d->contextItem = hoverItem_ListWidget(d->list); | 1317 | d->contextItem = hoverItem_ListWidget(d->list); |
1318 | /* Context is drawn in hover state. */ | ||
1319 | if (d->contextIndex != iInvalidPos) { | ||
1320 | invalidateItem_ListWidget(d->list, d->contextIndex); | ||
1321 | } | ||
1322 | d->contextIndex = hoverItemIndex_ListWidget(d->list); | ||
1319 | /* Update menu items. */ | 1323 | /* Update menu items. */ |
1320 | /* TODO: Some callback-based mechanism would be nice for updating menus right | 1324 | /* TODO: Some callback-based mechanism would be nice for updating menus right |
1321 | before they open? */ | 1325 | before they open? */ |
@@ -1436,9 +1440,13 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1436 | const iListWidget *list) { | 1440 | const iListWidget *list) { |
1437 | const iSidebarWidget *sidebar = findParentClass_Widget(constAs_Widget(list), | 1441 | const iSidebarWidget *sidebar = findParentClass_Widget(constAs_Widget(list), |
1438 | &Class_SidebarWidget); | 1442 | &Class_SidebarWidget); |
1443 | const iBool isMenuVisible = isVisible_Widget(sidebar->menu); | ||
1439 | const iBool isPressing = isMouseDown_ListWidget(list); | 1444 | const iBool isPressing = isMouseDown_ListWidget(list); |
1440 | const iBool isHover = isHover_Widget(constAs_Widget(list)) && | 1445 | const iBool isHover = |
1441 | constHoverItem_ListWidget(list) == d; | 1446 | (!isMenuVisible && |
1447 | isHover_Widget(constAs_Widget(list)) && | ||
1448 | constHoverItem_ListWidget(list) == d) || | ||
1449 | (isMenuVisible && sidebar->contextItem == d); | ||
1442 | const int scrollBarWidth = scrollBarWidth_ListWidget(list); | 1450 | const int scrollBarWidth = scrollBarWidth_ListWidget(list); |
1443 | #if defined (iPlatformApple) | 1451 | #if defined (iPlatformApple) |
1444 | const int blankWidth = 0; | 1452 | const int blankWidth = 0; |