diff options
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r-- | src/ui/sidebarwidget.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 55538812..57562cab 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -250,8 +250,10 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
250 | invalidate_ListWidget(d->list); | 250 | invalidate_ListWidget(d->list); |
251 | } | 251 | } |
252 | 252 | ||
253 | void setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) { | 253 | iBool setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) { |
254 | if (d->mode == mode) return; | 254 | if (d->mode == mode) { |
255 | return iFalse; | ||
256 | } | ||
255 | if (d->mode >= 0 && d->mode < max_SidebarMode) { | 257 | if (d->mode >= 0 && d->mode < max_SidebarMode) { |
256 | d->modeScroll[d->mode] = scrollPos_ListWidget(d->list); /* saved for later */ | 258 | d->modeScroll[d->mode] = scrollPos_ListWidget(d->list); /* saved for later */ |
257 | } | 259 | } |
@@ -266,6 +268,7 @@ void setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) { | |||
266 | setItemHeight_ListWidget(d->list, heights[mode] * lineHeight_Text(uiContent_FontId)); | 268 | setItemHeight_ListWidget(d->list, heights[mode] * lineHeight_Text(uiContent_FontId)); |
267 | /* Restore previous scroll position. */ | 269 | /* Restore previous scroll position. */ |
268 | setScrollPos_ListWidget(d->list, d->modeScroll[mode]); | 270 | setScrollPos_ListWidget(d->list, d->modeScroll[mode]); |
271 | return iTrue; | ||
269 | } | 272 | } |
270 | 273 | ||
271 | enum iSidebarMode mode_SidebarWidget(const iSidebarWidget *d) { | 274 | enum iSidebarMode mode_SidebarWidget(const iSidebarWidget *d) { |
@@ -501,10 +504,11 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
501 | return iTrue; | 504 | return iTrue; |
502 | } | 505 | } |
503 | else if (equal_Command(cmd, "sidebar.mode")) { | 506 | else if (equal_Command(cmd, "sidebar.mode")) { |
504 | setMode_SidebarWidget(d, arg_Command(cmd)); | 507 | const iBool wasChanged = setMode_SidebarWidget(d, arg_Command(cmd)); |
505 | updateItems_SidebarWidget_(d); | 508 | updateItems_SidebarWidget_(d); |
506 | if (argLabel_Command(cmd, "show") && !isVisible_Widget(w)) { | 509 | if ((argLabel_Command(cmd, "show") && !isVisible_Widget(w)) || |
507 | postCommand_App("sidebar.toggle arg:1"); | 510 | (argLabel_Command(cmd, "toggle") && !wasChanged)) { |
511 | postCommand_App("sidebar.toggle"); | ||
508 | } | 512 | } |
509 | scrollOffset_ListWidget(d->list, 0); | 513 | scrollOffset_ListWidget(d->list, 0); |
510 | return iTrue; | 514 | return iTrue; |