diff --git a/sphaira/CMakeLists.txt b/sphaira/CMakeLists.txt index dc031dd..2c244bc 100644 --- a/sphaira/CMakeLists.txt +++ b/sphaira/CMakeLists.txt @@ -51,13 +51,12 @@ add_executable(sphaira source/ui/notification.cpp source/ui/nvg_util.cpp source/ui/option_box.cpp - source/ui/option_list.cpp source/ui/popup_list.cpp source/ui/progress_box.cpp source/ui/scrollable_text.cpp - source/ui/scrollbar.cpp source/ui/sidebar.cpp source/ui/widget.cpp + source/ui/list.cpp source/app.cpp source/download.cpp diff --git a/sphaira/include/app.hpp b/sphaira/include/app.hpp index cebb2c6..697134d 100644 --- a/sphaira/include/app.hpp +++ b/sphaira/include/app.hpp @@ -33,7 +33,9 @@ enum class LaunchType { Forwader_Sphaira, }; +// todo: why is this global??? void DrawElement(float x, float y, float w, float h, ThemeEntryID id); +void DrawElement(const Vec4&, ThemeEntryID id); class App { public: diff --git a/sphaira/include/ui/error_box.hpp b/sphaira/include/ui/error_box.hpp index e6e58f8..a2327e5 100644 --- a/sphaira/include/ui/error_box.hpp +++ b/sphaira/include/ui/error_box.hpp @@ -10,7 +10,6 @@ public: ErrorBox(Result code, const std::string& message); auto Update(Controller* controller, TouchInfo* touch) -> void override; - auto OnLayoutChange() -> void override; auto Draw(NVGcontext* vg, Theme* theme) -> void override; private: diff --git a/sphaira/include/ui/list.hpp b/sphaira/include/ui/list.hpp new file mode 100644 index 0000000..b511a69 --- /dev/null +++ b/sphaira/include/ui/list.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "ui/object.hpp" + +namespace sphaira::ui { + +struct List final : Object { + using Callback = std::function; + + List(const Vec4& pos, const Vec4& v, const Vec2& pad = {}); + + void Do(u64 index, u64 count, Callback callback) const { + Do(nullptr, nullptr, index, count, callback); + } + + void Do(NVGcontext* vg, Theme* theme, u64 index, u64 count, Callback callback, float y_off = 0) const; + +private: + auto Draw(NVGcontext* vg, Theme* theme) -> void override {} + +private: + Vec4 m_v; + Vec2 m_pad; +}; + +} // namespace sphaira::ui diff --git a/sphaira/include/ui/menus/appstore.hpp b/sphaira/include/ui/menus/appstore.hpp index d31c48c..102943e 100644 --- a/sphaira/include/ui/menus/appstore.hpp +++ b/sphaira/include/ui/menus/appstore.hpp @@ -2,6 +2,7 @@ #include "ui/menus/menu_base.hpp" #include "ui/scrollable_text.hpp" +#include "ui/list.hpp" #include "nro.hpp" #include "fs.hpp" #include @@ -100,7 +101,7 @@ private: std::size_t m_index{}; // where i am in the array std::vector