From 0f22ed2ef160eef2da6080782943b22c9539650d Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Sun, 2 Feb 2025 22:49:01 +0100 Subject: wip: hacky file browser --- lib/nes/app/ui/screen-browser.hh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'lib/nes/app/ui/screen-browser.hh') diff --git a/lib/nes/app/ui/screen-browser.hh b/lib/nes/app/ui/screen-browser.hh index eb66266..7a711c5 100644 --- a/lib/nes/app/ui/screen-browser.hh +++ b/lib/nes/app/ui/screen-browser.hh @@ -2,6 +2,7 @@ #include "nes/app/ui/screen.hh" #include "nes/app/ui/selection.hh" +#include "nes/app/file-browser.hh" namespace nes::app { @@ -10,21 +11,34 @@ namespace nes::app /// An interface which allows the user to browse the filesystem for a game. class screen_browser final : public screen { - class selection_impl final : public selection + struct item { + bool is_parent{ false }; + file_browser::item data{ file_browser::item_type::directory, "" }; + }; + + class selection_impl final : public selection + { + file_browser& file_browser_; + public: - using selection::selection; + explicit selection_impl(file_browser& file_browser) + : selection{ 2, 5, 28 } + , file_browser_{ file_browser } + { + } protected: - auto render_item(renderer&, i32 const&, i32 x, i32 y, u32 width, color) const -> void override; - auto load_page(i32(&)[5], u32 page) -> u32 override; + auto render_item(renderer&, item const&, i32 x, i32 y, u32 width, color) const -> void override; + auto load_page(item(&)[8], u32 page) -> u32 override; }; input_device_keyboard& keyboard_; - selection_impl selection_{ 2, 5, 28 }; + file_browser& file_browser_; + selection_impl selection_; public: - explicit screen_browser(input_device_keyboard&); + explicit screen_browser(input_device_keyboard&, file_browser&); auto render(renderer&) -> void override; auto process_events() -> action override; -- cgit v1.3.1