mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 04:41:26 +04:00
[FL-3373] Scroll acceleration (#2784)
* Support for scroll acceleration * Revert keyboard acceleration * Add scroll acceleration to the text box * Remove redundant code from the file manager input handler * Archive: slightly better scrolling * Gui,Archive: final version of accelerated scrolling Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -334,9 +334,22 @@ static bool archive_view_input(InputEvent* event, void* context) {
|
||||
browser->view,
|
||||
ArchiveBrowserViewModel * model,
|
||||
{
|
||||
int32_t scroll_speed = 1;
|
||||
if(model->button_held_for_ticks > 5) {
|
||||
if(model->button_held_for_ticks % 2) {
|
||||
scroll_speed = 0;
|
||||
} else {
|
||||
scroll_speed = model->button_held_for_ticks > 9 ? 4 : 2;
|
||||
}
|
||||
}
|
||||
|
||||
if(event->key == InputKeyUp) {
|
||||
if(model->item_idx < scroll_speed) {
|
||||
scroll_speed = model->item_idx;
|
||||
}
|
||||
|
||||
model->item_idx =
|
||||
((model->item_idx - 1) + model->item_cnt) % model->item_cnt;
|
||||
((model->item_idx - scroll_speed) + model->item_cnt) % model->item_cnt;
|
||||
if(is_file_list_load_required(model)) {
|
||||
model->list_loading = true;
|
||||
browser->callback(ArchiveBrowserEventLoadPrevItems, browser->context);
|
||||
@@ -345,8 +358,14 @@ static bool archive_view_input(InputEvent* event, void* context) {
|
||||
browser->callback(ArchiveBrowserEventFavMoveUp, browser->context);
|
||||
}
|
||||
model->scroll_counter = 0;
|
||||
model->button_held_for_ticks += 1;
|
||||
} else if(event->key == InputKeyDown) {
|
||||
model->item_idx = (model->item_idx + 1) % model->item_cnt;
|
||||
int32_t count = model->item_cnt;
|
||||
if(model->item_idx >= (count - scroll_speed)) {
|
||||
scroll_speed = model->item_cnt - model->item_idx - 1;
|
||||
}
|
||||
|
||||
model->item_idx = (model->item_idx + scroll_speed) % model->item_cnt;
|
||||
if(is_file_list_load_required(model)) {
|
||||
model->list_loading = true;
|
||||
browser->callback(ArchiveBrowserEventLoadNextItems, browser->context);
|
||||
@@ -355,6 +374,7 @@ static bool archive_view_input(InputEvent* event, void* context) {
|
||||
browser->callback(ArchiveBrowserEventFavMoveDown, browser->context);
|
||||
}
|
||||
model->scroll_counter = 0;
|
||||
model->button_held_for_ticks += 1;
|
||||
}
|
||||
},
|
||||
true);
|
||||
@@ -391,6 +411,14 @@ static bool archive_view_input(InputEvent* event, void* context) {
|
||||
}
|
||||
}
|
||||
|
||||
if(event->type == InputTypeRelease) {
|
||||
with_view_model(
|
||||
browser->view,
|
||||
ArchiveBrowserViewModel * model,
|
||||
{ model->button_held_for_ticks = 0; },
|
||||
true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user