diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/CMakeLists.txt | 9 | ||||
-rw-r--r-- | src/ui/mapper/Mapper.cpp | 8 | ||||
-rw-r--r-- | src/ui/mapper/MapperRegistry.cpp | 29 | ||||
-rw-r--r-- | src/ui/xml/XmlMapper.cpp | 0 | ||||
-rw-r--r-- | src/ui/xml/XmlMapperRegistry.cpp | 0 |
5 files changed, 42 insertions, 4 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 16b03309..0d42c8b7 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -1,6 +1,6 @@ set(CRU_UI_INCLUDE_DIR ${CRU_INCLUDE_DIR}/cru/ui) -add_library(cru_ui STATIC +add_library(cru_ui SHARED Helper.cpp ThemeManager.cpp UiManager.cpp @@ -26,6 +26,8 @@ add_library(cru_ui STATIC helper/ShortcutHub.cpp host/LayoutPaintCycler.cpp host/WindowHost.cpp + mapper/Mapper.cpp + mapper/MapperRegistry.cpp render/BorderRenderObject.cpp render/CanvasRenderObject.cpp render/FlexLayoutRenderObject.cpp @@ -39,7 +41,6 @@ add_library(cru_ui STATIC style/Styler.cpp style/StyleRule.cpp style/StyleRuleSet.cpp - xml/XmlMapper.cpp - xml/XmlMapperRegistry.cpp ) -target_link_libraries(cru_ui PUBLIC cru_platform_gui) +target_compile_definitions(cru_ui PRIVATE CRU_UI_EXPORT_API) +target_link_libraries(cru_ui PUBLIC cru_platform_gui cru_xml) diff --git a/src/ui/mapper/Mapper.cpp b/src/ui/mapper/Mapper.cpp new file mode 100644 index 00000000..93a83d8a --- /dev/null +++ b/src/ui/mapper/Mapper.cpp @@ -0,0 +1,8 @@ +#include "cru/ui/mapper/Mapper.hpp" + +#include <typeindex> + +namespace cru::ui::mapper { +MapperBase::MapperBase(std::type_index type_index) + : type_index_(std::move(type_index)) {} +} // namespace cru::ui::mapper diff --git a/src/ui/mapper/MapperRegistry.cpp b/src/ui/mapper/MapperRegistry.cpp new file mode 100644 index 00000000..e445a7d0 --- /dev/null +++ b/src/ui/mapper/MapperRegistry.cpp @@ -0,0 +1,29 @@ +#include "cru/ui/mapper/MapperRegistry.hpp" + +namespace cru::ui::mapper { +MapperRegistry::MapperRegistry() {} + +MapperRegistry::~MapperRegistry() { + for (auto mapper : mapper_list_) { + delete mapper; + } +} + +void MapperRegistry::RegisterMapper(MapperBase *mapper) { + if (std::find(mapper_list_.cbegin(), mapper_list_.cend(), mapper) != + mapper_list_.cend()) { + throw Exception(u"This mapper is already registered."); + } + + mapper_list_.push_back(mapper); +} + +void MapperRegistry::UnregisterMapper(MapperBase *mapper) { + auto it = std::find(mapper_list_.begin(), mapper_list_.end(), mapper); + if (it == mapper_list_.end()) { + throw Exception(u"This mapper is not registered."); + } + + mapper_list_.erase(it); +} +} // namespace cru::ui::mapper diff --git a/src/ui/xml/XmlMapper.cpp b/src/ui/xml/XmlMapper.cpp deleted file mode 100644 index e69de29b..00000000 --- a/src/ui/xml/XmlMapper.cpp +++ /dev/null diff --git a/src/ui/xml/XmlMapperRegistry.cpp b/src/ui/xml/XmlMapperRegistry.cpp deleted file mode 100644 index e69de29b..00000000 --- a/src/ui/xml/XmlMapperRegistry.cpp +++ /dev/null |