Mercurial > hg > svcore
changeset 31:4afaf0df4d51
* Add TextModel and TextLayer types
* Make View refresh work better when editing a model (previously edits might
not be refreshed if their visible changed area extended beyond the strict
frame range that was being modified in the model)
* Add phase-adjusted instantaneous frequency display to spectrogram layer
(still a work in progress)
* Pull maths aliases out into a separate header in dsp/maths so MathUtilities
can be included without introducing them
author | Chris Cannam |
---|---|
date | Mon, 20 Feb 2006 13:33:36 +0000 |
parents | a6ef94ecbe74 |
children | 5e28cbb431d0 |
files | base/View.cpp base/View.h |
diffstat | 2 files changed, 51 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/base/View.cpp Fri Feb 17 18:11:08 2006 +0000 +++ b/base/View.cpp Mon Feb 20 13:33:36 2006 +0000 @@ -414,8 +414,26 @@ #ifdef DEBUG_VIEW_WIDGET_PAINT std::cerr << "View(" << this << ")::modelChanged()" << std::endl; #endif - delete m_cache; - m_cache = 0; + + // If the model that has changed is not used by any of the cached + // layers, we won't need to recreate the cache + + bool recreate = false; + + bool discard; + LayerList scrollables = getScrollableBackLayers(false, discard); + for (LayerList::const_iterator i = scrollables.begin(); + i != scrollables.end(); ++i) { + if (*i == obj || (*i)->getModel() == obj) { + recreate = true; + break; + } + } + + if (recreate) { + delete m_cache; + m_cache = 0; + } checkProgress(obj); @@ -443,8 +461,25 @@ return; } - delete m_cache; - m_cache = 0; + // If the model that has changed is not used by any of the cached + // layers, we won't need to recreate the cache + + bool recreate = false; + + bool discard; + LayerList scrollables = getScrollableBackLayers(false, discard); + for (LayerList::const_iterator i = scrollables.begin(); + i != scrollables.end(); ++i) { + if (*i == obj || (*i)->getModel() == obj) { + recreate = true; + break; + } + } + + if (recreate) { + delete m_cache; + m_cache = 0; + } if (long(startFrame) < myStartFrame) startFrame = myStartFrame; if (endFrame > myEndFrame) endFrame = myEndFrame; @@ -455,7 +490,8 @@ checkProgress(obj); - update(x0, 0, x1 - x0 + 1, height()); + update(); +//!! update(x0, 0, x1 - x0 + 1, height()); } void @@ -695,7 +731,7 @@ } View::LayerList -View::getScrollableBackLayers(bool &changed) const +View::getScrollableBackLayers(bool testChanged, bool &changed) const { changed = false; @@ -704,7 +740,7 @@ if ((*i)->isLayerDormant()) continue; if ((*i)->isLayerScrollable()) scrollables.push_back(*i); else { - if (scrollables != m_lastScrollableBackLayers) { + if (testChanged && scrollables != m_lastScrollableBackLayers) { m_lastScrollableBackLayers = scrollables; changed = true; } @@ -721,7 +757,7 @@ scrollables.clear(); } - if (scrollables != m_lastScrollableBackLayers) { + if (testChanged && scrollables != m_lastScrollableBackLayers) { m_lastScrollableBackLayers = scrollables; changed = true; } @@ -729,10 +765,10 @@ } View::LayerList -View::getNonScrollableFrontLayers(bool &changed) const +View::getNonScrollableFrontLayers(bool testChanged, bool &changed) const { changed = false; - LayerList scrollables = getScrollableBackLayers(changed); + LayerList scrollables = getScrollableBackLayers(testChanged, changed); LayerList nonScrollables; // Everything in front of the first non-scrollable from the back @@ -748,7 +784,7 @@ nonScrollables.push_back(*i); } - if (nonScrollables != m_lastNonScrollableBackLayers) { + if (testChanged && nonScrollables != m_lastNonScrollableBackLayers) { m_lastNonScrollableBackLayers = nonScrollables; changed = true; } @@ -897,8 +933,8 @@ // are, we should store only those in the cache bool layersChanged = false; - LayerList scrollables = getScrollableBackLayers(layersChanged); - LayerList nonScrollables = getNonScrollableFrontLayers(layersChanged); + LayerList scrollables = getScrollableBackLayers(true, layersChanged); + LayerList nonScrollables = getNonScrollableFrontLayers(true, layersChanged); bool selectionCacheable = nonScrollables.empty(); bool haveSelections = m_manager && !m_manager->getSelections().empty(); bool selectionDrawn = false;
--- a/base/View.h Fri Feb 17 18:11:08 2006 +0000 +++ b/base/View.h Mon Feb 20 13:33:36 2006 +0000 @@ -224,8 +224,8 @@ size_t getModelsEndFrame() const; int getModelsSampleRate() const; bool areLayersScrollable() const; - LayerList getScrollableBackLayers(bool &changed) const; - LayerList getNonScrollableFrontLayers(bool &changed) const; + LayerList getScrollableBackLayers(bool testChanged, bool &changed) const; + LayerList getNonScrollableFrontLayers(bool testChanged, bool &changed) const; size_t getZoomConstraintBlockSize(size_t blockSize, ZoomConstraint::RoundingDirection dir = ZoomConstraint::RoundNearest) const;