aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/flex_layout.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-05-24 01:40:02 +0800
committercrupest <crupest@outlook.com>2020-05-24 01:40:02 +0800
commitd86a71f79afe0e4dac768f61d6bff690567aca5b (patch)
tree4957e9a64c77680deb07201fbd879bf036616dae /src/ui/controls/flex_layout.cpp
parentf3a8fd608a9776ef0a5f547da918a32cf6074060 (diff)
downloadcru-d86a71f79afe0e4dac768f61d6bff690567aca5b.tar.gz
cru-d86a71f79afe0e4dac768f61d6bff690567aca5b.tar.bz2
cru-d86a71f79afe0e4dac768f61d6bff690567aca5b.zip
...
Diffstat (limited to 'src/ui/controls/flex_layout.cpp')
-rw-r--r--src/ui/controls/flex_layout.cpp71
1 files changed, 0 insertions, 71 deletions
diff --git a/src/ui/controls/flex_layout.cpp b/src/ui/controls/flex_layout.cpp
deleted file mode 100644
index 5412164a..00000000
--- a/src/ui/controls/flex_layout.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "cru/ui/controls/flex_layout.hpp"
-
-#include "cru/ui/render/flex_layout_render_object.hpp"
-
-namespace cru::ui::controls {
-using render::FlexLayoutRenderObject;
-
-FlexLayout::FlexLayout() {
- render_object_.reset(new FlexLayoutRenderObject());
- render_object_->SetAttachedControl(this);
-}
-
-FlexLayout::~FlexLayout() = default;
-
-render::RenderObject* FlexLayout::GetRenderObject() const {
- return render_object_.get();
-}
-
-namespace {
-int FindPosition(render::RenderObject* parent, render::RenderObject* child) {
- const auto& render_objects = parent->GetChildren();
- const auto find_result =
- std::find(render_objects.cbegin(), render_objects.cend(), child);
- if (find_result == render_objects.cend()) {
- throw std::logic_error("Control is not a child of FlexLayout.");
- }
- return static_cast<int>(find_result - render_objects.cbegin());
-}
-} // namespace
-
-FlexChildLayoutData FlexLayout::GetChildLayoutData(Control* control) {
- Expects(control);
- return *render_object_->GetChildLayoutData(
- FindPosition(render_object_.get(), control->GetRenderObject()));
-}
-
-void FlexLayout::SetChildLayoutData(Control* control,
- const FlexChildLayoutData& data) {
- Expects(control);
- *render_object_->GetChildLayoutData(
- FindPosition(render_object_.get(), control->GetRenderObject())) = data;
-}
-
-FlexMainAlignment FlexLayout::GetContentMainAlign() const {
- return render_object_->GetContentMainAlign();
-}
-
-void FlexLayout::SetContentMainAlign(FlexMainAlignment value) {
- if (value == GetContentMainAlign()) return;
- render_object_->SetContentMainAlign(value);
-}
-
-FlexDirection FlexLayout::GetFlexDirection() const {
- return render_object_->GetFlexDirection();
-}
-
-void FlexLayout::SetFlexDirection(FlexDirection direction) {
- if (direction == GetFlexDirection()) return;
- render_object_->SetFlexDirection(direction);
-}
-
-void FlexLayout::OnAddChild(Control* child, const Index position) {
- render_object_->AddChild(child->GetRenderObject(), position);
-}
-
-void FlexLayout::OnRemoveChild(Control* child, const Index position) {
- CRU_UNUSED(child)
-
- render_object_->RemoveChild(position);
-}
-} // namespace cru::ui::controls