Skip to content

Commit

Permalink
Launcher: Test sticky center #77
Browse files Browse the repository at this point in the history
  • Loading branch information
ducalex committed Jan 25, 2023
1 parent 67755f7 commit 955a106
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions launcher/main/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,21 @@ void gui_draw_list(tab_t *tab)
{
line_offset = (list->cursor / lines) * lines;
}
else if (gui.scroll_mode == SCROLL_MODE_STICKY)
{
if (list->cursor < lines / 2)
{
line_offset = 0;
}
else if (list->cursor > list->length - (lines / 2))
{
line_offset = list->length - lines;
}
else
{
line_offset = list->cursor - (lines / 2);
}
}
else // (gui.scroll_mode == SCROLL_MODE_CENTER)
{
line_offset = list->cursor - (lines / 2);
Expand Down
1 change: 1 addition & 0 deletions launcher/main/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ typedef enum {
typedef enum {
SCROLL_MODE_CENTER,
SCROLL_MODE_PAGING,
SCROLL_MODE_STICKY,
// SCROLL_MODE_EDGE,
SCROLL_MODE_COUNT,
} scroll_mode_t;
Expand Down
2 changes: 1 addition & 1 deletion launcher/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static rg_gui_event_t toggle_tabs_cb(rg_gui_option_t *option, rg_gui_event_t eve

static rg_gui_event_t scroll_mode_cb(rg_gui_option_t *option, rg_gui_event_t event)
{
const char *modes[SCROLL_MODE_COUNT] = {"Center", "Paging"};
const char *modes[SCROLL_MODE_COUNT] = {"Center", "Paging", "Sticky"};
const int max = SCROLL_MODE_COUNT - 1;

if (event == RG_DIALOG_PREV && --gui.scroll_mode < 0)
Expand Down

0 comments on commit 955a106

Please sign in to comment.