Files
sphaira/sphaira/include/ui/widget.hpp
ITotalJustice 9966e57e12 option to install nro from fs, swap LR display, load translations locally, fix scrolling sound, add file name to rename swkdb
- reduce nxlink svcsleep to reduce latency between polling.
- translations can now be loaded from /config/sphaira/i18n/name.json, this is to help aid those creating translations.
- swap LR position in display. the fix is a hack, but it'll do for now.
- sound effects are now consistent throught the app.
- renaming a file will now show the current file name in swkbd, makes it easier to rename from config.ini.template -> config.ini
- removed some dead code that was unused.
- add credits to the readme.
- speed up playlog ini parsing by browsing the ini rather that doing a query for each entry.
2024-12-17 16:03:05 +00:00

64 lines
1.3 KiB
C++

#pragma once
#include "ui/object.hpp"
#include <vector>
#include <memory>
#include <map>
#include <unordered_map>
namespace sphaira::ui {
struct Widget : public Object {
virtual ~Widget() = default;
virtual void Update(Controller* controller, TouchInfo* touch);
virtual void Draw(NVGcontext* vg, Theme* theme);
virtual void OnFocusGained() {
m_focus = true;
}
virtual void OnFocusLost() {
m_focus = false;
}
virtual auto HasFocus() const -> bool {
return m_focus;
}
auto HasAction(Button button) const -> bool;
void SetAction(Button button, Action action);
void SetActions(std::same_as<std::pair<Button, Action>> auto ...args) {
const std::array list = {args...};
for (const auto& [button, action] : list) {
SetAction(button, action);
}
}
auto GetActions() const {
return m_actions;
}
void RemoveAction(Button button);
void RemoveActions() {
m_actions.clear();
}
void SetPop(bool pop = true) {
m_pop = pop;
}
auto ShouldPop() const -> bool {
return m_pop;
}
using Actions = std::map<Button, Action>;
// using Actions = std::unordered_map<Button, Action>;
Actions m_actions;
bool m_focus{false};
bool m_pop{false};
};
} // namespace sphaira::ui