aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/controls')
-rw-r--r--src/ui/controls/button.cpp15
-rw-r--r--src/ui/controls/container.cpp13
-rw-r--r--src/ui/controls/flex_layout.cpp4
3 files changed, 22 insertions, 10 deletions
diff --git a/src/ui/controls/button.cpp b/src/ui/controls/button.cpp
index 5e32e064..1a1f4286 100644
--- a/src/ui/controls/button.cpp
+++ b/src/ui/controls/button.cpp
@@ -37,11 +37,10 @@ Button::Button() : click_detector_(this) {
border_style_.press_cancel.corner_radius =
render::CornerRadius{Point{10, 5}};
- render_object_.reset(
- new render::BorderRenderObject(border_style_.normal.brush));
+ render_object_.reset(new render::BorderRenderObject);
render_object_->SetAttachedControl(this);
- render_object_->SetEnabled(true);
- render_object_->SetStyle(border_style_.normal);
+ render_object_->SetBorderEnabled(true);
+ (*render_object_->GetBorderStyle()) = border_style_.normal;
MouseEnterEvent()->Direct()->AddHandler([this](event::MouseEventArgs& args) {
if (click_detector_.GetPressingButton() & trigger_button_) {
@@ -85,19 +84,19 @@ void Button::OnChildChanged(Control* old_child, Control* new_child) {
void Button::OnStateChange(ButtonState oldState, ButtonState newState) {
switch (newState) {
case ButtonState::Normal:
- render_object_->SetStyle(border_style_.normal);
+ (*render_object_->GetBorderStyle()) = border_style_.normal;
SetCursor(GetSystemCursor(SystemCursor::Arrow));
break;
case ButtonState::Hover:
- render_object_->SetStyle(border_style_.hover);
+ (*render_object_->GetBorderStyle()) = border_style_.hover;
SetCursor(GetSystemCursor(SystemCursor::Hand));
break;
case ButtonState::Press:
- render_object_->SetStyle(border_style_.press);
+ (*render_object_->GetBorderStyle()) = border_style_.press;
SetCursor(GetSystemCursor(SystemCursor::Hand));
break;
case ButtonState::PressCancel:
- render_object_->SetStyle(border_style_.press_cancel);
+ (*render_object_->GetBorderStyle()) = border_style_.press_cancel;
SetCursor(GetSystemCursor(SystemCursor::Arrow));
break;
}
diff --git a/src/ui/controls/container.cpp b/src/ui/controls/container.cpp
new file mode 100644
index 00000000..7ebee4b4
--- /dev/null
+++ b/src/ui/controls/container.cpp
@@ -0,0 +1,13 @@
+#include "cru/ui/controls/container.hpp"
+
+#include "cru/platform/graph/graph_factory.hpp"
+#include "cru/ui/render/border_render_object.hpp"
+
+namespace cru::ui::controls {
+Container::Container() {
+ render_object_.reset(new render::BorderRenderObject);
+ render_object_->SetBorderEnabled(false);
+}
+
+Container::~Container() {}
+} // namespace cru::ui::controls
diff --git a/src/ui/controls/flex_layout.cpp b/src/ui/controls/flex_layout.cpp
index bb8e3c14..a8200a12 100644
--- a/src/ui/controls/flex_layout.cpp
+++ b/src/ui/controls/flex_layout.cpp
@@ -22,7 +22,7 @@ FlexChildLayoutData FlexLayout::GetChildLayoutData(Control* control) {
if (find_result == render_objects.cend()) {
throw std::logic_error("Control is not a child of FlexLayout.");
}
- int position = find_result - render_objects.cbegin();
+ int position = static_cast<int>(find_result - render_objects.cbegin());
return *(render_object_->GetChildLayoutData(position));
}
@@ -35,7 +35,7 @@ void FlexLayout::SetChildLayoutData(Control* control,
if (find_result == render_objects.cend()) {
throw std::logic_error("Control is not a child of FlexLayout.");
}
- int position = find_result - render_objects.cbegin();
+ int position = static_cast<int>(find_result - render_objects.cbegin());
const auto d = render_object_->GetChildLayoutData(position);
*d = data;
if (const auto window = GetWindow()) window->InvalidateLayout();