File tree Expand file tree Collapse file tree 4 files changed +8
-6
lines changed
Expand file tree Collapse file tree 4 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ class LMMS_EXPORT TimePos
7070 TimePos ( const bar_t bar, const tick_t ticks );
7171 TimePos ( const tick_t ticks = 0 );
7272
73- TimePos quantize (float ) const ;
73+ TimePos quantize (float bars, bool forceRoundDown = false ) const ;
7474 TimePos toAbsoluteBar () const { return getBar () * s_ticksPerBar; }
7575
7676 TimePos& operator +=(const TimePos& time)
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ TimePos::TimePos( const tick_t ticks ) :
5353{
5454}
5555
56- TimePos TimePos::quantize (float bars) const
56+ TimePos TimePos::quantize (float bars, bool forceRoundDown ) const
5757{
5858 // The intervals we should snap to, our new position should be a factor of this
5959 int interval = s_ticksPerBar * bars;
@@ -65,7 +65,7 @@ TimePos TimePos::quantize(float bars) const
6565 // Ternary expression is making sure that the snap happens in the direction to
6666 // the right even if m_ticks is negative and the offset is exactly half-way
6767 // More details on issue #5840 and PR #5847
68- int snapUp = ((2 * offset) == -interval)
68+ int snapUp = forceRoundDown || ((2 * offset) == -interval)
6969 ? 0
7070 : (2 * offset) / interval;
7171
Original file line number Diff line number Diff line change 3737#include " Knob.h"
3838#include " SampleClip.h"
3939#include " SampleTrackWindow.h"
40+ #include " SongEditor.h"
4041#include " StringPairDrag.h"
4142#include " TrackContainerView.h"
4243#include " TrackLabelButton.h"
@@ -211,11 +212,12 @@ void SampleTrackView::dropEvent(QDropEvent *de)
211212 ? trackHeadWidth
212213 : de->pos ().x ();
213214
215+ const float snapSize = getGUI ()->songEditor ()->m_editor ->getSnapSize ();
214216 TimePos clipPos = trackContainerView ()->fixedClips ()
215217 ? TimePos (0 )
216218 : TimePos (((xPos - trackHeadWidth) / trackContainerView ()->pixelsPerBar ()
217219 * TimePos::ticksPerBar ()) + trackContainerView ()->currentPosition ()
218- ).quantize (1.0 );
220+ ).quantize (snapSize, true );
219221
220222 auto sClip = static_cast <SampleClip*>(getTrack ()->createClip (clipPos));
221223 if (sClip ) { sClip ->setSampleFile (value); }
Original file line number Diff line number Diff line change @@ -598,8 +598,8 @@ void TrackContentWidget::mousePressEvent( QMouseEvent * me )
598598 so.at ( i )->setSelected ( false );
599599 }
600600 getTrack ()->addJournalCheckPoint ();
601- const TimePos pos = getPosition ( me-> x () ). getBar () *
602- TimePos::ticksPerBar ( );
601+ const float snapSize = getGUI ()-> songEditor ()-> m_editor -> getSnapSize ();
602+ const TimePos pos = TimePos ( getPosition (me-> x ())). quantize (snapSize, true );
603603 getTrack ()->createClip (pos);
604604 }
605605}
You can’t perform that action at this time.
0 commit comments