fix layer move nodes
This commit is contained in:
25
src/node.cpp
25
src/node.cpp
@@ -497,6 +497,8 @@ void Node::move_child(Node* n, int index)
|
||||
{
|
||||
App::I->ui_task([&]
|
||||
{
|
||||
int count = YGNodeGetChildCount(y_node);
|
||||
index = glm::clamp<int>(index, 0, count - 1);
|
||||
YGNodeRemoveChild(y_node, n->y_node);
|
||||
YGNodeInsertChild(y_node, n->y_node, index);
|
||||
auto it = std::find_if(m_children.begin(), m_children.end(),
|
||||
@@ -509,29 +511,14 @@ void Node::move_child(Node* n, int index)
|
||||
|
||||
void Node::move_child_front(Node* n)
|
||||
{
|
||||
App::I->ui_task([&]
|
||||
{
|
||||
int count = YGNodeGetChildCount(y_node);
|
||||
move_child(n, count - 1);
|
||||
});
|
||||
int count = YGNodeGetChildCount(y_node);
|
||||
move_child(n, count - 1);
|
||||
}
|
||||
|
||||
void Node::move_child_offset(Node* n, int offset)
|
||||
{
|
||||
App::I->ui_task([&]
|
||||
{
|
||||
int count = YGNodeGetChildCount(y_node);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (YGNodeGetChild(y_node, i) == n->y_node)
|
||||
{
|
||||
int new_index = glm::clamp<int>(i + offset, 0, count - 1);
|
||||
YGNodeRemoveChild(y_node, n->y_node);
|
||||
YGNodeInsertChild(y_node, n->y_node, new_index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
int idx = get_child_index(n);
|
||||
move_child(n, idx + offset);
|
||||
}
|
||||
|
||||
int Node::get_child_index(Node* n)
|
||||
|
||||
Reference in New Issue
Block a user