fix layer order change

This commit is contained in:
2019-11-09 23:28:46 +01:00
parent a7511d3256
commit 8452bbe3e9
3 changed files with 17 additions and 6 deletions

View File

@@ -1295,7 +1295,18 @@ void Canvas::layer_remove(int idx) // m_order index
}
void Canvas::layer_order(int idx, int pos) // m_order index
{
std::swap(m_layers[idx], m_layers[pos]);
auto from = m_layers.begin() + idx;
auto to = m_layers.begin() + pos;
if (pos < idx)
std::rotate(to, from, from + 1);
if (pos > idx)
std::rotate(from, from + 1, to + 1);
if (m_current_layer_idx == idx)
m_current_layer_idx = pos;
else if (m_current_layer_idx == pos)
m_current_layer_idx = idx;
}
void Canvas::layer_merge(int source_idx, int dest_idx) // m_layer index
{