Knife Tool for Sample Clips (Again) (#5524)
* Rebase BaraMGB's Knife Co-authored-by: Steffen Baranowsky <BaraMGB@freenet.de> * Draw marker * Refactoring and shift mode * Allow resizing * Add Icon * Fix stuck marker on RMB, remove unnecessary cast * Remove redundant line, more const * Fix * Review fixes * Only perform split logic for SampleTCO * Add unquantizedModHeld function * missed one * Don't use copy/paste * Don't use copy/paste * More git troubles * Fix undo * git dammit * Cleaner solution? * Set cursor, add copy assignment to SampleBuffer * Add TODO comment * Make it build * Fixes from review * Make splitTCO virtual * Make splitTCO more generic Co-authored-by: IanCaio <iancaio_dev@hotmail.com> * Prevent resizing of MIDI clips in knife mode * Fix move/resize and rework box select via ctrl * Apply suggestions from code review. Co-authored-by: IanCaio <iancaio_dev@hotmail.com> * Don't show inaccurate/useless/empty text float in knife mode * Addresses Github review - Fixes a typo where QWidget::mousePressEvent was being called inside mouseReleaseEvent. - Avoids unnecessarily disabling journalling on the Split action, since it doesn't require it. * Revert format changes in Track * Revert format changes in Track.h * Revert formatting changes in Track.cpp Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com> Co-authored-by: IanCaio <iancaio_dev@hotmail.com>
This commit is contained in:
@@ -93,7 +93,6 @@ private:
|
||||
BoolModel m_recordModel;
|
||||
bool m_isPlaying;
|
||||
|
||||
|
||||
friend class SampleTCOView;
|
||||
|
||||
|
||||
@@ -132,6 +131,7 @@ protected:
|
||||
private:
|
||||
SampleTCO * m_tco;
|
||||
QPixmap m_paintPixmap;
|
||||
bool splitTCO( const TimePos pos ) override;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
enum EditMode
|
||||
{
|
||||
DrawMode,
|
||||
KnifeMode,
|
||||
SelectMode
|
||||
};
|
||||
|
||||
@@ -77,6 +78,7 @@ public slots:
|
||||
|
||||
void setEditMode( EditMode mode );
|
||||
void setEditModeDraw();
|
||||
void setEditModeKnife();
|
||||
void setEditModeSelect();
|
||||
void toggleProportionalSnap();
|
||||
|
||||
@@ -112,6 +114,7 @@ private:
|
||||
void wheelEvent( QWheelEvent * we ) override;
|
||||
|
||||
bool allowRubberband() const override;
|
||||
bool knifeMode() const override;
|
||||
|
||||
int trackIndexFromSelectionPoint(int yPos);
|
||||
int indexOfTrackView(const TrackView* tv);
|
||||
@@ -173,6 +176,7 @@ public:
|
||||
QSize sizeHint() const override;
|
||||
|
||||
SongEditor* m_editor;
|
||||
void syncEditMode();
|
||||
|
||||
protected:
|
||||
void resizeEvent( QResizeEvent * event ) override;
|
||||
@@ -194,9 +198,6 @@ signals:
|
||||
void resized();
|
||||
|
||||
private:
|
||||
void keyPressEvent( QKeyEvent * ke ) override;
|
||||
void keyReleaseEvent( QKeyEvent * ke ) override;
|
||||
|
||||
QAction* m_addBBTrackAction;
|
||||
QAction* m_addSampleTrackAction;
|
||||
QAction* m_addAutomationTrackAction;
|
||||
@@ -204,6 +205,7 @@ private:
|
||||
|
||||
ActionGroup * m_editModeGroup;
|
||||
QAction* m_drawModeAction;
|
||||
QAction* m_knifeModeAction;
|
||||
QAction* m_selectModeAction;
|
||||
QAction* m_crtlAction;
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ public:
|
||||
const TrackView * trackViewAt( const int _y ) const;
|
||||
|
||||
virtual bool allowRubberband() const;
|
||||
virtual bool knifeMode() const;
|
||||
|
||||
inline bool rubberBandActive() const
|
||||
{
|
||||
|
||||
@@ -58,6 +58,7 @@ class TrackContentObjectView : public selectableObject, public ModelView
|
||||
// We have to use a QSize here because using QPoint isn't supported.
|
||||
// width -> x, height -> y
|
||||
Q_PROPERTY( QSize mouseHotspotHand WRITE setMouseHotspotHand )
|
||||
Q_PROPERTY( QSize mouseHotspotKnife WRITE setMouseHotspotKnife )
|
||||
|
||||
public:
|
||||
TrackContentObjectView( TrackContentObject * tco, TrackView * tv );
|
||||
@@ -93,6 +94,7 @@ public:
|
||||
void setBBPatternBackground( const QColor & c );
|
||||
void setGradient( const bool & b );
|
||||
void setMouseHotspotHand(const QSize & s);
|
||||
void setMouseHotspotKnife(const QSize & s);
|
||||
|
||||
// access needsUpdate member variable
|
||||
bool needsUpdate();
|
||||
@@ -118,6 +120,9 @@ public:
|
||||
|
||||
QColor getColorForDisplay( QColor );
|
||||
|
||||
void inline setMarkerPos(int x) { m_markerPos = x; }
|
||||
void inline setMarkerEnabled(bool e) { m_marker = e; }
|
||||
|
||||
public slots:
|
||||
virtual bool close();
|
||||
void remove();
|
||||
@@ -137,6 +142,13 @@ protected:
|
||||
Merge
|
||||
};
|
||||
|
||||
TrackView * m_trackView;
|
||||
TimePos m_initialTCOPos;
|
||||
TimePos m_initialTCOEnd;
|
||||
|
||||
bool m_marker = false;
|
||||
int m_markerPos = 0;
|
||||
|
||||
virtual void constructContextMenu( QMenu * )
|
||||
{
|
||||
}
|
||||
@@ -145,7 +157,6 @@ protected:
|
||||
void contextMenuAction( ContextMenuAction action );
|
||||
void dragEnterEvent( QDragEnterEvent * dee ) override;
|
||||
void dropEvent( QDropEvent * de ) override;
|
||||
void leaveEvent( QEvent * e ) override;
|
||||
void mousePressEvent( QMouseEvent * me ) override;
|
||||
void mouseMoveEvent( QMouseEvent * me ) override;
|
||||
void mouseReleaseEvent( QMouseEvent * me ) override;
|
||||
@@ -155,6 +166,9 @@ protected:
|
||||
selectableObject::resizeEvent( re );
|
||||
}
|
||||
|
||||
bool unquantizedModHeld( QMouseEvent * me );
|
||||
TimePos quantizeSplitPos( TimePos, bool shiftMode );
|
||||
|
||||
float pixelsPerBar();
|
||||
|
||||
|
||||
@@ -176,6 +190,7 @@ private:
|
||||
MoveSelection,
|
||||
Resize,
|
||||
ResizeLeft,
|
||||
Split,
|
||||
CopySelection,
|
||||
ToggleSelected
|
||||
} ;
|
||||
@@ -183,12 +198,9 @@ private:
|
||||
static TextFloat * s_textFloat;
|
||||
|
||||
TrackContentObject * m_tco;
|
||||
TrackView * m_trackView;
|
||||
Actions m_action;
|
||||
QPoint m_initialMousePos;
|
||||
QPoint m_initialMouseGlobalPos;
|
||||
TimePos m_initialTCOPos;
|
||||
TimePos m_initialTCOEnd;
|
||||
QVector<TimePos> m_initialOffsets;
|
||||
|
||||
TextFloat * m_hint;
|
||||
@@ -202,7 +214,10 @@ private:
|
||||
QColor m_textShadowColor;
|
||||
QColor m_BBPatternBackground;
|
||||
bool m_gradient;
|
||||
QSize m_mouseHotspotHand; // QSize must be used because QPoint isn't supported by property system
|
||||
QSize m_mouseHotspotHand; // QSize must be used because QPoint
|
||||
QSize m_mouseHotspotKnife; // isn't supported by property system
|
||||
QCursor m_cursorHand;
|
||||
QCursor m_cursorKnife;
|
||||
bool m_cursorSetYet;
|
||||
|
||||
bool m_needsUpdate;
|
||||
@@ -217,6 +232,10 @@ private:
|
||||
|
||||
bool mouseMovedDistance( QMouseEvent * me, int distance );
|
||||
TimePos draggedTCOPos( QMouseEvent * me );
|
||||
int knifeMarkerPos( QMouseEvent * me );
|
||||
//! Return true iff TCO could be split. Currently only implemented for samples
|
||||
virtual bool splitTCO( const TimePos pos ){ return false; };
|
||||
void updateCursor(QMouseEvent * me);
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ protected:
|
||||
void dragEnterEvent( QDragEnterEvent * dee ) override;
|
||||
void dropEvent( QDropEvent * de ) override;
|
||||
void mousePressEvent( QMouseEvent * me ) override;
|
||||
void mouseReleaseEvent( QMouseEvent * me ) override;
|
||||
void paintEvent( QPaintEvent * pe ) override;
|
||||
void resizeEvent( QResizeEvent * re ) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user