aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-03-01 22:08:15 +0800
committercrupest <crupest@outlook.com>2020-03-01 22:08:15 +0800
commit6e0e0e18cbeff6487160c84d71997575f6cccebd (patch)
tree9b4c552234dfc4f9b5129dd96b25dba3518e4581 /src/ui/controls
parent8fc4e33b97372d93b1bcc4b598e5c8e2f15652d8 (diff)
downloadcru-6e0e0e18cbeff6487160c84d71997575f6cccebd.tar.gz
cru-6e0e0e18cbeff6487160c84d71997575f6cccebd.tar.bz2
cru-6e0e0e18cbeff6487160c84d71997575f6cccebd.zip
Add stack layout.
Diffstat (limited to 'src/ui/controls')
-rw-r--r--src/ui/controls/flex_layout.cpp6
-rw-r--r--src/ui/controls/stack_layout.cpp27
-rw-r--r--src/ui/controls/text_box.cpp1
3 files changed, 31 insertions, 3 deletions
diff --git a/src/ui/controls/flex_layout.cpp b/src/ui/controls/flex_layout.cpp
index 6491b180..6ea26d92 100644
--- a/src/ui/controls/flex_layout.cpp
+++ b/src/ui/controls/flex_layout.cpp
@@ -28,15 +28,15 @@ int FindPosition(render::RenderObject* parent, render::RenderObject* child) {
FlexChildLayoutData FlexLayout::GetChildLayoutData(Control* control) {
assert(control);
- return render_object_->GetChildLayoutData(
+ return *render_object_->GetChildLayoutData(
FindPosition(render_object_.get(), control->GetRenderObject()));
}
void FlexLayout::SetChildLayoutData(Control* control,
const FlexChildLayoutData& data) {
assert(control);
- render_object_->SetChildLayoutData(
- FindPosition(render_object_.get(), control->GetRenderObject()), data);
+ *render_object_->GetChildLayoutData(
+ FindPosition(render_object_.get(), control->GetRenderObject())) = data;
}
void FlexLayout::OnAddChild(Control* child, int position) {
diff --git a/src/ui/controls/stack_layout.cpp b/src/ui/controls/stack_layout.cpp
new file mode 100644
index 00000000..b9abb510
--- /dev/null
+++ b/src/ui/controls/stack_layout.cpp
@@ -0,0 +1,27 @@
+#include "cru/ui/controls/stack_layout.hpp"
+
+#include "cru/ui/render/stack_layout_render_object.hpp"
+
+namespace cru::ui::controls {
+using render::StackLayoutRenderObject;
+
+StackLayout::StackLayout() : render_object_(new StackLayoutRenderObject()) {
+ render_object_->SetAttachedControl(this);
+}
+
+StackLayout::~StackLayout() = default;
+
+render::RenderObject* StackLayout::GetRenderObject() const {
+ return render_object_.get();
+}
+
+void StackLayout::OnAddChild(Control* child, int position) {
+ render_object_->AddChild(child->GetRenderObject(), position);
+}
+
+void StackLayout::OnRemoveChild(Control* child, int position) {
+ CRU_UNUSED(child)
+
+ render_object_->RemoveChild(position);
+}
+} // namespace cru::ui::controls
diff --git a/src/ui/controls/text_box.cpp b/src/ui/controls/text_box.cpp
new file mode 100644
index 00000000..7fde06d9
--- /dev/null
+++ b/src/ui/controls/text_box.cpp
@@ -0,0 +1 @@
+#include "cru/ui/controls/text_box.hpp"