aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render/FlexLayoutRenderObject.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-03-24 19:14:19 +0800
committercrupest <crupest@outlook.com>2021-03-24 19:14:19 +0800
commit7f15a1ff9a2007e119798053083a0a87d042990a (patch)
treecb35c01a7eaee867376d959b96c9bbd15df939e5 /src/ui/render/FlexLayoutRenderObject.cpp
parent74956951ee663012df0c3fe4ebe29799cb2f7732 (diff)
parent7703063a5816b089483e78ccd74bb9902ccfbea8 (diff)
downloadcru-7f15a1ff9a2007e119798053083a0a87d042990a.tar.gz
cru-7f15a1ff9a2007e119798053083a0a87d042990a.tar.bz2
cru-7f15a1ff9a2007e119798053083a0a87d042990a.zip
Merge branch 'master' of https://github.com/crupest/CruUI
Diffstat (limited to 'src/ui/render/FlexLayoutRenderObject.cpp')
-rw-r--r--src/ui/render/FlexLayoutRenderObject.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/ui/render/FlexLayoutRenderObject.cpp b/src/ui/render/FlexLayoutRenderObject.cpp
index ade230b5..b1ef69ee 100644
--- a/src/ui/render/FlexLayoutRenderObject.cpp
+++ b/src/ui/render/FlexLayoutRenderObject.cpp
@@ -1,7 +1,7 @@
#include "cru/ui/render/FlexLayoutRenderObject.hpp"
#include "cru/common/Logger.hpp"
-#include "cru/platform/graph/util/Painter.hpp"
+#include "cru/platform/graphics/util/Painter.hpp"
#include "cru/ui/render/LayoutHelper.hpp"
#include <algorithm>
@@ -10,6 +10,10 @@
namespace cru::ui::render {
+std::u16string_view FlexLayoutRenderObject::GetName() const {
+ return u"FlexLayoutRenderObject";
+}
+
struct tag_horizontal_t {};
struct tag_vertical_t {};
@@ -64,7 +68,7 @@ template <typename TSize>
constexpr TSize CreateTSize(decltype(std::declval<TSize>().width) main,
decltype(std::declval<TSize>().height) cross,
tag_vertical_t) {
- return TSize{main, cross};
+ return TSize{cross, main};
}
enum class FlexLayoutAdjustType { None, Expand, Shrink };
@@ -387,10 +391,11 @@ void FlexLayoutRenderObject::OnLayoutContent(const Rect& content_rect) {
const auto cross_align =
GetChildLayoutDataList()[i].cross_alignment.value_or(
GetItemCrossAlign());
- child->Layout(
- Point{content_rect.top + current_main_offset,
- CalculateAnchorByAlignment(cross_align, content_rect.left,
- content_rect.width, size.width)});
+ child->Layout(Point{
+ CalculateAnchorByAlignment(cross_align, content_rect.left,
+ content_rect.width, size.width),
+ content_rect.top + current_main_offset,
+ });
current_main_offset += size.height;
}
} else {
@@ -402,9 +407,9 @@ void FlexLayoutRenderObject::OnLayoutContent(const Rect& content_rect) {
GetChildLayoutDataList()[i].cross_alignment.value_or(
GetItemCrossAlign());
child->Layout(
- Point{content_rect.GetBottom() - current_main_offset,
- CalculateAnchorByAlignment(cross_align, content_rect.left,
- content_rect.width, size.width)});
+ Point{CalculateAnchorByAlignment(cross_align, content_rect.left,
+ content_rect.width, size.width),
+ content_rect.GetBottom() - current_main_offset});
current_main_offset += size.height;
}
}