SDOM - Simple SDL Document Object Model
A lightweight, extensible Document Object Model for SDL-based applications.
Loading...
Searching...
No Matches
SDOM_Group.hpp
Go to the documentation of this file.
1// SDOM_Group.hpp
2#pragma once
3
5
6namespace SDOM
7{
8
9 class Group : public IPanelObject
10 {
12
13 public:
14 // --- Type Info --- //
15 static constexpr const char* TypeName = "Group";
16
17 // --- Initialization Struct --- //
19 {
21 {
22 // from IDisplayObject
23 name = TypeName;
24 type = TypeName;
25 color = {96, 0, 96, 255}; // Group color
26 tabEnabled = false; // groups are not tab-enabled by default
27 isClickable = false; // groups are not clickable by default
28 // from IPanelObject
30 icon_resource = "internal_icon_8x8"; // Default to internal 8x8 sprite sheet
31 icon_width = 8; // default icon width is 8
32 icon_height = 8; // default icon height is 8
33 font_resource = "internal_font_8x8"; // Default to internal 8x8 font
34 font_width = 8; // default font width is 8
35 font_height = 8; // default font height is 8
36 }
37 std::string text = "Group"; // default group text
38 int font_size = 8; // default font size is 8
39 SDL_Color label_color_ = {255, 255, 255, 255}; // default label color is white
40
41 }; // END: InitStruct
42 protected:
43 // --- Constructors --- //
44 Group(const InitStruct& init);
45 Group(const sol::table& config);
46
47 public:
48
49 // --- Static Factory Methods --- //
50 static std::unique_ptr<IDisplayObject> CreateFromLua(const sol::table& config) {
51 return std::unique_ptr<IDisplayObject>(new Group(config));
52 }
53 static std::unique_ptr<IDisplayObject> CreateFromInitStruct(const IDisplayObject::InitStruct& baseInit) {
54 const auto& groupInit = static_cast<const Group::InitStruct&>(baseInit);
55 return std::unique_ptr<IDisplayObject>(new Group(groupInit));
56 }
57
58 Group() = default;
59 virtual ~Group() = default;
60
61 // --- Virtual Methods --- //
62 virtual bool onInit() override; // Called when the display object is initialized
63 virtual void onRender() override; // Called to render the display object
64 virtual void onQuit() override; // Called when the display object is being destroyed
65 virtual void onUpdate(float fElapsedTime) override; // Called every frame to update the display object
66 virtual void onEvent(const Event& event) override; // Called when an event occurs
67
69
70 protected:
71 DisplayHandle labelObject_; // internal label object for group text
72 std::string text_; // initialized label text
73 std::string font_resource_ = "internal_font_8x8"; // default font resource name
74 std::string icon_resource_ = "internal_icon_8x8"; // default icon resource name
75 int font_size_ = 8; // default font size
76 int font_width_ = 8; // default font width
77 int font_height_ = 8; // default font height
78 SDL_Color label_color_ = {255, 255, 255, 255}; // default label color is white
79
80 // --- Lua Registration --- //
81 virtual void _registerLuaBindings(const std::string& typeName, sol::state_view lua);
82
83 }; // END: class Button : public IPanelObject
84
85} // END namespace SDOM
Definition SDOM_DisplayHandle.hpp:24
Definition SDOM_Event.hpp:55
Definition SDOM_Group.hpp:10
virtual void onRender() override
Definition SDOM_Group.cpp:237
static std::unique_ptr< IDisplayObject > CreateFromLua(const sol::table &config)
Definition SDOM_Group.hpp:50
virtual void onQuit() override
Definition SDOM_Group.cpp:231
DisplayHandle labelObject_
Definition SDOM_Group.hpp:71
virtual ~Group()=default
std::string icon_resource_
Definition SDOM_Group.hpp:74
virtual void onEvent(const Event &event) override
Definition SDOM_Group.cpp:249
DisplayHandle getLabelObject() const
Definition SDOM_Group.hpp:68
int font_width_
Definition SDOM_Group.hpp:76
Group()=default
virtual void _registerLuaBindings(const std::string &typeName, sol::state_view lua)
Definition SDOM_Group.cpp:262
std::string font_resource_
Definition SDOM_Group.hpp:73
int font_size_
Definition SDOM_Group.hpp:75
static std::unique_ptr< IDisplayObject > CreateFromInitStruct(const IDisplayObject::InitStruct &baseInit)
Definition SDOM_Group.hpp:53
std::string text_
Definition SDOM_Group.hpp:72
int font_height_
Definition SDOM_Group.hpp:77
virtual void onUpdate(float fElapsedTime) override
Definition SDOM_Group.cpp:244
static constexpr const char * TypeName
Definition SDOM_Group.hpp:15
virtual bool onInit() override
Definition SDOM_Group.cpp:126
SDL_Color label_color_
Definition SDOM_Group.hpp:78
Definition SDOM_IPanelObject.hpp:107
Contains all core classes and utilities for the SDOM library.
Definition lua_BindHelpers.hpp:7
Definition SDOM_Group.hpp:19
int font_size
Definition SDOM_Group.hpp:38
SDL_Color label_color_
Definition SDOM_Group.hpp:39
std::string text
Definition SDOM_Group.hpp:37
InitStruct()
Definition SDOM_Group.hpp:20
Definition SDOM_IDisplayObject.hpp:187
std::string type
Definition SDOM_IDisplayObject.hpp:189
bool tabEnabled
Definition SDOM_IDisplayObject.hpp:212
std::string name
Definition SDOM_IDisplayObject.hpp:188
SDL_Color color
Definition SDOM_IDisplayObject.hpp:194
bool isClickable
Definition SDOM_IDisplayObject.hpp:208
Definition SDOM_IPanelObject.hpp:116
std::string font_resource
Definition SDOM_IPanelObject.hpp:127
std::string icon_resource
Definition SDOM_IPanelObject.hpp:124
int font_height
Definition SDOM_IPanelObject.hpp:129
PanelBaseIndex base_index
Definition SDOM_IPanelObject.hpp:123
int font_width
Definition SDOM_IPanelObject.hpp:128
int icon_height
Definition SDOM_IPanelObject.hpp:126
int icon_width
Definition SDOM_IPanelObject.hpp:125