diff options
author | crupest <crupest@outlook.com> | 2022-01-27 21:37:38 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-01-27 21:37:38 +0800 |
commit | 103bcb137273729a0f23ff3771e26150a64454ba (patch) | |
tree | 5d75e869cc4b1bf0f2afdfbc9ed5ff0f78e0d030 /include | |
parent | 560c0ead613658a2b7444907c3d1d69e49be8c32 (diff) | |
download | cru-103bcb137273729a0f23ff3771e26150a64454ba.tar.gz cru-103bcb137273729a0f23ff3771e26150a64454ba.tar.bz2 cru-103bcb137273729a0f23ff3771e26150a64454ba.zip |
...
Diffstat (limited to 'include')
-rw-r--r-- | include/cru/ui/ThemeManager.hpp | 2 | ||||
-rw-r--r-- | include/cru/ui/UiManager.hpp | 44 | ||||
-rw-r--r-- | include/cru/ui/mapper/FontMapper.hpp | 19 |
3 files changed, 21 insertions, 44 deletions
diff --git a/include/cru/ui/ThemeManager.hpp b/include/cru/ui/ThemeManager.hpp index 7d52fa48..be9daa47 100644 --- a/include/cru/ui/ThemeManager.hpp +++ b/include/cru/ui/ThemeManager.hpp @@ -56,6 +56,8 @@ class CRU_UI_API ThemeManager : public Object { std::shared_ptr<platform::graphics::IBrush> GetResourceBrush( const String& key); + std::shared_ptr<platform::graphics::IFont> GetResourceFont(const String& key); + std::shared_ptr<style::StyleRuleSet> GetResourceStyleRuleSet( const String& key); diff --git a/include/cru/ui/UiManager.hpp b/include/cru/ui/UiManager.hpp deleted file mode 100644 index 9ac7f416..00000000 --- a/include/cru/ui/UiManager.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once -#include "Base.hpp" - -#include "controls/Base.hpp" -#include "cru/platform/graphics/Brush.hpp" -#include "cru/ui/helper/ClickDetector.hpp" -#include "style/StyleRuleSet.hpp" - -#include <gsl/pointers> -#include <memory> -#include <string> -#include <unordered_map> - -namespace cru::ui { -struct ThemeResources { - String default_font_family; - std::shared_ptr<platform::graphics::IFont> default_font; - std::shared_ptr<platform::graphics::IBrush> text_brush; - std::shared_ptr<platform::graphics::IBrush> text_selection_brush; - std::shared_ptr<platform::graphics::IBrush> caret_brush; -}; - -class CRU_UI_API UiManager : public Object { - public: - static UiManager* GetInstance(); - - private: - UiManager(); - - public: - UiManager(const UiManager& other) = delete; - UiManager(UiManager&& other) = delete; - UiManager& operator=(const UiManager& other) = delete; - UiManager& operator=(UiManager&& other) = delete; - ~UiManager() override; - - ThemeResources* GetThemeResources() { return &theme_resource_; } - - void ReadResourcesFile(const String& file_path); - - private: - ThemeResources theme_resource_; -}; -} // namespace cru::ui diff --git a/include/cru/ui/mapper/FontMapper.hpp b/include/cru/ui/mapper/FontMapper.hpp new file mode 100644 index 00000000..ad8c43b5 --- /dev/null +++ b/include/cru/ui/mapper/FontMapper.hpp @@ -0,0 +1,19 @@ +#pragma once +#include "Mapper.hpp" +#include "cru/common/Base.hpp" +#include "cru/platform/graphics/Font.hpp" + +namespace cru::ui::mapper { +class FontMapper : public BasicRefMapper<platform::graphics::IFont> { + public: + CRU_DEFAULT_CONSTRUCTOR_DESTRUCTOR(FontMapper) + + public: + bool SupportMapFromXml() override { return true; } + bool XmlElementIsOfThisType(xml::XmlElementNode* node) override; + + protected: + std::shared_ptr<platform::graphics::IFont> DoMapFromXml( + xml::XmlElementNode* node) override; +}; +} // namespace cru::ui::mapper |