Enhanced snapping in song editor (#4973)
* New default behavior: Preserves offsets when moving clips, resizes in fixed increments. * Adds shift + drag: Snaps move start position (like current behavior) or end position (new), based on which is closest to the real position. When moving a selection, the grabbed clip snaps into position and the rest move relative to it. * Adds alt + drag: Allows fine adjustment of a clip's position or size, as an alternative to ctrl + drag. * Adds a Q dropdown in the song editor to allow finer or coarser snapping (8 bars to 1/16th bar) * Adds a proportional snap toggle. When enabled, snapping size/Q adjusts based on zoom, and a label appears showing the current snap size. This is disabled by default.
This commit is contained in:
@@ -63,7 +63,7 @@ public:
|
||||
MidiTime( const tact_t tact, const tick_t ticks );
|
||||
MidiTime( const tick_t ticks = 0 );
|
||||
|
||||
MidiTime toNearestTact() const;
|
||||
MidiTime quantize(float) const;
|
||||
MidiTime toAbsoluteTact() const;
|
||||
|
||||
MidiTime& operator+=( const MidiTime& time );
|
||||
@@ -110,4 +110,3 @@ private:
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -73,6 +73,9 @@ public:
|
||||
void loadSettings( const QDomElement& element );
|
||||
|
||||
ComboBoxModel *zoomingModel() const;
|
||||
ComboBoxModel *snappingModel() const;
|
||||
float getSnapSize() const;
|
||||
QString getSnapSizeString() const;
|
||||
|
||||
public slots:
|
||||
void scrolled( int new_pos );
|
||||
@@ -80,6 +83,7 @@ public slots:
|
||||
void setEditMode( EditMode mode );
|
||||
void setEditModeDraw();
|
||||
void setEditModeSelect();
|
||||
void toggleProportionalSnap();
|
||||
|
||||
void updatePosition( const MidiTime & t );
|
||||
void updatePositionLine();
|
||||
@@ -130,6 +134,8 @@ private:
|
||||
positionLine * m_positionLine;
|
||||
|
||||
ComboBoxModel* m_zoomingModel;
|
||||
ComboBoxModel* m_snappingModel;
|
||||
bool m_proportionalSnap;
|
||||
|
||||
static const QVector<double> m_zoomLevels;
|
||||
|
||||
@@ -141,7 +147,6 @@ private:
|
||||
EditMode m_ctrlMode; // mode they were in before they hit ctrl
|
||||
|
||||
friend class SongEditorWindow;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
@@ -170,6 +175,8 @@ protected slots:
|
||||
void lostFocus();
|
||||
void adjustUiAfterProjectLoad();
|
||||
|
||||
void updateSnapLabel();
|
||||
|
||||
signals:
|
||||
void playTriggered();
|
||||
void resized();
|
||||
@@ -181,6 +188,7 @@ private:
|
||||
QAction* m_addBBTrackAction;
|
||||
QAction* m_addSampleTrackAction;
|
||||
QAction* m_addAutomationTrackAction;
|
||||
QAction* m_setProportionalSnapAction;
|
||||
|
||||
ActionGroup * m_editModeGroup;
|
||||
QAction* m_drawModeAction;
|
||||
@@ -188,6 +196,8 @@ private:
|
||||
QAction* m_crtlAction;
|
||||
|
||||
ComboBox * m_zoomingComboBox;
|
||||
ComboBox * m_snappingComboBox;
|
||||
QLabel* m_snapSizeLabel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -236,7 +236,7 @@ public:
|
||||
// access needsUpdate member variable
|
||||
bool needsUpdate();
|
||||
void setNeedsUpdate( bool b );
|
||||
|
||||
|
||||
public slots:
|
||||
virtual bool close();
|
||||
void cut();
|
||||
@@ -297,6 +297,9 @@ private:
|
||||
Actions m_action;
|
||||
QPoint m_initialMousePos;
|
||||
QPoint m_initialMouseGlobalPos;
|
||||
MidiTime m_initialTCOPos;
|
||||
MidiTime m_initialTCOEnd;
|
||||
QVector<MidiTime> m_initialOffsets;
|
||||
|
||||
TextFloat * m_hint;
|
||||
|
||||
@@ -311,14 +314,17 @@ private:
|
||||
bool m_gradient;
|
||||
|
||||
bool m_needsUpdate;
|
||||
inline void setInitialMousePos( QPoint pos )
|
||||
inline void setInitialPos( QPoint pos )
|
||||
{
|
||||
m_initialMousePos = pos;
|
||||
m_initialMouseGlobalPos = mapToGlobal( pos );
|
||||
m_initialTCOPos = m_tco->startPosition();
|
||||
m_initialTCOEnd = m_initialTCOPos + m_tco->length();
|
||||
}
|
||||
void setInitialOffsets();
|
||||
|
||||
bool mouseMovedDistance( QMouseEvent * me, int distance );
|
||||
|
||||
MidiTime draggedTCOPos( QMouseEvent * me );
|
||||
} ;
|
||||
|
||||
|
||||
@@ -564,13 +570,13 @@ public:
|
||||
|
||||
using Model::dataChanged;
|
||||
|
||||
inline int getHeight()
|
||||
inline int getHeight()
|
||||
{
|
||||
return m_height >= MINIMAL_TRACK_HEIGHT
|
||||
? m_height
|
||||
? m_height
|
||||
: DEFAULT_TRACK_HEIGHT;
|
||||
}
|
||||
inline void setHeight( int height )
|
||||
inline void setHeight( int height )
|
||||
{
|
||||
m_height = height;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user