sidebar: add text input entry

This commit is contained in:
ITotalJustice
2025-08-02 19:18:42 +01:00
parent fb3ad260da
commit 1a00db9d55
2 changed files with 48 additions and 2 deletions

View File

@@ -77,10 +77,9 @@ public:
explicit SidebarEntryBool(const std::string& title, bool& option, const std::string& info = "", const std::string& true_str = "On", const std::string& false_str = "Off");
explicit SidebarEntryBool(const std::string& title, option::OptionBool& option, const Callback& cb, const std::string& info = "", const std::string& true_str = "On", const std::string& false_str = "Off");
explicit SidebarEntryBool(const std::string& title, option::OptionBool& option, const std::string& info = "", const std::string& true_str = "On", const std::string& false_str = "Off");
private:
void Draw(NVGcontext* vg, Theme* theme, const Vec4& root_pos, bool left) override;
private:
bool m_option;
Callback m_callback;
std::string m_true_str;
@@ -125,6 +124,32 @@ private:
float m_text_yoff{};
};
class SidebarEntryTextInput final : public SidebarEntryBase {
public:
using Callback = std::function<void(bool&)>;
public:
explicit SidebarEntryTextInput(const std::string& text, const std::string& guide = {}, const std::string& info = "");
void Draw(NVGcontext* vg, Theme* theme, const Vec4& root_pos, bool left) override;
auto GetText() const {
return m_title;
}
void SetText(const std::string& text) {
m_title = text;
}
void SetGuide(const std::string& guide) {
m_guide = guide;
}
private:
std::string m_guide;
ScrollingText m_scolling_title{};
};
class Sidebar final : public Widget {
public:
enum class Side { LEFT, RIGHT };