aboutsummaryrefslogtreecommitdiff
path: root/src/ui/ui_manager.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-12-13 01:02:47 +0800
committercrupest <crupest@outlook.com>2019-12-13 01:02:47 +0800
commit9110574bb51e9e2959842a7641f598d34c3cd847 (patch)
tree96ee1f5b3c40095e4e923fc763de0663ee6a01aa /src/ui/ui_manager.cpp
parentf2aa96fba0b72eeeadf5160ea5df2c8143ec8aa0 (diff)
downloadcru-9110574bb51e9e2959842a7641f598d34c3cd847.tar.gz
cru-9110574bb51e9e2959842a7641f598d34c3cd847.tar.bz2
cru-9110574bb51e9e2959842a7641f598d34c3cd847.zip
...
Diffstat (limited to 'src/ui/ui_manager.cpp')
-rw-r--r--src/ui/ui_manager.cpp48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/ui/ui_manager.cpp b/src/ui/ui_manager.cpp
index f60f6355..6c61083b 100644
--- a/src/ui/ui_manager.cpp
+++ b/src/ui/ui_manager.cpp
@@ -1,27 +1,35 @@
#include "cru/ui/ui_manager.hpp"
#include "cru/platform/graph/brush.hpp"
+#include "cru/platform/graph/factory.hpp"
#include "cru/platform/graph/font.hpp"
-#include "cru/platform/graph/graph_factory.hpp"
#include "cru/platform/native/ui_application.hpp"
+#include "helper.hpp"
namespace cru::ui {
using namespace cru::platform::graph;
+
+namespace {
+std::unique_ptr<ISolidColorBrush> CreateSolidColorBrush(IGraphFactory* factory,
+ const Color& color) {
+ auto brush = factory->CreateSolidColorBrush();
+ brush->SetColor(color);
+ return brush;
+}
+} // namespace
+
PredefineResources::PredefineResources() {
- const auto graph_factory = GraphFactory::GetInstance();
-
- button_normal_border_brush.reset(
- static_cast<Brush*>(graph_factory->CreateSolidColorBrush(colors::black)));
- text_block_selection_brush.reset(static_cast<Brush*>(
- graph_factory->CreateSolidColorBrush(colors::skyblue)));
- text_block_text_brush.reset(
- static_cast<Brush*>(graph_factory->CreateSolidColorBrush(colors::black)));
- text_block_font.reset(graph_factory->CreateFont(L"等线", 24.0f));
+ const auto factory = GetGraphFactory();
+
+ button_normal_border_brush = CreateSolidColorBrush(factory, colors::black);
+ text_block_selection_brush = CreateSolidColorBrush(factory, colors::skyblue);
+ text_block_text_brush = CreateSolidColorBrush(factory, colors::black);
+ text_block_font = factory->CreateFont("等线", 24.0f);
}
UiManager* UiManager::GetInstance() {
static UiManager* instance = new UiManager();
- platform::native::UiApplication::GetInstance()->AddOnQuitHandler([] {
+ GetUiApplication()->AddOnQuitHandler([] {
delete instance;
instance = nullptr;
});
@@ -29,15 +37,15 @@ UiManager* UiManager::GetInstance() {
}
UiManager::UiManager() : predefine_resources_(new PredefineResources()) {
- const auto factory = GraphFactory::GetInstance();
- theme_resource_.button_style.normal.border_brush = std::shared_ptr<platform::graph::Brush>(
- factory->CreateSolidColorBrush(Color::FromHex(0x00bfff)));
- theme_resource_.button_style.hover.border_brush = std::shared_ptr<platform::graph::Brush>(
- factory->CreateSolidColorBrush(Color::FromHex(0x47d1ff)));
- theme_resource_.button_style.press.border_brush = std::shared_ptr<platform::graph::Brush>(
- factory->CreateSolidColorBrush(Color::FromHex(0x91e4ff)));
- theme_resource_.button_style.press_cancel.border_brush = std::shared_ptr<platform::graph::Brush>(
- factory->CreateSolidColorBrush(Color::FromHex(0x91e4ff)));
+ const auto factory = GetGraphFactory();
+ theme_resource_.button_style.normal.border_brush =
+ CreateSolidColorBrush(factory, Color::FromHex(0x00bfff));
+ theme_resource_.button_style.hover.border_brush =
+ CreateSolidColorBrush(factory, Color::FromHex(0x47d1ff));
+ theme_resource_.button_style.press.border_brush =
+ CreateSolidColorBrush(factory, Color::FromHex(0x91e4ff));
+ theme_resource_.button_style.press_cancel.border_brush =
+ CreateSolidColorBrush(factory, Color::FromHex(0x91e4ff));
theme_resource_.button_style.normal.border_thickness =
theme_resource_.button_style.hover.border_thickness =