aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/ThemeManager.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-05-10 19:34:01 +0800
committercrupest <crupest@outlook.com>2021-05-10 19:34:01 +0800
commit43a1883ac80ce3ff4782cd74e5ad16a03887c2aa (patch)
treedaa3c374813f478e0ce99dfca858393b6ad95a3a /include/cru/ui/ThemeManager.hpp
parentae5042599688af2d8b462e49e3cd103b6ec92fe9 (diff)
downloadcru-43a1883ac80ce3ff4782cd74e5ad16a03887c2aa.tar.gz
cru-43a1883ac80ce3ff4782cd74e5ad16a03887c2aa.tar.bz2
cru-43a1883ac80ce3ff4782cd74e5ad16a03887c2aa.zip
...
Diffstat (limited to 'include/cru/ui/ThemeManager.hpp')
-rw-r--r--include/cru/ui/ThemeManager.hpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/include/cru/ui/ThemeManager.hpp b/include/cru/ui/ThemeManager.hpp
index c9e17680..1da29a0e 100644
--- a/include/cru/ui/ThemeManager.hpp
+++ b/include/cru/ui/ThemeManager.hpp
@@ -2,26 +2,49 @@
#include "Base.hpp"
#include "cru/common/Base.hpp"
#include "cru/common/Event.hpp"
+#include "cru/platform/graphics/Brush.hpp"
#include <boost/property_tree/ptree.hpp>
#include <cstddef>
+#include <memory>
+#include <stdexcept>
+#include <string_view>
+#include <unordered_map>
namespace cru::ui {
+class BadThemeResourceException : public std::runtime_error {
+ public:
+ using std::runtime_error::runtime_error;
+};
+
class ThemeManager : public Object {
public:
+ static ThemeManager* GetInstance();
+
+ private:
ThemeManager();
+ public:
CRU_DELETE_COPY(ThemeManager)
CRU_DELETE_MOVE(ThemeManager)
- ~ThemeManager() override;
+ ~ThemeManager() override = default;
IEvent<std::nullptr_t>* ThemeResourceChangeEvent() {
return &theme_resource_change_event_;
}
+ gsl::not_null<std::shared_ptr<platform::graphics::IBrush>> GetBrush(
+ std::u16string key);
+
+ private:
+ void Init();
+
private:
Event<std::nullptr_t> theme_resource_change_event_;
- boost::property_tree::iptree theme_tree_;
+ boost::property_tree::ptree theme_tree_;
+ std::unordered_map<std::u16string,
+ std::shared_ptr<platform::graphics::IBrush>>
+ brushes_;
};
} // namespace cru::ui