En-/disable loop points via MidiControlListener
MidiControlListener's toggleLoop action makes the song object emit a loopPointsChanged signal, which timeLine connects to and enables or disables the loop points accordingly. Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
committed by
Tobias Doerffel
parent
dc539d88de
commit
86b0056488
@@ -44,9 +44,12 @@ public:
|
||||
ActionNone = 0,
|
||||
ActionControl,
|
||||
ActionPlay,
|
||||
ActionStop
|
||||
ActionStop,
|
||||
ActionToggleLoop,
|
||||
ActionJumpToLoopStart,
|
||||
ActionJumpToLoopEnd
|
||||
} EventAction;
|
||||
static const int numActions = 4;
|
||||
static const int numActions = 7;
|
||||
|
||||
typedef QMap<int, EventAction> ActionMap;
|
||||
|
||||
|
||||
@@ -192,7 +192,11 @@ public:
|
||||
return m_timeSigModel;
|
||||
}
|
||||
|
||||
|
||||
inline void toggleLoopPoints( int _mode )
|
||||
{
|
||||
emit loopPointsChanged( _mode );
|
||||
}
|
||||
|
||||
public slots:
|
||||
void play( void );
|
||||
void record( void );
|
||||
@@ -316,7 +320,7 @@ signals:
|
||||
void tempoChanged( bpm_t _new_bpm );
|
||||
void timeSignatureChanged( int _old_ticks_per_tact,
|
||||
int _ticks_per_tact );
|
||||
|
||||
void loopPointsChanged( int _mode );
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "engine.h"
|
||||
#include "note.h"
|
||||
#include "song.h"
|
||||
#include "timeline.h"
|
||||
#include "config_mgr.h"
|
||||
|
||||
const QString MidiControlListener::configClass = "MidiControlListener";
|
||||
@@ -46,7 +47,10 @@ const MidiControlListener::ActionNameMap MidiControlListener::actionNames[] =
|
||||
{ MidiControlListener::ActionNone, "", "" },
|
||||
{ MidiControlListener::ActionControl, "Control key", "control" },
|
||||
{ MidiControlListener::ActionPlay, "Play", "play" },
|
||||
{ MidiControlListener::ActionStop, "Stop", "stop" }
|
||||
{ MidiControlListener::ActionStop, "Stop", "stop" },
|
||||
{ MidiControlListener::ActionToggleLoop, "Toggle loop", "toggleLoop" },
|
||||
{ MidiControlListener::ActionJumpToLoopStart, "Jump to loop start", "jumpToLoopStart" },
|
||||
{ MidiControlListener::ActionJumpToLoopEnd, "Jump to loop end", "jumpToLoopEnd" }
|
||||
};
|
||||
|
||||
|
||||
@@ -152,6 +156,7 @@ void MidiControlListener::processInEvent( const midiEvent & _me,
|
||||
|
||||
void MidiControlListener::act( EventAction _action )
|
||||
{
|
||||
timeLine * tl = engine::getSong()->getPlayPos( song::Mode_PlaySong ).m_timeLine;
|
||||
switch( _action )
|
||||
{
|
||||
case ActionNone:
|
||||
@@ -164,6 +169,20 @@ void MidiControlListener::act( EventAction _action )
|
||||
case ActionStop:
|
||||
engine::getSong()->stop();
|
||||
break;
|
||||
case ActionToggleLoop:
|
||||
if( tl->loopPointsEnabled() )
|
||||
{
|
||||
engine::getSong()->toggleLoopPoints( timeLine::LoopPointsDisabled );
|
||||
}
|
||||
else
|
||||
{
|
||||
engine::getSong()->toggleLoopPoints( timeLine::LoopPointsEnabled );
|
||||
}
|
||||
break;
|
||||
case ActionJumpToLoopStart:
|
||||
break;
|
||||
case ActionJumpToLoopEnd:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,10 @@ void timeLine::addToolButtons( QWidget * _tool_bar )
|
||||
SLOT( toggleLoopPoints( int ) ) );
|
||||
connect( this, SIGNAL( loopPointStateLoaded( int ) ), loopPoints,
|
||||
SLOT( changeState( int ) ) );
|
||||
connect( engine::getSong(), SIGNAL( loopPointsChanged( int ) ), this,
|
||||
SLOT( toggleLoopPoints( int ) ) );
|
||||
connect( engine::getSong(), SIGNAL( loopPointsChanged( int ) ),
|
||||
loopPoints, SLOT( changeState( int ) ) );
|
||||
|
||||
nStateButton * behaviourAtStop = new nStateButton( _tool_bar );
|
||||
behaviourAtStop->addState( embed::getIconPixmap( "back_to_zero" ),
|
||||
|
||||
Reference in New Issue
Block a user