Merge pull request #1652 from curlymorphic/821

proposed fix 821 Range-select in Song Editor
This commit is contained in:
Lukas W
2015-01-22 13:16:40 +01:00
5 changed files with 48 additions and 2 deletions

View File

@@ -35,6 +35,7 @@ class QPixmap;
class QToolBar;
class NStateButton;
class TextFloat;
class SongEditor;
class TimeLineWidget : public QWidget, public JournallingObject
@@ -128,6 +129,11 @@ public:
m_ppt / MidiTime::ticksPerTact() );
}
signals:
void regionSelectedFromPixels( int, int );
void selectionFinished();
public slots:
void updatePosition( const MidiTime & );
@@ -171,6 +177,7 @@ private:
TextFloat * m_hint;
int m_initalXSelect;
enum actions
@@ -178,7 +185,8 @@ private:
NoAction,
MovePositionMarker,
MoveLoopBegin,
MoveLoopEnd
MoveLoopEnd,
SelectSongTCO,
} m_action;
int m_moveXOff;

View File

@@ -126,6 +126,17 @@ public slots:
virtual void dropEvent( QDropEvent * _de );
virtual void dragEnterEvent( QDragEnterEvent * _dee );
///
/// \brief selectRegionFromPixels
/// \param x
/// \param y
/// Use the rubber band to select TCO from all tracks using x, y pixels
void selectRegionFromPixels(int x, int y);
///
/// \brief stopRubberBand
/// Removes the rubber band from display when finished with.
void stopRubberBand();
protected:
static const int DEFAULT_PIXELS_PER_TACT = 16;

View File

@@ -39,6 +39,7 @@
#include "NStateButton.h"
#include "GuiApplication.h"
#include "TextFloat.h"
#include "SongEditor.h"
#if QT_VERSION < 0x040800
@@ -280,7 +281,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event )
{
return;
}
if( event->button() == Qt::LeftButton )
if( event->button() == Qt::LeftButton && !(event->modifiers() & Qt::ShiftModifier) )
{
m_action = MovePositionMarker;
if( event->x() - m_xOffset < s_posMarkerPixmap->width() )
@@ -292,6 +293,11 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event )
m_moveXOff = s_posMarkerPixmap->width() / 2;
}
}
else if( event->button() == Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier) )
{
m_action = SelectSongTCO;
m_initalXSelect = event->x();
}
else if( event->button() == Qt::RightButton || event->button() == Qt::MiddleButton )
{
m_moveXOff = s_posMarkerPixmap->width() / 2;
@@ -373,6 +379,9 @@ void TimeLineWidget::mouseMoveEvent( QMouseEvent* event )
update();
break;
}
case SelectSongTCO:
emit regionSelectedFromPixels( m_initalXSelect , event->x() );
break;
default:
break;
@@ -386,6 +395,7 @@ void TimeLineWidget::mouseReleaseEvent( QMouseEvent* event )
{
delete m_hint;
m_hint = NULL;
if ( m_action == SelectSongTCO ) { emit selectionFinished(); }
m_action = NoAction;
}

View File

@@ -313,6 +313,19 @@ void TrackContainerView::dragEnterEvent( QDragEnterEvent * _dee )
arg( Track::SampleTrack ) );
}
void TrackContainerView::selectRegionFromPixels(int x, int y)
{
m_rubberBand->setEnabled( true );
m_rubberBand->show();
m_rubberBand->setGeometry( min( x, y ), 0, max( x, y ) - min( x, y ), std::numeric_limits<int>::max() );
}
void TrackContainerView::stopRubberBand()
{
m_rubberBand->hide();
m_rubberBand->setEnabled( false );
}

View File

@@ -98,6 +98,10 @@ SongEditor::SongEditor( Song * _song ) :
SLOT( updatePosition( const MidiTime & ) ) );
connect( m_timeLine, SIGNAL( positionChanged( const MidiTime & ) ),
this, SLOT( updatePosition( const MidiTime & ) ) );
connect( m_timeLine, SIGNAL( regionSelectedFromPixels( int, int ) ),
this, SLOT( selectRegionFromPixels( int, int ) ) );
connect( m_timeLine, SIGNAL( selectionFinished() ),
this, SLOT( stopRubberBand() ) );
m_positionLine = new positionLine( this );