aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/IconButton.cpp
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-21 21:43:42 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-21 21:43:42 +0800
commit3b875091c445b7465b9bd044914318989a94d2ad (patch)
treea358aebb488ec1ddc86bf87b8038bacd5d7515cb /src/ui/controls/IconButton.cpp
parent3cda35dbcbbe1e3854b880169c0efa0fc7a79264 (diff)
downloadcru-3b875091c445b7465b9bd044914318989a94d2ad.tar.gz
cru-3b875091c445b7465b9bd044914318989a94d2ad.tar.bz2
cru-3b875091c445b7465b9bd044914318989a94d2ad.zip
Clean codes. Remove member function const.
Diffstat (limited to 'src/ui/controls/IconButton.cpp')
-rw-r--r--src/ui/controls/IconButton.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/ui/controls/IconButton.cpp b/src/ui/controls/IconButton.cpp
index 059a7784..e20e422f 100644
--- a/src/ui/controls/IconButton.cpp
+++ b/src/ui/controls/IconButton.cpp
@@ -1,20 +1,16 @@
#include "cru/ui/controls/IconButton.h"
-
-#include "../Helper.h"
#include "cru/platform/graphics/Factory.h"
#include "cru/platform/graphics/Geometry.h"
+#include "cru/platform/gui/UiApplication.h"
#include "cru/ui/ThemeManager.h"
namespace cru::ui::controls {
-IconButton::IconButton()
- : container_render_object_(new render::BorderRenderObject()),
- geometry_render_object_(new render::GeometryRenderObject()),
- click_detector_(this) {
- container_render_object_->SetChild(geometry_render_object_.get());
- container_render_object_->SetAttachedControl(this);
- geometry_render_object_->SetAttachedControl(this);
-
- container_render_object_->SetBorderEnabled(true);
+IconButton::IconButton() : Control(kControlName), click_detector_(this) {
+ container_render_object_.SetChild(&geometry_render_object_);
+ container_render_object_.SetAttachedControl(this);
+ geometry_render_object_.SetAttachedControl(this);
+
+ container_render_object_.SetBorderEnabled(true);
GetStyleRuleSet()->SetParent(
ThemeManager::GetInstance()->GetResourceStyleRuleSet(
"icon-button.style"));
@@ -29,14 +25,18 @@ IconButton::IconButton(std::string_view icon_svg_path_data_string,
IconButton::~IconButton() {}
void IconButton::SetIconFillColor(const Color& color) {
- SetIconFillBrush(GetGraphicsFactory()->CreateSolidColorBrush(color));
+ SetIconFillBrush(platform::gui::IUiApplication::GetInstance()
+ ->GetGraphicsFactory()
+ ->CreateSolidColorBrush(color));
}
void IconButton::SetIconWithSvgPathDataString(
std::string_view icon_svg_path_data_string, const Rect& view_port) {
- SetIconGeometry(platform::graphics::CreateGeometryFromSvgPathData(
- GetGraphicsFactory(), icon_svg_path_data_string),
- view_port);
+ SetIconGeometry(
+ platform::graphics::CreateGeometryFromSvgPathData(
+ platform::gui::IUiApplication::GetInstance()->GetGraphicsFactory(),
+ icon_svg_path_data_string),
+ view_port);
}
void IconButton::SetIconWithSvgPathDataStringResourceKey(