Channel selector has a max range of num channels

When you add and remove channels, the range of the
L.E.D. channel selector is correct.
This commit is contained in:
Andrew Kelley
2009-09-30 17:04:28 -07:00
parent 33753495bd
commit dd28a654b5
6 changed files with 54 additions and 13 deletions

View File

@@ -225,6 +225,9 @@ protected:
float fittedValue( float _value ) const;
float m_minValue;
float m_maxValue;
float m_value;
private:
void linkModel( AutomatableModel * _model );
@@ -232,10 +235,7 @@ private:
DataType m_dataType;
float m_value;
float m_initValue;
float m_minValue;
float m_maxValue;
float m_step;
float m_range;
@@ -281,7 +281,18 @@ signals:
{ \
return AutomatableModel::maxValue<type>(); \
} \
\
inline void setMinValue(type val) \
{ \
m_minValue = val; \
if( m_value < m_minValue ) m_value = m_minValue; \
} \
\
inline void setMaxValue(type val) \
{ \
m_maxValue = val; \
if( m_value > m_maxValue ) m_value = m_maxValue; \
}
// some typed AutomatableModel-definitions

View File

@@ -105,6 +105,8 @@ private:
QHBoxLayout * chLayout;
QWidget * m_channelAreaWidget;
EffectRackView * m_rackView;
void updateMaxChannelSelector();
} ;
#endif

View File

@@ -1,9 +1,9 @@
#ifndef SENDBUTTONINDICATOR_H
#define SENDBUTTONINDICATOR_H
#include <QLabel>
#include <QDebug>
#include <QPixmap>
#include <QtGui/QLabel>
#include <QtGui/QPixmap>
#include "FxLine.h"
#include "FxMixerView.h"

View File

@@ -44,11 +44,11 @@ AutomatableModel::AutomatableModel( DataType _type,
const QString & _display_name,
bool _default_constructed ) :
Model( _parent, _display_name, _default_constructed ),
m_minValue( _min ),
m_maxValue( _max ),
m_dataType( _type ),
m_value( _val ),
m_initValue( _val ),
m_minValue( _min ),
m_maxValue( _max ),
m_step( _step ),
m_range( _max - _min ),
m_journalEntryReady( false ),

View File

@@ -1,9 +1,9 @@
#include "FxLine.h"
#include <QDebug>
#include <QPainter>
#include <QInputDialog>
#include <QLineEdit>
#include <QtGui/QInputDialog>
#include <QtGui/QPainter>
#include <QtGui/QLineEdit>
#include "FxMixer.h"
#include "FxMixerView.h"

View File

@@ -24,7 +24,6 @@
#include <QtGlobal>
#include <QDebug>
#include <QKeyEvent>
#include <QtGui/QButtonGroup>
#include <QtGui/QInputDialog>
@@ -37,6 +36,7 @@
#include <QtGui/QStackedLayout>
#include <QtGui/QScrollArea>
#include <QtGui/QStyle>
#include <QtGui/QKeyEvent>
#include "FxMixerView.h"
#include "knob.h"
@@ -45,6 +45,9 @@
#include "MainWindow.h"
#include "lcd_spinbox.h"
#include "gui_templates.h"
#include "InstrumentTrack.h"
#include "song.h"
#include "bb_track_container.h"
FxMixerView::FxMixerView() :
QWidget(),
@@ -90,7 +93,7 @@ FxMixerView::FxMixerView() :
}
// add the scrolling section to the main layout
// class for scroll area to pass key presses down
// class solely for scroll area to pass key presses down
class ChannelArea : public QScrollArea
{
public:
@@ -167,9 +170,33 @@ void FxMixerView::addNewChannel()
chLayout->addWidget(m_fxChannelViews[newChannelIndex]->m_fxLine);
updateFxLine(newChannelIndex);
updateMaxChannelSelector();
}
void FxMixerView::updateMaxChannelSelector()
{
// update the and max. channel number for every instrument
QVector<track *> songTrackList = engine::getSong()->tracks();
QVector<track *> bbTrackList = engine::getBBTrackContainer()->tracks();
QVector<track *> trackLists[] = {songTrackList, bbTrackList};
for(int tl=0; tl<2; ++tl)
{
QVector<track *> trackList = trackLists[tl];
for(int i=0; i<trackList.size(); ++i)
{
if( trackList[i]->type() == track::InstrumentTrack )
{
InstrumentTrack * inst = (InstrumentTrack *) trackList[i];
inst->effectChannelModel()->setMaxValue(
m_fxChannelViews.size()-1);
}
}
}
}
void FxMixerView::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
@@ -286,6 +313,7 @@ void FxMixerView::deleteChannel(int index)
}
setCurrentFxLine(selLine);
updateMaxChannelSelector();
}