14.15: a chosen layer is revealed in the Layers panel
This commit is contained in:
9 files changed
+177
-2
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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; };
|
||||
|
||||
@@ -32,6 +32,8 @@ NativeLayerList::NativeLayerList(EditorSession &session, QWidget *parent)
|
||||
|
||||
void NativeLayerList::update()
|
||||
{
|
||||
const bool activeChanged = m_shownActive != m_session.activeLayerID();
|
||||
m_shownActive = m_session.activeLayerID();
|
||||
const std::vector<LayerHierarchy::Entry> entries = m_session.layerRows();
|
||||
const std::vector<ImageLayer> &layers = m_session.document() ? m_session.document()->layers : std::vector<ImageLayer>();
|
||||
std::vector<ImageLayer> next;
|
||||
@@ -70,6 +72,9 @@ void NativeLayerList::update()
|
||||
}
|
||||
// Heights change at once, as Swift's noteHeightOfRows.
|
||||
m_column->layout()->activate();
|
||||
// A newly active layer comes into view; a scroll stays.
|
||||
if (const int row = indexOf(m_rows, m_shownActive); activeChanged && row >= 0)
|
||||
ensureWidgetVisible(m_cells[row], 0, 0);
|
||||
// A rename, asked from anywhere, is typed in the row.
|
||||
if (const std::optional<QUuid> renaming = m_session.renamingLayerID()) {
|
||||
const int row = indexOf(m_rows, renaming);
|
||||
|
||||
@@ -271,6 +271,8 @@ private:
|
||||
EditorSession &m_session;
|
||||
LayerColumn *const m_column;
|
||||
std::vector<LayerCell *> m_cells;
|
||||
// The active layer last shown: a new one scrolls in.
|
||||
std::optional<QUuid> m_shownActive;
|
||||
std::vector<ImageLayer> m_rows;
|
||||
std::map<QUuid, LayerHierarchy::Entry> m_details;
|
||||
bool m_editingEnabled = false;
|
||||
|
||||
Reference in new issue
Block a user