Mercurial > hg > sonic-visualiser
diff main/MainWindow.cpp @ 2332:1057ae621c87 time-frequency-boxes
Rename time-frequency box to plain box; have it adopt the unit from the layer beneath if created empty
author | Chris Cannam |
---|---|
date | Wed, 25 Sep 2019 09:53:15 +0100 |
parents | f2dd9218617e |
children | f576895641c2 |
line wrap: on
line diff
--- a/main/MainWindow.cpp Tue Sep 24 11:33:57 2019 +0100 +++ b/main/MainWindow.cpp Wed Sep 25 09:53:15 2019 +0100 @@ -4020,16 +4020,13 @@ Layer *newLayer = nullptr; + bool isNewEmptyLayer = false; + if (emptyTypes.find(type) != emptyTypes.end()) { newLayer = m_document->createEmptyLayer(type); if (newLayer) { - for (auto &a : m_toolActions) { - if (a.first == ViewManager::DrawMode) { - a.second->trigger(); - break; - } - } + isNewEmptyLayer = true; } } else { @@ -4068,6 +4065,23 @@ } } + if (isNewEmptyLayer) { + + double vmin, vmax, dmin, dmax; + QString unit; + if (pane->getTopLayerDisplayExtents + (vmin, vmax, dmin, dmax, &unit)) { + newLayer->adoptExtents(vmin, vmax, unit); + } + + for (auto &a : m_toolActions) { + if (a.first == ViewManager::DrawMode) { + a.second->trigger(); + break; + } + } + } + if (newLayer) { m_document->addLayerToView(pane, newLayer); m_paneStack->setCurrentLayer(pane, newLayer);