Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shortcut refactor for songeditor #3649

Merged
merged 4 commits into from
Aug 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/Rubberband.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ class RubberBand : public QRubberBand
virtual ~RubberBand();

QVector<selectableObject *> selectedObjects() const;
QVector<selectableObject *> selectableObjects() const;


protected:
virtual void resizeEvent( QResizeEvent * _re );

private:
QVector<selectableObject *> selectableObjects() const;

};

Expand Down
8 changes: 8 additions & 0 deletions include/SongEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include <QVector>

#include "ActionGroup.h"
#include "Editor.h"
#include "TrackContainerView.h"

Expand Down Expand Up @@ -82,6 +83,7 @@ public slots:

void updatePosition( const MidiTime & t );
void updatePositionLine();
void selectAllTcos( bool select );

protected:
virtual void closeEvent( QCloseEvent * ce );
Expand Down Expand Up @@ -135,6 +137,7 @@ private slots:
bool m_smoothScroll;

EditMode m_mode;
EditMode m_ctrlMode; // mode they were in before they hit ctrl

friend class SongEditorWindow;

Expand Down Expand Up @@ -169,12 +172,17 @@ protected slots:
void resized();

private:
virtual void keyPressEvent( QKeyEvent * ke );
virtual void keyReleaseEvent( QKeyEvent * ke );

QAction* m_addBBTrackAction;
QAction* m_addSampleTrackAction;
QAction* m_addAutomationTrackAction;

ActionGroup * m_editModeGroup;
QAction* m_drawModeAction;
QAction* m_selectModeAction;
QAction* m_crtlAction;

ComboBox * m_zoomingComboBox;
};
Expand Down
1 change: 0 additions & 1 deletion include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ public slots:
void update();
void changePosition( const MidiTime & newPos = MidiTime( -1 ) );


protected:
virtual void dragEnterEvent( QDragEnterEvent * dee );
virtual void dropEvent( QDropEvent * de );
Expand Down
8 changes: 3 additions & 5 deletions include/TrackContainerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ class TrackContainerView : public QWidget, public ModelView,

inline QVector<selectableObject *> selectedObjects()
{
if( allowRubberband() == true )
{
return( m_rubberBand->selectedObjects() );
}
return( QVector<selectableObject *>() );
return( m_rubberBand->selectedObjects() );
}


Expand Down Expand Up @@ -126,6 +122,8 @@ class TrackContainerView : public QWidget, public ModelView,
}


RubberBand *rubberBand() const;

