aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/cru/theme_builder/ThemeResources.xml4
-rw-r--r--include/cru/ui/controls/IContentBrushControl.h12
-rw-r--r--include/cru/ui/controls/IFontControl.h10
-rw-r--r--include/cru/ui/controls/IconButton.h15
-rw-r--r--include/cru/ui/controls/TextBlock.h23
-rw-r--r--include/cru/ui/controls/TextBox.h30
6 files changed, 89 insertions, 5 deletions
diff --git a/assets/cru/theme_builder/ThemeResources.xml b/assets/cru/theme_builder/ThemeResources.xml
index a61a59f8..b5a9dc73 100644
--- a/assets/cru/theme_builder/ThemeResources.xml
+++ b/assets/cru/theme_builder/ThemeResources.xml
@@ -7,7 +7,7 @@
<StyleRuleSet>
<StyleRule>
<NoCondition />
- <PreferredSizeStyler width="30" height="20" />
+ <PreferredSizeStyler width="20" height="20" />
<BorderStyler>
<BorderStyle>
<Thickness value="0" />
@@ -25,7 +25,7 @@
<StyleRuleSet>
<StyleRule>
<NoCondition />
- <PreferredSizeStyler width="30" height="20" />
+ <PreferredSizeStyler width="20" height="20" />
<BorderStyler>
<BorderStyle>
<Color value="black" />
diff --git a/include/cru/ui/controls/IContentBrushControl.h b/include/cru/ui/controls/IContentBrushControl.h
new file mode 100644
index 00000000..d7a4c1b8
--- /dev/null
+++ b/include/cru/ui/controls/IContentBrushControl.h
@@ -0,0 +1,12 @@
+#pragma once
+#include "../Base.h"
+#include "cru/platform/graphics/Brush.h"
+
+namespace cru::ui::controls {
+struct CRU_UI_API IContentBrushControl : virtual Interface {
+ virtual std::shared_ptr<platform::graphics::IBrush> GetContentBrush()
+ const = 0;
+ virtual void SetContentBrush(
+ std::shared_ptr<platform::graphics::IBrush> brush) = 0;
+};
+} // namespace cru::ui::controls
diff --git a/include/cru/ui/controls/IFontControl.h b/include/cru/ui/controls/IFontControl.h
new file mode 100644
index 00000000..4167de27
--- /dev/null
+++ b/include/cru/ui/controls/IFontControl.h
@@ -0,0 +1,10 @@
+#pragma once
+#include "../Base.h"
+#include "cru/platform/graphics/Font.h"
+
+namespace cru::ui::controls {
+struct CRU_UI_API IFontControl : virtual Interface {
+ virtual std::shared_ptr<platform::graphics::IFont> GetFont() const = 0;
+ virtual void SetFont(std::shared_ptr<platform::graphics::IFont> font) = 0;
+};
+} // namespace cru::ui::controls
diff --git a/include/cru/ui/controls/IconButton.h b/include/cru/ui/controls/IconButton.h
index 4f347b33..a76d01d4 100644
--- a/include/cru/ui/controls/IconButton.h
+++ b/include/cru/ui/controls/IconButton.h
@@ -1,4 +1,5 @@
#pragma once
+#include <memory>
#include "NoChildControl.h"
#include "../helper/ClickDetector.h"
@@ -6,12 +7,15 @@
#include "../render/GeometryRenderObject.h"
#include "IBorderControl.h"
#include "IClickableControl.h"
+#include "IContentBrushControl.h"
#include "cru/common/Event.h"
+#include "cru/platform/graphics/Brush.h"
namespace cru::ui::controls {
class CRU_UI_API IconButton : public NoChildControl,
public virtual IClickableControl,
- public virtual IBorderControl {
+ public virtual IBorderControl,
+ public virtual IContentBrushControl {
public:
static constexpr StringView kControlType = u"IconButton";
@@ -85,6 +89,15 @@ class CRU_UI_API IconButton : public NoChildControl,
void SetIconWithSvgPathDataStringResourceKey(
StringView icon_svg_path_data_string_resource_key, const Rect& view_port);
+ std::shared_ptr<platform::graphics::IBrush> GetContentBrush() const override {
+ return GetIconFillBrush();
+ }
+
+ void SetContentBrush(
+ std::shared_ptr<platform::graphics::IBrush> brush) override {
+ SetIconFillBrush(std::move(brush));
+ }
+
private:
std::unique_ptr<render::BorderRenderObject> container_render_object_;
std::unique_ptr<render::GeometryRenderObject> geometry_render_object_;
diff --git a/include/cru/ui/controls/TextBlock.h b/include/cru/ui/controls/TextBlock.h
index e43d472f..12c9d2f9 100644
--- a/include/cru/ui/controls/TextBlock.h
+++ b/include/cru/ui/controls/TextBlock.h
@@ -2,12 +2,17 @@
#include "NoChildControl.h"
#include "../render/TextRenderObject.h"
+#include "IContentBrushControl.h"
+#include "IFontControl.h"
#include "TextHostControlService.h"
#include "cru/platform/graphics/Brush.h"
+#include "cru/platform/graphics/Font.h"
namespace cru::ui::controls {
class CRU_UI_API TextBlock : public NoChildControl,
- public virtual ITextHostControl {
+ public virtual ITextHostControl,
+ public virtual IFontControl,
+ public virtual IContentBrushControl {
public:
static constexpr StringView kControlType = u"TextBlock";
@@ -47,6 +52,22 @@ class CRU_UI_API TextBlock : public NoChildControl,
return nullptr;
}
+ std::shared_ptr<platform::graphics::IFont> GetFont() const override {
+ return text_render_object_->GetFont();
+ }
+ void SetFont(std::shared_ptr<platform::graphics::IFont> font) override {
+ text_render_object_->SetFont(std::move(font));
+ }
+
+ std::shared_ptr<platform::graphics::IBrush> GetContentBrush() const override {
+ return GetTextBrush();
+ }
+
+ void SetContentBrush(
+ std::shared_ptr<platform::graphics::IBrush> brush) override {
+ SetTextBrush(std::move(brush));
+ }
+
private:
std::unique_ptr<render::TextRenderObject> text_render_object_;
diff --git a/include/cru/ui/controls/TextBox.h b/include/cru/ui/controls/TextBox.h
index 3e041880..c3d8fc4d 100644
--- a/include/cru/ui/controls/TextBox.h
+++ b/include/cru/ui/controls/TextBox.h
@@ -4,14 +4,19 @@
#include "../render/BorderRenderObject.h"
#include "../render/TextRenderObject.h"
#include "IBorderControl.h"
+#include "IContentBrushControl.h"
+#include "IFontControl.h"
#include "TextHostControlService.h"
+#include "cru/platform/graphics/Brush.h"
#include <memory>
namespace cru::ui::controls {
class CRU_UI_API TextBox : public NoChildControl,
public virtual IBorderControl,
- public virtual ITextHostControl {
+ public virtual ITextHostControl,
+ public virtual IContentBrushControl,
+ public virtual IFontControl {
public:
static constexpr StringView control_type = u"TextBox";
@@ -40,6 +45,29 @@ class CRU_UI_API TextBox : public NoChildControl,
return service_->TextChangeEvent();
}
+ std::shared_ptr<platform::graphics::IFont> GetFont() const override {
+ return text_render_object_->GetFont();
+ }
+ void SetFont(std::shared_ptr<platform::graphics::IFont> font) override {
+ text_render_object_->SetFont(std::move(font));
+ }
+
+ std::shared_ptr<platform::graphics::IBrush> GetTextBrush() const {
+ return text_render_object_->GetBrush();
+ }
+ void SetTextBrush(std::shared_ptr<platform::graphics::IBrush> brush) {
+ text_render_object_->SetBrush(std::move(brush));
+ }
+
+ std::shared_ptr<platform::graphics::IBrush> GetContentBrush() const override {
+ return GetTextBrush();
+ }
+
+ void SetContentBrush(
+ std::shared_ptr<platform::graphics::IBrush> brush) override {
+ SetTextBrush(std::move(brush));
+ }
+
private:
std::unique_ptr<render::BorderRenderObject> border_render_object_;
std::unique_ptr<render::ScrollRenderObject> scroll_render_object_;