diff --git a/romfs/scroll_bar.png b/romfs/scroll_bar.png new file mode 100644 index 0000000..a491c13 Binary files /dev/null and b/romfs/scroll_bar.png differ diff --git a/source/core/screen.c b/source/core/screen.c index 8dc14a9..75f8c00 100644 --- a/source/core/screen.c +++ b/source/core/screen.c @@ -219,6 +219,7 @@ void screen_init() { screen_load_texture_file(TEXTURE_TOP_SCREEN_BOTTOM_BAR_SHADOW, "top_screen_bottom_bar_shadow.png", true); screen_load_texture_file(TEXTURE_LOGO, "logo.png", true); screen_load_texture_file(TEXTURE_SELECTION_OVERLAY, "selection_overlay.png", true); + screen_load_texture_file(TEXTURE_SCROLL_BAR, "scroll_bar.png", true); screen_load_texture_file(TEXTURE_BUTTON_SMALL, "button_small.png", true); screen_load_texture_file(TEXTURE_BUTTON_LARGE, "button_large.png", true); screen_load_texture_file(TEXTURE_PROGRESS_BAR_BG, "progress_bar_bg.png", true); diff --git a/source/core/screen.h b/source/core/screen.h index f791635..4147c22 100644 --- a/source/core/screen.h +++ b/source/core/screen.h @@ -20,25 +20,26 @@ #define TEXTURE_TOP_SCREEN_BOTTOM_BAR_SHADOW 9 #define TEXTURE_LOGO 10 #define TEXTURE_SELECTION_OVERLAY 11 -#define TEXTURE_BUTTON_SMALL 12 -#define TEXTURE_BUTTON_LARGE 13 -#define TEXTURE_PROGRESS_BAR_BG 14 -#define TEXTURE_PROGRESS_BAR_CONTENT 15 -#define TEXTURE_META_INFO_BOX 16 -#define TEXTURE_META_INFO_BOX_SHADOW 17 -#define TEXTURE_BATTERY_CHARGING 18 -#define TEXTURE_BATTERY_0 19 -#define TEXTURE_BATTERY_1 20 -#define TEXTURE_BATTERY_2 21 -#define TEXTURE_BATTERY_3 22 -#define TEXTURE_BATTERY_4 23 -#define TEXTURE_BATTERY_5 24 -#define TEXTURE_WIFI_DISCONNECTED 25 -#define TEXTURE_WIFI_0 26 -#define TEXTURE_WIFI_1 27 -#define TEXTURE_WIFI_2 28 -#define TEXTURE_WIFI_3 29 -#define TEXTURE_AUTO_START 30 +#define TEXTURE_SCROLL_BAR 12 +#define TEXTURE_BUTTON_SMALL 13 +#define TEXTURE_BUTTON_LARGE 14 +#define TEXTURE_PROGRESS_BAR_BG 15 +#define TEXTURE_PROGRESS_BAR_CONTENT 16 +#define TEXTURE_META_INFO_BOX 17 +#define TEXTURE_META_INFO_BOX_SHADOW 18 +#define TEXTURE_BATTERY_CHARGING 19 +#define TEXTURE_BATTERY_0 20 +#define TEXTURE_BATTERY_1 21 +#define TEXTURE_BATTERY_2 22 +#define TEXTURE_BATTERY_3 23 +#define TEXTURE_BATTERY_4 24 +#define TEXTURE_BATTERY_5 25 +#define TEXTURE_WIFI_DISCONNECTED 26 +#define TEXTURE_WIFI_0 27 +#define TEXTURE_WIFI_1 28 +#define TEXTURE_WIFI_2 29 +#define TEXTURE_WIFI_3 30 +#define TEXTURE_AUTO_START 31 #define NUM_COLORS 6 diff --git a/source/ui/list.c b/source/ui/list.c index d9e5a6b..5aea00e 100644 --- a/source/ui/list.c +++ b/source/ui/list.c @@ -243,6 +243,28 @@ static void list_draw_bottom(ui_view* view, void* data, float x1, float y1, floa i++; } + + u32 size = linked_list_size(&listData->items); + if(size > 0) { + float lastItemHeight; + screen_get_string_size(NULL, &lastItemHeight, ((list_item*) linked_list_get(&listData->items, size - 1))->name, 0.5f, 0.5f); + + float totalHeight = list_get_item_screen_y(listData, size - 1) + listData->scrollPos + lastItemHeight; + + float viewHeight = y2 - y1; + + if(totalHeight > viewHeight) { + u32 scrollBarWidth = 0; + screen_get_texture_size(&scrollBarWidth, NULL, TEXTURE_SCROLL_BAR); + + float scrollBarHeight = (viewHeight / totalHeight) * viewHeight; + + float scrollBarX = x2 - scrollBarWidth; + float scrollBarY = y1 + (listData->scrollPos / totalHeight) * viewHeight; + + screen_draw_texture(TEXTURE_SCROLL_BAR, scrollBarX, scrollBarY, scrollBarWidth, scrollBarHeight); + } + } } void list_display(const char* name, const char* info, void* data, void (*update)(ui_view* view, void* data, linked_list* items, list_item* selected, bool selectedTouched),