public slots:
void realignTracks();
TrackView * createTrackView( Track * _t );
Expand Down
161 changes: 75 additions & 86 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,99 +688,87 @@ void TrackContentObjectView::paintTextLabel(QString const & text, QPainter & pai
void TrackContentObjectView::mousePressEvent( QMouseEvent * me )
{
setInitialMousePos( me->pos() );
if( m_trackView->trackContainerView()->allowRubberband() == true &&
me->button() == Qt::LeftButton )
if( me->button() == Qt::LeftButton )
{
if( m_trackView->trackContainerView()->rubberBandActive() == true )
{
// Propagate to trackView for rubberbanding
selectableObject::mousePressEvent( me );
}
else if ( me->modifiers() & Qt::ControlModifier )
if( me->modifiers() & Qt::ControlModifier )
{
if( isSelected() == true )
if( isSelected() )
{
m_action = CopySelection;
}
else
{
m_action = ToggleSelected;
gui->songEditor()->m_editor->selectAllTcos( false );
QVector<TrackContentObjectView *> tcoViews;
tcoViews.push_back( this );
DataFile dataFile = createTCODataFiles( tcoViews );
QPixmap thumbnail = QPixmap::grabWidget( this ).scaled(
128, 128,
Qt::KeepAspectRatio,
Qt::SmoothTransformation );
new StringPairDrag( QString( "tco_%1" ).arg(
m_tco->getTrack()->type() ),
dataFile.toString(), thumbnail, this );
}
}
else if( !me->modifiers() )
else
{
if( isSelected() == true )
if( isSelected() )
{
m_action = MoveSelection;
}
}
}
else if( me->button() == Qt::LeftButton &&
me->modifiers() & Qt::ControlModifier )
{
// start drag-action
QVector<TrackContentObjectView *> tcoViews;
tcoViews.push_back( this );
DataFile dataFile = createTCODataFiles( tcoViews );
QPixmap thumbnail = QPixmap::grabWidget( this ).scaled(
128, 128,
Qt::KeepAspectRatio,
Qt::SmoothTransformation );
new StringPairDrag( QString( "tco_%1" ).arg(
m_tco->getTrack()->type() ),
dataFile.toString(), thumbnail, this );
}
else if( me->button() == Qt::LeftButton &&
/* engine::mainWindow()->isShiftPressed() == false &&*/
fixedTCOs() == false )
{
m_tco->addJournalCheckPoint();
else
{
gui->songEditor()->m_editor->selectAllTcos( false );
m_tco->addJournalCheckPoint();

// move or resize
m_tco->setJournalling( false );
// move or resize
m_tco->setJournalling( false );

setInitialMousePos( me->pos() );
setInitialMousePos( me->pos() );

if( me->x() < width() - RESIZE_GRIP_WIDTH )
{
m_action = Move;
m_oldTime = m_tco->startPosition();
QCursor c( Qt::SizeAllCursor );
QApplication::setOverrideCursor( c );
s_textFloat->setTitle( tr( "Current position" ) );
delete m_hint;
m_hint = TextFloat::displayMessage( tr( "Hint" ),
tr( "Press <%1> and drag to make "
"a copy." ).arg(
#ifdef LMMS_BUILD_APPLE
"⌘"),
#else
"Ctrl"),
#endif
embed::getIconPixmap( "hint" ), 0 );
}
else if( !m_tco->getAutoResize() )
{
m_action = Resize;
m_oldTime = m_tco->length();
QCursor c( Qt::SizeHorCursor );
QApplication::setOverrideCursor( c );
s_textFloat->setTitle( tr( "Current length" ) );
delete m_hint;
m_hint = TextFloat::displayMessage( tr( "Hint" ),
tr( "Press <%1> for free "
"resizing." ).arg(
#ifdef LMMS_BUILD_APPLE
"⌘"),
#else
"Ctrl"),
#endif
embed::getIconPixmap( "hint" ), 0 );
if( me->x() < width() - RESIZE_GRIP_WIDTH )
{
m_action = Move;
m_oldTime = m_tco->startPosition();
QCursor c( Qt::SizeAllCursor );
QApplication::setOverrideCursor( c );
s_textFloat->setTitle( tr( "Current position" ) );
delete m_hint;
m_hint = TextFloat::displayMessage( tr( "Hint" ),
tr( "Press <%1> and drag to make "
"a copy." ).arg(
#ifdef LMMS_BUILD_APPLE
"⌘"),
#else
"Ctrl"),
#endif
embed::getIconPixmap( "hint" ), 0 );
}
else if( !m_tco->getAutoResize() )
{
m_action = Resize;
m_oldTime = m_tco->length();
QCursor c( Qt::SizeHorCursor );
QApplication::setOverrideCursor( c );
s_textFloat->setTitle( tr( "Current length" ) );
delete m_hint;
m_hint = TextFloat::displayMessage( tr( "Hint" ),
tr( "Press <%1> for free "
"resizing." ).arg(
#ifdef LMMS_BUILD_APPLE
"⌘"),
#else
"Ctrl"),
#endif
embed::getIconPixmap( "hint" ), 0 );
}
// s_textFloat->reparent( this );
// setup text-float as if TCO was already moved/resized
mouseMoveEvent( me );
s_textFloat->show();
}
}
// s_textFloat->reparent( this );
// setup text-float as if TCO was already moved/resized
mouseMoveEvent( me );
s_textFloat->show();
}
else if( me->button() == Qt::RightButton )
{
Expand Down Expand Up @@ -826,10 +814,7 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me )
{
if( m_action == CopySelection )
{
if( mouseMovedDistance( me, 2 ) == true &&
m_trackView->trackContainerView()->allowRubberband() == true &&
m_trackView->trackContainerView()->rubberBandActive() == false &&
( me->modifiers() & Qt::ControlModifier ) )
if( mouseMovedDistance( me, 2 ) == true )
{
// Clear the action here because mouseReleaseEvent will not get
// triggered once we go into drag.
Expand Down Expand Up @@ -923,7 +908,7 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me )
t = ( *it )->startPosition() +
static_cast<int>( dx *MidiTime::ticksPerTact() /
ppt )-smallest_pos;
if( ! ( me->modifiers() & Qt::AltModifier )
if( ! ( me->modifiers() & Qt::ControlModifier )
&& me->button() == Qt::NoButton )
{
t = t.toNearestTact();
Expand Down Expand Up @@ -1464,19 +1449,17 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, QDropEvent * de )
const TrackContainer::TrackList tracks = getTrack()->trackContainer()->tracks();
const int currentTrackIndex = tracks.indexOf( getTrack() );

bool allowRubberband = m_trackView->trackContainerView()->allowRubberband();
bool wasSelection = m_trackView->trackContainerView()->rubberBand()->selectedObjects().count();

// Unselect the old group
if( allowRubberband == true )
{
const QVector<selectableObject *> so =
m_trackView->trackContainerView()->selectedObjects();
for( QVector<selectableObject *>::const_iterator it = so.begin();
it != so.end(); ++it )
{
( *it )->setSelected( false );
}
}


// TODO -- Need to draw the hovericon either way, or ghost the TCOs
// onto their final position.
Expand All @@ -1501,10 +1484,11 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, QDropEvent * de )
TrackContentObject * tco = t->createTCO( pos );
tco->restoreState( tcoElement );
tco->movePosition( pos );
if( allowRubberband == true )
if( wasSelection )
{
tco->selectViewOnCreate( true );
}

//check tco name, if the same as source track name dont copy
if( tco->name() == tracks[trackIndex]->name() )
{
Expand Down Expand Up @@ -1551,6 +1535,11 @@ void TrackContentWidget::mousePressEvent( QMouseEvent * me )
else if( me->button() == Qt::LeftButton &&
!m_trackView->trackContainerView()->fixedTCOs() )
{
QVector<selectableObject*> so = m_trackView->trackContainerView()->rubberBand()->selectedObjects();
for( int i = 0; i < so.count(); ++i )
{
so.at( i )->setSelected( false);
}
getTrack()->addJournalCheckPoint();
const MidiTime pos = getPosition( me->x() ).getTact() *
MidiTime::ticksPerTact();
Expand Down
5 changes: 5 additions & 0 deletions src/gui/TrackContainerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ void TrackContainerView::resizeEvent( QResizeEvent * _re )
QWidget::resizeEvent( _re );
}

RubberBand *TrackContainerView::rubberBand() const
{
return m_rubberBand;
}




Expand Down
Loading