Add LayerGroup::insertLayerBefore

This commit is contained in:
Martín Capello 2024-09-16 16:00:02 -03:00
parent 722c74189c
commit e5bf9cb253
2 changed files with 12 additions and 0 deletions

View File

@ -623,6 +623,17 @@ void LayerGroup::insertLayer(Layer* layer, Layer* after)
layer->setParent(this);
}
void LayerGroup::insertLayerBefore(Layer* layer, Layer* before)
{
auto before_it = m_layers.end();
if (before) {
before_it = std::find(m_layers.begin(), m_layers.end(), before);
}
m_layers.insert(before_it, layer);
layer->setParent(this);
}
void LayerGroup::stackLayer(Layer* layer, Layer* after)
{
ASSERT(layer != after);

View File

@ -206,6 +206,7 @@ namespace doc {
void addLayer(Layer* layer);
void removeLayer(Layer* layer);
void insertLayer(Layer* layer, Layer* after);
void insertLayerBefore(Layer* layer, Layer* before);
void stackLayer(Layer* layer, Layer* after);
Layer* firstLayer() const { return (m_layers.empty() ? nullptr: m_layers.front()); }