aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/controls')
-rw-r--r--src/ui/controls/Button.cpp5
-rw-r--r--src/ui/controls/Control.cpp8
-rw-r--r--src/ui/controls/TextBox.cpp5
3 files changed, 11 insertions, 7 deletions
diff --git a/src/ui/controls/Button.cpp b/src/ui/controls/Button.cpp
index 0f122650..887bcae6 100644
--- a/src/ui/controls/Button.cpp
+++ b/src/ui/controls/Button.cpp
@@ -4,6 +4,7 @@
#include "cru/platform/graphics/Brush.hpp"
#include "cru/platform/gui/Cursor.hpp"
#include "cru/platform/gui/UiApplication.hpp"
+#include "cru/ui/ThemeManager.hpp"
#include "cru/ui/UiManager.hpp"
#include "cru/ui/helper/ClickDetector.hpp"
#include "cru/ui/render/BorderRenderObject.hpp"
@@ -16,8 +17,8 @@ Button::Button() : click_detector_(this) {
render_object_->SetBorderEnabled(true);
auto default_button_style =
- UiManager::GetInstance()->GetThemeResources()->button_style.get();
- GetStyleRuleSet()->SetParent(default_button_style);
+ ThemeManager::GetInstance()->GetResourceStyleRuleSet(u"button.style");
+ GetStyleRuleSet()->SetParent(std::move(default_button_style));
}
Button::~Button() = default;
diff --git a/src/ui/controls/Control.cpp b/src/ui/controls/Control.cpp
index 44da7f6f..04199d1d 100644
--- a/src/ui/controls/Control.cpp
+++ b/src/ui/controls/Control.cpp
@@ -16,9 +16,9 @@ using platform::gui::IUiApplication;
using platform::gui::SystemCursorType;
Control::Control() {
- style_rule_set_ = std::make_unique<style::StyleRuleSet>();
+ style_rule_set_ = std::make_shared<style::StyleRuleSet>();
style_rule_set_bind_ =
- std::make_unique<style::StyleRuleSetBind>(this, style_rule_set_.get());
+ std::make_unique<style::StyleRuleSetBind>(this, style_rule_set_);
MouseEnterEvent()->Direct()->AddHandler([this](events::MouseEventArgs&) {
this->is_mouse_over_ = true;
@@ -99,8 +99,8 @@ void Control::SetCursor(std::shared_ptr<ICursor> cursor) {
}
}
-style::StyleRuleSet* Control::GetStyleRuleSet() {
- return style_rule_set_.get();
+std::shared_ptr<style::StyleRuleSet> Control::GetStyleRuleSet() {
+ return style_rule_set_;
}
void Control::AddChild(Control* control, const Index position) {
diff --git a/src/ui/controls/TextBox.cpp b/src/ui/controls/TextBox.cpp
index bf72b494..20e89028 100644
--- a/src/ui/controls/TextBox.cpp
+++ b/src/ui/controls/TextBox.cpp
@@ -1,5 +1,6 @@
#include "cru/ui/controls/TextBox.hpp"
+#include "cru/ui/ThemeManager.hpp"
#include "cru/ui/UiManager.hpp"
#include "cru/ui/render/BorderRenderObject.hpp"
#include "cru/ui/render/CanvasRenderObject.hpp"
@@ -16,6 +17,7 @@ TextBox::TextBox()
: border_render_object_(new BorderRenderObject()),
scroll_render_object_(new ScrollRenderObject()) {
const auto theme_resources = UiManager::GetInstance()->GetThemeResources();
+ auto theme_manager = ThemeManager::GetInstance();
text_render_object_ = std::make_unique<TextRenderObject>(
theme_resources->text_brush, theme_resources->default_font,
@@ -37,7 +39,8 @@ TextBox::TextBox()
border_render_object_->SetBorderEnabled(true);
- GetStyleRuleSet()->SetParent(theme_resources->text_box_style.get());
+ GetStyleRuleSet()->SetParent(
+ theme_manager->GetResourceStyleRuleSet(u"textbox.style"));
}
TextBox::~TextBox() {}