aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/CMakeLists.txt4
-rw-r--r--src/ui/content_control.cpp5
-rw-r--r--src/ui/control.cpp9
-rw-r--r--src/ui/controls/button.cpp6
-rw-r--r--src/ui/controls/flex_layout.cpp2
-rw-r--r--src/ui/layout_control.cpp10
-rw-r--r--src/ui/render/flex_layout_render_object.cpp4
-rw-r--r--src/ui/render/render_object.cpp11
-rw-r--r--src/ui/render/text_render_object.cpp6
-rw-r--r--src/ui/render/window_render_object.cpp6
-rw-r--r--src/ui/window.cpp2
11 files changed, 51 insertions, 14 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 51d36e0d..111e3e33 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -42,8 +42,4 @@ target_sources(cru_ui PUBLIC
${CRU_UI_INCLUDE_DIR}/render/text_render_object.hpp
${CRU_UI_INCLUDE_DIR}/render/window_render_object.hpp
)
-target_link_libraries(cru_ui PUBLIC cru_base)
-
-if(WIN32)
target_link_libraries(cru_ui PUBLIC cru_platform_native)
-endif()
diff --git a/src/ui/content_control.cpp b/src/ui/content_control.cpp
index 6383a10e..5bc8eda4 100644
--- a/src/ui/content_control.cpp
+++ b/src/ui/content_control.cpp
@@ -28,5 +28,8 @@ void ContentControl::SetChild(Control* child) {
OnChildChanged(old_child, child);
}
-void ContentControl::OnChildChanged(Control* old_child, Control* new_child) {}
+void ContentControl::OnChildChanged(Control* old_child, Control* new_child) {
+ CRU_UNUSED(old_child)
+ CRU_UNUSED(new_child)
+}
} // namespace cru::ui
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index 5f760939..cde602b7 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.cpp
@@ -105,9 +105,12 @@ void Control::SetCursor(std::shared_ptr<ICursor> cursor) {
}
}
-void Control::OnParentChanged(Control* old_parent, Control* new_parent) {}
+void Control::OnParentChanged(Control* old_parent, Control* new_parent) {
+ CRU_UNUSED(old_parent)
+ CRU_UNUSED(new_parent)
+}
-void Control::OnAttachToWindow(Window* window) {}
+void Control::OnAttachToWindow(Window* window) { CRU_UNUSED(window) }
-void Control::OnDetachToWindow(Window* window) {}
+void Control::OnDetachToWindow(Window* window) { CRU_UNUSED(window) }
} // namespace cru::ui
diff --git a/src/ui/controls/button.cpp b/src/ui/controls/button.cpp
index b7f972be..75651a1d 100644
--- a/src/ui/controls/button.cpp
+++ b/src/ui/controls/button.cpp
@@ -36,6 +36,8 @@ Button::Button() : click_detector_(this) {
render_object_->SetBorderEnabled(true);
MouseEnterEvent()->Direct()->AddHandler([this](event::MouseEventArgs& args) {
+ CRU_UNUSED(args)
+
if (click_detector_.GetPressingButton() & trigger_button_) {
SetState(ButtonState::Press);
} else {
@@ -44,6 +46,8 @@ Button::Button() : click_detector_(this) {
});
MouseLeaveEvent()->Direct()->AddHandler([this](event::MouseEventArgs& args) {
+ CRU_UNUSED(args)
+
if (click_detector_.GetPressingButton() & trigger_button_) {
SetState(ButtonState::Normal);
} else {
@@ -75,6 +79,8 @@ void Button::OnChildChanged(Control* old_child, Control* new_child) {
}
void Button::OnStateChange(ButtonState oldState, ButtonState newState) {
+ CRU_UNUSED(oldState)
+
switch (newState) {
case ButtonState::Normal:
Set(render_object_.get(), style_.normal);
diff --git a/src/ui/controls/flex_layout.cpp b/src/ui/controls/flex_layout.cpp
index cf6d4aad..6491b180 100644
--- a/src/ui/controls/flex_layout.cpp
+++ b/src/ui/controls/flex_layout.cpp
@@ -44,6 +44,8 @@ void FlexLayout::OnAddChild(Control* child, int position) {
}
void FlexLayout::OnRemoveChild(Control* child, int position) {
+ CRU_UNUSED(child)
+
render_object_->RemoveChild(position);
}
} // namespace cru::ui::controls
diff --git a/src/ui/layout_control.cpp b/src/ui/layout_control.cpp
index 00215a8e..cd9587c7 100644
--- a/src/ui/layout_control.cpp
+++ b/src/ui/layout_control.cpp
@@ -38,7 +38,13 @@ void LayoutControl::RemoveChild(const int position) {
OnRemoveChild(child, position);
}
-void LayoutControl::OnAddChild(Control* child, int position) {}
+void LayoutControl::OnAddChild(Control* child, int position) {
+ CRU_UNUSED(child)
+ CRU_UNUSED(position)
+}
-void LayoutControl::OnRemoveChild(Control* child, int position) {}
+void LayoutControl::OnRemoveChild(Control* child, int position) {
+ CRU_UNUSED(child)
+ CRU_UNUSED(position)
+}
} // namespace cru::ui
diff --git a/src/ui/render/flex_layout_render_object.cpp b/src/ui/render/flex_layout_render_object.cpp
index 3370ffc1..a5fde12a 100644
--- a/src/ui/render/flex_layout_render_object.cpp
+++ b/src/ui/render/flex_layout_render_object.cpp
@@ -42,11 +42,15 @@ RenderObject* FlexLayoutRenderObject::HitTest(const Point& point) {
} // namespace cru::ui::render
void FlexLayoutRenderObject::OnAddChild(RenderObject* new_child, int position) {
+ CRU_UNUSED(new_child)
+
child_layout_data_.emplace(child_layout_data_.cbegin() + position);
}
void FlexLayoutRenderObject::OnRemoveChild(RenderObject* removed_child,
int position) {
+ CRU_UNUSED(removed_child)
+
child_layout_data_.erase(child_layout_data_.cbegin() + position);
}
diff --git a/src/ui/render/render_object.cpp b/src/ui/render/render_object.cpp
index 8e65dad0..b6a9e8e4 100644
--- a/src/ui/render/render_object.cpp
+++ b/src/ui/render/render_object.cpp
@@ -42,14 +42,23 @@ void RenderObject::Layout(const Rect& rect) {
}
void RenderObject::OnParentChanged(RenderObject* old_parent,
- RenderObject* new_parent) {}
+ RenderObject* new_parent) {
+ CRU_UNUSED(old_parent)
+ CRU_UNUSED(new_parent)
+}
void RenderObject::OnAddChild(RenderObject* new_child, int position) {
+ CRU_UNUSED(new_child)
+ CRU_UNUSED(position)
+
InvalidateLayout();
InvalidatePaint();
}
void RenderObject::OnRemoveChild(RenderObject* removed_child, int position) {
+ CRU_UNUSED(removed_child)
+ CRU_UNUSED(position)
+
InvalidateLayout();
InvalidatePaint();
}
diff --git a/src/ui/render/text_render_object.cpp b/src/ui/render/text_render_object.cpp
index 9afb9f6e..260c6688 100644
--- a/src/ui/render/text_render_object.cpp
+++ b/src/ui/render/text_render_object.cpp
@@ -8,7 +8,7 @@
#include <algorithm>
#include <cassert>
-//TODO: Null Check!!!
+// TODO: Null Check!!!
namespace cru::ui::render {
TextRenderObject::TextRenderObject(
@@ -78,7 +78,9 @@ Size TextRenderObject::OnMeasureContent(const Size& available_size) {
return text_layout_->GetTextBounds().GetSize();
}
-void TextRenderObject::OnLayoutContent(const Rect& content_rect) {}
+void TextRenderObject::OnLayoutContent(const Rect& content_rect) {
+ CRU_UNUSED(content_rect)
+}
void TextRenderObject::OnAfterLayout() {
const auto&& size = GetContentRect().GetSize();
diff --git a/src/ui/render/window_render_object.cpp b/src/ui/render/window_render_object.cpp
index 8e48b7c9..12fc2ce1 100644
--- a/src/ui/render/window_render_object.cpp
+++ b/src/ui/render/window_render_object.cpp
@@ -92,16 +92,20 @@ namespace {
void SetRenderHostRecursive(RenderObject* render_object, IRenderHost* host) {
render_object->SetRenderHost(host);
for (const auto child : render_object->GetChildren()) {
- SetRenderHostRecursive(render_object, host);
+ SetRenderHostRecursive(child, host);
}
}
} // namespace
void WindowRenderObject::OnAddChild(RenderObject* new_child, int position) {
+ CRU_UNUSED(position)
+
SetRenderHostRecursive(new_child, render_host_.get());
}
void WindowRenderObject::OnRemoveChild(RenderObject* new_child, int position) {
+ CRU_UNUSED(position)
+
SetRenderHostRecursive(new_child, nullptr);
}
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index 73cbc60b..6ff44b4b 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -203,6 +203,8 @@ void Window::OnNativePaint(std::nullptr_t) {
}
void Window::OnNativeResize(const Size& size) {
+ CRU_UNUSED(size)
+
render_object_->GetRenderHost()->InvalidateLayout();
}