Layer › Ungroup Layers (Ctrl+Shift+G), in a folder's menu too; Alt over a mask shows the eye pointer (13.15)
This commit is contained in:
1 parent
3f2b99f045
commit
6ea248367d
12 files changed
+271
-12
No files matched your search
@@ -7,6 +7,9 @@ public:
|
||||
void selectLayers(const QSet<QUuid> &ids, std::optional<QUuid> primary);
|
||||
void extendSelection(QUuid id);
|
||||
void groupSelectedLayers();
|
||||
// The active layer is a folder: something to unwrap.
|
||||
bool canUngroupLayers() const;
|
||||
void ungroupLayers();
|
||||
std::vector<LayerHierarchy::Entry> layerRows() const;
|
||||
bool canPlaceLayer(QUuid id, std::optional<QUuid> parent) const;
|
||||
bool placeLayer(QUuid id, std::optional<QUuid> parent, std::optional<QUuid> above = std::nullopt, bool atBottom = false);
|
||||
|
||||
@@ -317,6 +317,44 @@ void EditorSession::groupSelectedLayers()
|
||||
endEdit();
|
||||
}
|
||||
|
||||
bool EditorSession::canUngroupLayers() const
|
||||
{
|
||||
const std::optional<ImageLayer> active = activeLayer();
|
||||
return canEditLayers() && active && active->isGroup;
|
||||
}
|
||||
|
||||
// The folder's children take its place, in order.
|
||||
void EditorSession::ungroupLayers()
|
||||
{
|
||||
if (!canUngroupLayers())
|
||||
return;
|
||||
const ImageLayer group = activeLayer().value();
|
||||
std::vector<ImageLayer> children;
|
||||
for (const ImageLayer &layer : m_document->layers) {
|
||||
if (layer.parentID == group.id) {
|
||||
children.push_back(layer);
|
||||
children.back().parentID = group.parentID;
|
||||
}
|
||||
}
|
||||
std::vector<ImageLayer> layers;
|
||||
QSet<QUuid> childIDs;
|
||||
for (const ImageLayer &child : children)
|
||||
childIDs.insert(child.id);
|
||||
for (const ImageLayer &layer : m_document->layers) {
|
||||
if (layer.id == group.id)
|
||||
layers.insert(layers.end(), children.begin(), children.end());
|
||||
else if (!childIDs.contains(layer.id))
|
||||
layers.push_back(layer);
|
||||
}
|
||||
releaseDetachedClipping(layers);
|
||||
finishOpacityEdit();
|
||||
beginEdit(QStringLiteral("Ungroup Layers"));
|
||||
m_document->layers = layers;
|
||||
selectLayers(childIDs, children.empty() ? std::nullopt : std::optional(children.front().id));
|
||||
m_collapsedGroupIDs.remove(group.id);
|
||||
endEdit();
|
||||
}
|
||||
|
||||
std::vector<LayerHierarchy::Entry> EditorSession::layerRows() const
|
||||
{
|
||||
std::vector<ProjectLayerRecord> records;
|
||||
|
||||
Reference in new issue
Block a user