From cebb6aa70bb7594a5d3e0202d17ed9f28d7793f9 Mon Sep 17 00:00:00 2001 From: asizon Date: Sun, 4 Jun 2023 11:03:51 +0200 Subject: [PATCH 1/3] 5 Step Scrolling --- .../services/gui/modules/file_browser.c | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/applications/services/gui/modules/file_browser.c b/applications/services/gui/modules/file_browser.c index d12a00ba598..dc05f16ccde 100644 --- a/applications/services/gui/modules/file_browser.c +++ b/applications/services/gui/modules/file_browser.c @@ -110,6 +110,7 @@ typedef struct { bool is_root; bool folder_loading; bool list_loading; + bool large_step; uint32_t item_cnt; int32_t item_idx; int32_t array_offset; @@ -577,6 +578,7 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) { furi_assert(browser); bool consumed = false; bool is_loading = false; + uint8_t step_weight; with_view_model( browser->view, FileBrowserModel * model, { is_loading = model->folder_loading; }, false); @@ -589,9 +591,14 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) { browser->view, FileBrowserModel * model, { + if(model->large_step) { + step_weight = 5; + } else { + step_weight = 1; + } if(event->key == InputKeyUp) { model->item_idx = - ((model->item_idx - 1) + model->item_cnt) % model->item_cnt; + ((model->item_idx - step_weight) + model->item_cnt) % model->item_cnt; if(browser_is_list_load_required(model)) { model->list_loading = true; int32_t load_offset = CLAMP( @@ -603,7 +610,7 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) { } model->scroll_counter = 0; } else if(event->key == InputKeyDown) { - model->item_idx = (model->item_idx + 1) % model->item_cnt; + model->item_idx = (model->item_idx + step_weight) % model->item_cnt; if(browser_is_list_load_required(model)) { model->list_loading = true; int32_t load_offset = CLAMP( @@ -658,10 +665,16 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) { if(event->type == InputTypeShort) { bool is_root = false; with_view_model( - browser->view, FileBrowserModel * model, { is_root = model->is_root; }, false); - if(!is_root) { - file_browser_worker_folder_exit(browser->worker); - } + browser->view, FileBrowserModel * model, + { + is_root = model->is_root; + if(model->large_step) { + model->large_step = false; + } else if(!is_root) { + file_browser_worker_folder_exit(browser->worker); + } + }, + false); consumed = true; } } else if(event->key == InputKeyBack) { @@ -675,6 +688,16 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) { file_browser_worker_folder_exit(browser->worker); } } + } else if(event->key == InputKeyRight) { + with_view_model( + browser->view, + FileBrowserModel * model, + { + if(event->type == InputTypeShort) { + model->large_step = true; + } + }, + false); } return consumed; From 53a496af32f47c3fad9057bae407ce80c08339a5 Mon Sep 17 00:00:00 2001 From: asizon Date: Sun, 4 Jun 2023 12:28:36 +0200 Subject: [PATCH 2/3] clang formatting fixes --- .../services/gui/modules/file_browser.c | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/applications/services/gui/modules/file_browser.c b/applications/services/gui/modules/file_browser.c index dc05f16ccde..b3114a04c30 100644 --- a/applications/services/gui/modules/file_browser.c +++ b/applications/services/gui/modules/file_browser.c @@ -665,7 +665,8 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) { if(event->type == InputTypeShort) { bool is_root = false; with_view_model( - browser->view, FileBrowserModel * model, + browser->view, + FileBrowserModel * model, { is_root = model->is_root; if(model->large_step) { @@ -674,7 +675,7 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) { file_browser_worker_folder_exit(browser->worker); } }, - false); + false); consumed = true; } } else if(event->key == InputKeyBack) { @@ -689,15 +690,15 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) { } } } else if(event->key == InputKeyRight) { - with_view_model( - browser->view, - FileBrowserModel * model, - { - if(event->type == InputTypeShort) { - model->large_step = true; - } - }, - false); + with_view_model( + browser->view, + FileBrowserModel * model, + { + if(event->type == InputTypeShort) { + model->large_step = true; + } + }, + false); } return consumed; From 52f228a0ef66ba22b1e4eadca2da481b855eafe9 Mon Sep 17 00:00:00 2001 From: asizon Date: Sun, 4 Jun 2023 14:45:07 +0200 Subject: [PATCH 3/3] formating fix --- applications/services/gui/modules/file_browser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/services/gui/modules/file_browser.c b/applications/services/gui/modules/file_browser.c index b3114a04c30..dd33acbea94 100644 --- a/applications/services/gui/modules/file_browser.c +++ b/applications/services/gui/modules/file_browser.c @@ -666,7 +666,7 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) { bool is_root = false; with_view_model( browser->view, - FileBrowserModel * model, + FileBrowserModel * model, { is_root = model->is_root; if(model->large_step) {