# HG changeset patch # User Chris Cannam # Date 1173092021 0 # Node ID bd2d0346da0e92705a2812acb8ad297282b32373 # Parent 34bbbcb3c01fb752b8de786a24f2bc881b966acf * Inhibit making and displaying time selections in slice layers diff -r 34bbbcb3c01f -r bd2d0346da0e layer/Layer.h --- a/layer/Layer.h Fri Mar 02 14:00:12 2007 +0000 +++ b/layer/Layer.h Mon Mar 05 10:53:41 2007 +0000 @@ -270,6 +270,8 @@ virtual bool needsTextLabelHeight() const { return false; } + virtual bool hasTimeXAxis() const { return true; } + /** * Return the minimum and maximum values for the y axis of the * model in this layer, as well as whether the layer is configured diff -r 34bbbcb3c01f -r bd2d0346da0e layer/SliceLayer.h --- a/layer/SliceLayer.h Fri Mar 02 14:00:12 2007 +0000 +++ b/layer/SliceLayer.h Mon Mar 05 10:53:41 2007 +0000 @@ -61,6 +61,8 @@ virtual bool getValueExtents(float &min, float &max, bool &logarithmic, QString &unit) const; + virtual bool hasTimeXAxis() const { return false; } + virtual bool isLayerScrollable(const View *v) const { return false; } enum EnergyScale { LinearScale, MeterScale, dBScale }; diff -r 34bbbcb3c01f -r bd2d0346da0e view/Pane.cpp --- a/view/Pane.cpp Fri Mar 02 14:00:12 2007 +0000 +++ b/view/Pane.cpp Mon Mar 05 10:53:41 2007 +0000 @@ -812,6 +812,8 @@ } else if (mode == ViewManager::SelectMode) { + if (!hasTopLayerTimeXAxis()) return; + bool closeToLeft = false, closeToRight = false; Selection selection = getSelectionAt(e->x(), closeToLeft, closeToRight); @@ -909,6 +911,8 @@ } else if (mode == ViewManager::SelectMode) { + if (!hasTopLayerTimeXAxis()) return; + if (m_manager && m_manager->haveInProgressSelection()) { bool exclusive; @@ -970,7 +974,7 @@ if (!m_clickedInRange) { - if (mode == ViewManager::SelectMode) { + if (mode == ViewManager::SelectMode && hasTopLayerTimeXAxis()) { bool closeToLeft = false, closeToRight = false; getSelectionAt(e->x(), closeToLeft, closeToRight); if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) { @@ -1011,6 +1015,8 @@ } else if (mode == ViewManager::SelectMode) { + if (!hasTopLayerTimeXAxis()) return; + dragExtendSelection(e); } else if (mode == ViewManager::DrawMode) { @@ -1690,6 +1696,8 @@ } else if (mode == ViewManager::SelectMode) { + if (!hasTopLayerTimeXAxis()) return; + bool haveSelection = (m_manager && !m_manager->getSelections().empty()); if (haveSelection) { diff -r 34bbbcb3c01f -r bd2d0346da0e view/View.cpp --- a/view/View.cpp Fri Mar 02 14:00:12 2007 +0000 +++ b/view/View.cpp Mon Mar 05 10:53:41 2007 +0000 @@ -1071,6 +1071,15 @@ return false; } +bool +View::hasTopLayerTimeXAxis() const +{ + LayerList::const_iterator i = m_layers.end(); + if (i == m_layers.begin()) return false; + --i; + return (*i)->hasTimeXAxis(); +} + void View::zoom(bool in) { @@ -1435,6 +1444,8 @@ void View::drawSelections(QPainter &paint) { + if (!hasTopLayerTimeXAxis()) return; + MultiSelection::SelectionList selections; if (m_manager) { diff -r 34bbbcb3c01f -r bd2d0346da0e view/View.h --- a/view/View.h Fri Mar 02 14:00:12 2007 +0000 +++ b/view/View.h Mon Mar 05 10:53:41 2007 +0000 @@ -285,6 +285,12 @@ // rather than with a translucent fill. bool areLayerColoursSignificant() const; + // True if the top layer has a time axis on the x coordinate (this + // is generally the case except for spectrum/slice layers). It + // will not be possible to make or display selections if this is + // false. + bool hasTopLayerTimeXAxis() const; + bool setCentreFrame(size_t f, bool doEmit); void checkProgress(void *object);