mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 16:09:06 +07:00
add space_evenly layout align
This commit is contained in:
@@ -24,6 +24,7 @@ namespace e2d
|
||||
(center)
|
||||
(right)
|
||||
(space_around)
|
||||
(space_evenly)
|
||||
(space_between))
|
||||
|
||||
ENUM_HPP_CLASS_DECL(valigns, u8,
|
||||
@@ -31,6 +32,7 @@ namespace e2d
|
||||
(center)
|
||||
(bottom)
|
||||
(space_around)
|
||||
(space_evenly)
|
||||
(space_between))
|
||||
public:
|
||||
layout() = default;
|
||||
|
||||
@@ -43,6 +43,7 @@ layout.haligns = {
|
||||
center = "center",
|
||||
right = "right",
|
||||
space_around = "space_around",
|
||||
space_evenly = "space_evenly",
|
||||
space_between = "space_between"
|
||||
}
|
||||
|
||||
@@ -52,6 +53,7 @@ layout.valigns = {
|
||||
center = "center",
|
||||
bottom = "bottom",
|
||||
space_around = "space_around",
|
||||
space_evenly = "space_evenly",
|
||||
space_between = "space_between"
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +144,7 @@ namespace e2d::bindings::high
|
||||
LAYOUT_HALIGN_PAIR(center)
|
||||
LAYOUT_HALIGN_PAIR(right)
|
||||
LAYOUT_HALIGN_PAIR(space_around)
|
||||
LAYOUT_HALIGN_PAIR(space_evenly)
|
||||
LAYOUT_HALIGN_PAIR(space_between)
|
||||
});
|
||||
#undef LAYOUT_HALIGN_PAIR
|
||||
@@ -155,6 +156,7 @@ namespace e2d::bindings::high
|
||||
LAYOUT_VALIGN_PAIR(center)
|
||||
LAYOUT_VALIGN_PAIR(bottom)
|
||||
LAYOUT_VALIGN_PAIR(space_around)
|
||||
LAYOUT_VALIGN_PAIR(space_evenly)
|
||||
LAYOUT_VALIGN_PAIR(space_between)
|
||||
});
|
||||
#undef LAYOUT_VALIGN_PAIR
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace e2d
|
||||
"center",
|
||||
"right",
|
||||
"space_around",
|
||||
"space_evenly",
|
||||
"space_between"
|
||||
]
|
||||
},
|
||||
@@ -47,6 +48,7 @@ namespace e2d
|
||||
"center",
|
||||
"bottom",
|
||||
"space_around",
|
||||
"space_evenly",
|
||||
"space_between"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@ namespace
|
||||
case layout::haligns::space_around:
|
||||
YGNodeStyleSetJustifyContent(yn.as_root.get(), YGJustifySpaceAround);
|
||||
break;
|
||||
case layout::haligns::space_evenly:
|
||||
YGNodeStyleSetJustifyContent(yn.as_root.get(), YGJustifySpaceEvenly);
|
||||
break;
|
||||
case layout::haligns::space_between:
|
||||
YGNodeStyleSetJustifyContent(yn.as_root.get(), YGJustifySpaceBetween);
|
||||
break;
|
||||
@@ -60,6 +63,7 @@ namespace
|
||||
break;
|
||||
case layout::valigns::center:
|
||||
case layout::valigns::space_around:
|
||||
case layout::valigns::space_evenly:
|
||||
YGNodeStyleSetAlignItems(yn.as_root.get(), YGAlignCenter);
|
||||
break;
|
||||
case layout::valigns::bottom:
|
||||
@@ -87,6 +91,9 @@ namespace
|
||||
case layout::valigns::space_around:
|
||||
YGNodeStyleSetJustifyContent(yn.as_root.get(), YGJustifySpaceAround);
|
||||
break;
|
||||
case layout::valigns::space_evenly:
|
||||
YGNodeStyleSetJustifyContent(yn.as_root.get(), YGJustifySpaceEvenly);
|
||||
break;
|
||||
case layout::valigns::space_between:
|
||||
YGNodeStyleSetJustifyContent(yn.as_root.get(), YGJustifySpaceBetween);
|
||||
break;
|
||||
@@ -102,6 +109,7 @@ namespace
|
||||
break;
|
||||
case layout::haligns::center:
|
||||
case layout::haligns::space_around:
|
||||
case layout::haligns::space_evenly:
|
||||
YGNodeStyleSetAlignItems(yn.as_root.get(), YGAlignCenter);
|
||||
break;
|
||||
case layout::haligns::right:
|
||||
@@ -164,7 +172,7 @@ namespace
|
||||
|
||||
owner.for_joined_components<layout, actor>([](
|
||||
ecs::entity e,
|
||||
const layout& l,
|
||||
const layout&,
|
||||
const actor& a)
|
||||
{
|
||||
e.ensure_component<yogo_node>();
|
||||
@@ -226,8 +234,8 @@ namespace
|
||||
YGDirectionLTR);
|
||||
|
||||
for ( const auto& item : items ) {
|
||||
auto& item_a = item.owner().component<actor>();
|
||||
const auto& item_yn = item.owner().component<yogo_node>();
|
||||
gcomponent<actor> item_a = item.owner().component<actor>();
|
||||
const_gcomponent<yogo_node> item_yn = item.owner().component<yogo_node>();
|
||||
if ( item_a && item_a->node() && item_yn && item_yn->as_item ) {
|
||||
item_a->node()->translation(v2f(
|
||||
YGNodeLayoutGetLeft(item_yn->as_item.get()),
|
||||
|
||||
Reference in New Issue
Block a user