Other scrolling method - fix hack (#122)

* other method: leave scrolling to icon updating function
downside: scroll can lag behind the selected entry if going too fast

* bring back looping so scrolling doesnt lag behind as much when going out of bounds
only about a second lag, then a second again for icons to load

* this method doesnt need to know the ids

* fix memory leak

* optimize for invisibility

* fix lockup when install checking threads are finished

* less magic, again
make icon loading functions/numbers more general

* increase wait time for fastcroll to give people more time to react, and to prevent some lag for the loading function
This commit is contained in:
LiquidFenrir
2017-12-31 05:01:31 +01:00
committed by Alex Taber
parent 841773d9e4
commit f65b32c90c
3 changed files with 107 additions and 142 deletions

View File

@@ -34,7 +34,7 @@
#include "pp2d/pp2d/pp2d.h"
#include <time.h>
#define FASTSCROLL_WAIT 1e8
#define FASTSCROLL_WAIT 1.5e8
static bool homebrew = false;
static bool installed_themes = false;
@@ -88,7 +88,6 @@ static void stop_install_check(void)
if(installCheckThreads_arg[i].run_thread)
{
installCheckThreads_arg[i].run_thread = false;
threadJoin(installCheckThreads[i], U64_MAX);
}
}
}
@@ -183,45 +182,6 @@ static void jump_menu(Entry_List_s * list)
}
}
static void handle_scrolling(Entry_List_s * list)
{
// Scroll the menu up or down if the selected theme is out of its bounds
//----------------------------------------------------------------
if(list->entries_count > ENTRIES_PER_SCREEN)
{
if(list->entries_count > ENTRIES_PER_SCREEN*2 && list->previous_scroll < ENTRIES_PER_SCREEN && list->selected_entry >= list->entries_count - ENTRIES_PER_SCREEN)
{
list->scroll = list->entries_count - ENTRIES_PER_SCREEN;
}
else if(list->entries_count > ENTRIES_PER_SCREEN*2 && list->selected_entry < ENTRIES_PER_SCREEN && list->previous_selected >= list->entries_count - ENTRIES_PER_SCREEN)
{
list->scroll = 0;
}
else if(list->selected_entry == list->previous_selected+1 && list->selected_entry == list->scroll+ENTRIES_PER_SCREEN)
{
list->scroll++;
}
else if(list->selected_entry == list->previous_selected-1 && list->selected_entry == list->scroll-1)
{
list->scroll--;
}
else if(list->selected_entry == list->previous_selected+ENTRIES_PER_SCREEN || list->selected_entry >= list->scroll + ENTRIES_PER_SCREEN)
{
list->scroll += ENTRIES_PER_SCREEN;
}
else if(list->selected_entry == list->previous_selected-ENTRIES_PER_SCREEN || list->selected_entry < list->scroll)
{
list->scroll -= ENTRIES_PER_SCREEN;
}
if(list->scroll < 0)
list->scroll = 0;
if(list->scroll > list->entries_count - ENTRIES_PER_SCREEN)
list->scroll = list->entries_count - ENTRIES_PER_SCREEN;
}
//----------------------------------------------------------------
}
static void change_selected(Entry_List_s * list, int change_value)
{
if(abs(change_value) >= list->entries_count) return;
@@ -348,12 +308,16 @@ int main(void)
if(qr_mode) take_picture();
else if(preview_mode) draw_preview(preview_offset);
else {
handle_scrolling(current_list);
svcSignalEvent(update_icons_handle);
svcSleepThread(1e6);
current_list->previous_scroll = current_list->scroll;
current_list->previous_selected = current_list->selected_entry;
if(!iconLoadingThread_arg.run_thread)
{
handle_scrolling(current_list);
current_list->previous_scroll = current_list->scroll;
}
else
{
svcSignalEvent(update_icons_handle);
svcSleepThread(5e6);
}
draw_interface(current_list, instructions);
svcSleepThread(1e7);
@@ -606,12 +570,10 @@ int main(void)
else if(kDown & KEY_LEFT)
{
change_selected(current_list, -ENTRIES_PER_SCREEN);
load_icons_first(current_list, true);
}
else if(kDown & KEY_RIGHT)
{
change_selected(current_list, ENTRIES_PER_SCREEN);
load_icons_first(current_list, true);
}
// Fast scroll using circle pad
@@ -657,7 +619,6 @@ int main(void)
if(BETWEEN(arrowStartX, x, arrowEndX) && current_list->scroll > 0)
{
change_selected(current_list, -ENTRIES_PER_SCREEN);
load_icons_first(current_list, true);
}
else if(BETWEEN(320-24, x, 320))
{
@@ -685,7 +646,6 @@ int main(void)
if(BETWEEN(arrowStartX, x, arrowEndX) && current_list->scroll < current_list->entries_count - ENTRIES_PER_SCREEN)
{
change_selected(current_list, ENTRIES_PER_SCREEN);
load_icons_first(current_list, true);
}
else if(BETWEEN(176, x, 320))
{