14.15: a chosen layer is revealed in the Layers panel

This commit is contained in:
ZacharyZhang-NY committed 2026-10-11 07:52:39 -04:00
1 parent e49359d997
commit da8b05509f
9 files changed
+177 -2

No files matched your search

+3
View File
@@ -126,6 +126,9 @@ void EditorSession::selectLayer(std::optional<QUuid> id)
resolveGradient();
}
setActiveLayerID(id);
// A layer chosen on the canvas shows in the panel.
if (revealActiveLayer())
notify();
}
void EditorSession::selectTool(NavigationTool value)
+2
View File
@@ -6,6 +6,8 @@ public:
// The primary layer becomes active when the document holds it.
void selectLayers(const QSet<QUuid> &ids, std::optional<QUuid> primary);
void extendSelection(QUuid id);
// Opens the active layer's folders; true when one opened.
bool revealActiveLayer();
void groupSelectedLayers();
// The active layer is a folder: something to unwrap.
bool canUngroupLayers() const;
+17
View File
@@ -170,9 +170,26 @@ void EditorSession::selectLayers(const QSet<QUuid> &ids, std::optional<QUuid> pr
: std::optional(*valid.begin());
setActiveLayerID(active);
m_selectedLayerIDs = valid;
revealActiveLayer();
notify();
}
bool EditorSession::revealActiveLayer()
{
if (m_collapsedGroupIDs.isEmpty() || !m_activeLayerID || !m_document)
return false;
// Validated parents end at the root: no cycle to guard.
const std::vector<ImageLayer> &layers = m_document->layers;
const int found = indexOf(layers, *m_activeLayerID);
std::optional<QUuid> parent = found >= 0 ? layers[found].parentID : std::nullopt;
bool opened = false;
while (parent) {
opened = m_collapsedGroupIDs.remove(*parent) || opened;
parent = layers[indexOf(layers, *parent)].parentID;
}
return opened;
}
void EditorSession::extendSelection(QUuid id)
{
const auto known = [&](const ImageLayer &layer) { return layer.id == id; };