1 #ifndef LXGUI_GUI_FACTORY_HPP
2 #define LXGUI_GUI_FACTORY_HPP
4 #include "lxgui/lxgui.hpp"
5 #include "lxgui/utils_observer.hpp"
9 #include <unordered_map>
24 struct region_core_attributes;
25 struct frame_core_attributes;
44 return utils::make_owned<T>(mgr, attr);
50 return utils::make_owned<T>(mgr, attr);
56 return utils::make_owned<T>(mgr, attr);
113 typename std::enable_if<std::is_base_of<gui::region, ObjectType>::value>::type>
115 if constexpr (std::is_base_of_v<gui::layered_region, ObjectType>) {
116 custom_region_list_[ObjectType::class_name] = &create_new_layered_region<ObjectType>;
117 }
else if constexpr (std::is_base_of_v<gui::frame, ObjectType>) {
118 custom_frame_list_[ObjectType::class_name] = &create_new_frame<ObjectType>;
120 custom_object_list_[ObjectType::class_name] = &create_new_object<ObjectType>;
123 custom_lua_regs_[ObjectType::class_name] = &ObjectType::register_on_lua;
133 typename FunctionType,
135 typename std::enable_if<std::is_base_of<gui::region, ObjectType>::value>::type>
137 if constexpr (std::is_base_of_v<gui::layered_region, ObjectType>) {
138 custom_region_list_[ObjectType::class_name] =
141 return factory_func(mgr, attr);
143 }
else if constexpr (std::is_base_of_v<gui::frame, ObjectType>) {
144 custom_frame_list_[ObjectType::class_name] =
147 return factory_func(mgr, attr);
150 custom_object_list_[ObjectType::class_name] =
153 return factory_func(mgr, attr);
157 custom_lua_regs_[ObjectType::class_name] = &ObjectType::register_on_lua;
174 using string_map = std::unordered_map<std::string, T>;
186 string_map<std::function<void(sol::state&)>> custom_lua_regs_;
Handles the creation of new UI objects.
factory(factory &&)=delete
void register_on_lua(sol::state &lua)
Registers all region types on the provided Lua state.
utils::owner_ptr< layered_region > create_layered_region(registry ®, const region_core_attributes &attr)
Creates a new layered_region.
factory & operator=(const factory &)=delete
factory(manager &mgr)
Constructor.
utils::owner_ptr< region > create_region(registry ®, const region_core_attributes &attr)
Creates a new region.
factory(const factory &)=delete
factory & operator=(factory &&)=delete
void register_region_type()
Registers a new object type.
utils::owner_ptr< frame > create_frame(registry ®, const frame_core_attributes &attr)
Creates a new frame.
void register_region_type(FunctionType &&factory_func)
Registers a new object type.
Manages the user interface.
The base class of all elements in the GUI.
Keeps track of created UI objects and records their names for lookup.
oup::observable_sealed_ptr< T > owner_ptr
Struct holding all the core information about a frame necessary for its creation.
Struct holding all the core information about a region necessary for its creation.