From 5291b587708b7f1b9be9187aa4df99ea2cfe0538 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 19 Nov 2018 23:10:45 +0800 Subject: Add FrameLayout. --- src/ui/controls/frame_layout.cpp | 16 ++++++++++++++++ src/ui/controls/frame_layout.hpp | 33 +++++++++++++++++++++++++++++++++ src/ui/ui_base.hpp | 15 +++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 src/ui/controls/frame_layout.cpp create mode 100644 src/ui/controls/frame_layout.hpp (limited to 'src/ui') diff --git a/src/ui/controls/frame_layout.cpp b/src/ui/controls/frame_layout.cpp new file mode 100644 index 00000000..32d25edc --- /dev/null +++ b/src/ui/controls/frame_layout.cpp @@ -0,0 +1,16 @@ +#include "frame_layout.hpp" + +namespace cru::ui::controls +{ + FrameLayout::FrameLayout() : Control(true) + { + + } + + FrameLayout::~FrameLayout() = default; + + StringView FrameLayout::GetControlType() const + { + return control_type; + } +} diff --git a/src/ui/controls/frame_layout.hpp b/src/ui/controls/frame_layout.hpp new file mode 100644 index 00000000..ca022780 --- /dev/null +++ b/src/ui/controls/frame_layout.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include + +#include "ui/control.hpp" + +namespace cru::ui::controls +{ + class FrameLayout : public Control + { + public: + static constexpr auto control_type = L"FrameLayout"; + + static FrameLayout* Create(const std::initializer_list& children = std::initializer_list{}) + { + const auto layout = new FrameLayout(); + for (auto child : children) + layout->AddChild(child); + return layout; + } + + protected: + FrameLayout(); + public: + FrameLayout(const FrameLayout& other) = delete; + FrameLayout(FrameLayout&& other) = delete; + FrameLayout& operator=(const FrameLayout& other) = delete; + FrameLayout& operator=(FrameLayout&& other) = delete; + ~FrameLayout() override; + + StringView GetControlType() const override final; + }; +} diff --git a/src/ui/ui_base.hpp b/src/ui/ui_base.hpp index c20d44b6..d9c9d0b2 100644 --- a/src/ui/ui_base.hpp +++ b/src/ui/ui_base.hpp @@ -91,6 +91,21 @@ namespace cru::ui return top + bottom; } + void SetLeftRight(const float value) + { + left = right = value; + } + + void SetTopBottom(const float value) + { + top = bottom = value; + } + + void SetAll(const float value) + { + left = top = right = bottom = value; + } + float Validate() const { return left >= 0.0 && top >= 0.0 && right >= 0.0 && bottom >= 0.0; -- cgit v1.2.3