mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
UI
Add textbox
This commit is contained in:
@@ -16,6 +16,7 @@ target_sources(UI
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_led.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_button.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_slider.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_textbox.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_x_boxes.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_combobox.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/UI_checkbox.cpp
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "UI_textbox.hpp"
|
||||
|
||||
UI_textbox::UI_textbox(std::string id, std::string hint, Color fg_color, Color bg_color)
|
||||
: UI_item(id, UI_TEXTBOX_TYPE, "", 0, fg_color, bg_color), m_hint(hint)
|
||||
{
|
||||
}
|
||||
|
||||
UI_textbox::UI_textbox(const json& j)
|
||||
: UI_item(UI_TEXTBOX_TYPE)
|
||||
{
|
||||
from_json(j);
|
||||
}
|
||||
|
||||
void UI_textbox::set_hint(std::string hint)
|
||||
{
|
||||
m_hint = hint;
|
||||
}
|
||||
|
||||
std::string UI_textbox::hint() const
|
||||
{
|
||||
return m_hint;
|
||||
}
|
||||
|
||||
void UI_textbox::from_json(const json& j)
|
||||
{
|
||||
UI_item::from_json(j);
|
||||
m_hint = j["hint"];
|
||||
}
|
||||
|
||||
json UI_textbox::to_json() const
|
||||
{
|
||||
json j = UI_item::to_json();
|
||||
j["hint"] = m_hint;
|
||||
return j;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "UI_item.hpp"
|
||||
|
||||
#define UI_TEXTBOX_TYPE std::string("UItextbox")
|
||||
|
||||
class UI_textbox : public UI_item
|
||||
{
|
||||
public:
|
||||
UI_textbox(std::string id, std::string hint, Color fg_color, Color bg_color);
|
||||
UI_textbox(const json& j);
|
||||
|
||||
void set_hint(std::string hint);
|
||||
std::string hint() const;
|
||||
|
||||
void from_json(const json& j) override;
|
||||
json to_json() const override;
|
||||
private:
|
||||
std::string m_hint;
|
||||
};
|
||||
Reference in New Issue
Block a user