lxgui
gui_check_button.hpp
1 #ifndef LXGUI_GUI_CHECK_BUTTON_HPP
2 #define LXGUI_GUI_CHECK_BUTTON_HPP
3 
4 #include "lxgui/gui_button.hpp"
5 #include "lxgui/lxgui.hpp"
6 #include "lxgui/utils.hpp"
7 
8 namespace lxgui::gui {
9 
15 class check_button : public button {
16 public:
17  using base = button;
18 
20  explicit check_button(
21  utils::control_block& block, manager& mgr, const frame_core_attributes& attr);
22 
28  std::string serialize(const std::string& tab) const override;
29 
34  void copy_from(const region& obj) override;
35 
37  virtual void check();
38 
40  virtual void uncheck();
41 
46  void disable() override;
47 
49  void enable() override;
50 
56  void release() override;
57 
62  bool is_checked() const;
63 
68  const utils::observer_ptr<texture>& get_checked_texture() {
69  return checked_texture_;
70  }
71 
76  utils::observer_ptr<const texture> get_checked_texture() const {
77  return checked_texture_;
78  }
79 
84  const utils::observer_ptr<texture>& get_disabled_checked_texture() {
86  }
87 
92  utils::observer_ptr<const texture> get_disabled_checked_texture() const {
94  }
95 
100  void set_checked_texture(utils::observer_ptr<texture> tex);
101 
106  void set_disabled_checked_texture(utils::observer_ptr<texture> tex);
107 
109  static void register_on_lua(sol::state& lua);
110 
111  static constexpr const char* class_name = "CheckButton";
112 
113 protected:
114  void parse_all_nodes_before_children_(const layout_node& node) override;
115 
116  const std::vector<std::string>& get_type_list_() const override;
117 
118  bool is_checked_ = false;
119 
120  utils::observer_ptr<texture> checked_texture_ = nullptr;
121  utils::observer_ptr<texture> disabled_checked_texture_ = nullptr;
122 };
123 
124 } // namespace lxgui::gui
125 
126 #endif
A frame with a button that can be clicked.
Definition: gui_button.hpp:52
button(utils::control_block &block, manager &mgr, const frame_core_attributes &attr)
Constructor.
Definition: gui_button.cpp:13
A button with two additional states: checked and unchecked.
const utils::observer_ptr< texture > & get_disabled_checked_texture()
Returns this button's disabled checked texture.
utils::observer_ptr< const texture > get_checked_texture() const
Returns this button's checked texture.
const std::vector< std::string > & get_type_list_() const override
utils::observer_ptr< texture > disabled_checked_texture_
void set_disabled_checked_texture(utils::observer_ptr< texture > tex)
Sets this button's disabled checked texture.
virtual void uncheck()
UnChecks this button.
const utils::observer_ptr< texture > & get_checked_texture()
Returns this button's checked texture.
virtual void check()
Checks this button.
check_button(utils::control_block &block, manager &mgr, const frame_core_attributes &attr)
Constructor.
void disable() override
Disables this check button.
void enable() override
Enables this check button.
void copy_from(const region &obj) override
Copies a region's parameters into this check button (inheritance).
static void register_on_lua(sol::state &lua)
Registers this region class to the provided Lua state.
void parse_all_nodes_before_children_(const layout_node &node) override
std::string serialize(const std::string &tab) const override
Prints all relevant information about this region in a string.
utils::observer_ptr< const texture > get_disabled_checked_texture() const
Returns this button's disabled checked texture.
static constexpr const char * class_name
void release() override
Releases this check button.
utils::observer_ptr< texture > checked_texture_
void set_checked_texture(utils::observer_ptr< texture > tex)
Sets this button's checked texture.
bool is_checked() const
Checks if this check button is checked.
A region that can contain other regions and react to events.
Definition: gui_frame.hpp:255
An node in a layout file.
Manages the user interface.
Definition: gui_manager.hpp:44
The base class of all elements in the GUI.
Definition: gui_region.hpp:161
Struct holding all the core information about a frame necessary for its creation.