Done! As a 4th commit
regards,
On Wed, Jan 25, 2012 at 11:21 PM, Tobias Doerffel <[email protected]
> wrote:
> Hi!
>
> 2012/1/25 S . <[email protected]>:
> > Here are 3 small patches that I propose to you, based on stable-0.4
> > (cacc0d6).
>
> Good stuff! However can you please fix the local static variable in
> knob::setPosition(). Once fixed, I'll apply the patches and commit
> them to the Git repo, so they can go into 0.4.13.
>
> Best regards
>
> Toby
>
From 898b84ceec69f2d37be8c25f244b489e44285fd1 Mon Sep 17 00:00:00 2001
From: NoiseByNorthwest <[email protected]>
Date: Sat, 21 Jan 2012 20:34:24 +0100
Subject: [PATCH 1/4] Add magnetic effect (for init value) on knobs
---
include/AutomatableModel.h | 5 +++++
src/gui/widgets/knob.cpp | 28 +++++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h
index b9b436f..453949b 100644
--- a/include/AutomatableModel.h
+++ b/include/AutomatableModel.h
@@ -268,6 +268,11 @@ signals:
return AutomatableModel::value<type>( _frameOffset ); \
} \
\
+ inline type initValue() const \
+ { \
+ return AutomatableModel::initValue<type>(); \
+ } \
+ \
inline type minValue() const \
{ \
return AutomatableModel::minValue<type>(); \
diff --git a/src/gui/widgets/knob.cpp b/src/gui/widgets/knob.cpp
index 40dff8d..0df4a8b 100644
--- a/src/gui/widgets/knob.cpp
+++ b/src/gui/widgets/knob.cpp
@@ -558,7 +558,33 @@ void knob::wheelEvent( QWheelEvent * _we )
void knob::setPosition( const QPoint & _p )
{
- model()->setValue( model()->value() - getValue( _p ) );
+ const float current = model()->value();
+ const float next = current - getValue( _p );
+
+ if( model()->initValue() == current )
+ {
+ // not critical but should be a property
+ static int magnet_dec = 0;
+ if( ++magnet_dec > 20 )
+ {
+ magnet_dec = 0;
+ model()->setValue( next );
+ }
+
+ return;
+ }
+
+ const bool current_sign = model()->initValue() - current < 0;
+ const bool next_sign = model()->initValue() - next < 0;
+
+ if( current_sign != next_sign )
+ {
+ model()->setValue( model()->initValue() );
+ }
+ else
+ {
+ model()->setValue( next );
+ }
}
--
1.7.5.4
From 11d0252bde5f8d247616e195b8ae60899fae8e70 Mon Sep 17 00:00:00 2001
From: NoiseByNorthwest <[email protected]>
Date: Sat, 21 Jan 2012 22:23:42 +0100
Subject: [PATCH 2/4] Piano-roll: remove from selection feature (shift +
left-click)
---
src/gui/piano_roll.cpp | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/src/gui/piano_roll.cpp b/src/gui/piano_roll.cpp
index e81c657..030c9fe 100644
--- a/src/gui/piano_roll.cpp
+++ b/src/gui/piano_roll.cpp
@@ -1765,7 +1765,15 @@ void pianoRoll::computeSelectedNotes(bool shift)
pos_ticks + len_ticks > sel_pos_start &&
pos_ticks < sel_pos_end )
{
- ( *it )->setSelected( true );
+ // remove from selection when holding shift
+ if( shift && ( *it )->selected() )
+ {
+ ( *it )->setSelected(false);
+ }
+ else
+ {
+ ( *it )->setSelected(true);
+ }
}
}
}
--
1.7.5.4
From 8e4b09ae0f88dc28aba6b87374a840c29bfc5744 Mon Sep 17 00:00:00 2001
From: NoiseByNorthwest <[email protected]>
Date: Sun, 22 Jan 2012 13:25:58 +0100
Subject: [PATCH 3/4] Piano-roll: preserve melody when resizing a note by
holding shift
---
include/piano_roll.h | 2 +-
src/gui/piano_roll.cpp | 53 ++++++++++++++++++++++++++++++++++++++----------
2 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/include/piano_roll.h b/include/piano_roll.h
index 426fd81..c00d649 100644
--- a/include/piano_roll.h
+++ b/include/piano_roll.h
@@ -204,7 +204,7 @@ private:
inline int noteEditRight() const;
inline int noteEditLeft() const;
- void dragNotes( int x, int y, bool alt );
+ void dragNotes( int x, int y, bool alt, bool shift );
static const int cm_scrollAmtHoriz = 10;
static const int cm_scrollAmtVert = 1;
diff --git a/src/gui/piano_roll.cpp b/src/gui/piano_roll.cpp
index 030c9fe..7bb995f 100644
--- a/src/gui/piano_roll.cpp
+++ b/src/gui/piano_roll.cpp
@@ -927,8 +927,8 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
m_action == ActionResizeNote )
{
dragNotes( m_lastMouseX, m_lastMouseY,
- _ke->modifiers() &
- Qt::AltModifier );
+ _ke->modifiers() & Qt::AltModifier,
+ _ke->modifiers() & Qt::ShiftModifier );
}
}
_ke->accept();
@@ -955,8 +955,8 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
m_action == ActionResizeNote )
{
dragNotes( m_lastMouseX, m_lastMouseY,
- _ke->modifiers() &
- Qt::AltModifier );
+ _ke->modifiers() & Qt::AltModifier,
+ _ke->modifiers() & Qt::ShiftModifier );
}
}
_ke->accept();
@@ -995,8 +995,8 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
m_action == ActionResizeNote )
{
dragNotes( m_lastMouseX, m_lastMouseY,
- _ke->modifiers() &
- Qt::AltModifier );
+ _ke->modifiers() & Qt::AltModifier,
+ _ke->modifiers() & Qt::ShiftModifier );
}
}
@@ -1033,8 +1033,8 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
m_action == ActionResizeNote )
{
dragNotes( m_lastMouseX, m_lastMouseY,
- _ke->modifiers() &
- Qt::AltModifier );
+ _ke->modifiers() & Qt::AltModifier,
+ _ke->modifiers() & Qt::ShiftModifier );
}
}
@@ -1944,7 +1944,12 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
pauseTestNotes();
}
- dragNotes(_me->x(), _me->y(), _me->modifiers() & Qt::AltModifier);
+ dragNotes(
+ _me->x(),
+ _me->y(),
+ _me->modifiers() & Qt::AltModifier,
+ _me->modifiers() & Qt::ShiftModifier
+ );
if( replay_note && m_action == ActionMoveNote )
{
@@ -2318,7 +2323,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
-void pianoRoll::dragNotes( int x, int y, bool alt )
+void pianoRoll::dragNotes( int x, int y, bool alt, bool shift )
{
// dragging one or more notes around
@@ -2355,7 +2360,10 @@ void pianoRoll::dragNotes( int x, int y, bool alt )
off_key += 0 - (m_moveBoundaryBottom + off_key);
}
}
-
+
+ int shift_offset = 0;
+ int shift_ref_pos = -1;
+
// get note-vector of current pattern
const NoteVector & notes = m_pattern->notes();
@@ -2363,6 +2371,19 @@ void pianoRoll::dragNotes( int x, int y, bool alt )
NoteVector::ConstIterator it = notes.begin();
while( it != notes.end() )
{
+ const int pos = ( *it )->pos().getTicks();
+ // when resizing a note and holding shift: shift the following
+ // notes to preserve the melody
+ if( m_action == ActionResizeNote && shift )
+ {
+ int shifted_pos = ( *it )->oldPos().getTicks() + shift_offset;
+ if( shifted_pos && pos == shift_ref_pos )
+ {
+ shifted_pos -= off_ticks;
+ }
+ ( *it )->setPos( midiTime( shifted_pos ) );
+ }
+
if( ( *it )->selected() )
{
@@ -2399,6 +2420,16 @@ void pianoRoll::dragNotes( int x, int y, bool alt )
{
ticks_new = 1;
}
+ else if( shift )
+ {
+ // when holding shift: update the offset used to shift
+ // the following notes
+ if( pos > shift_ref_pos )
+ {
+ shift_offset += off_ticks;
+ shift_ref_pos = pos;
+ }
+ }
( *it )->setLength( midiTime( ticks_new ) );
m_lenOfNewNotes = ( *it )->length();
--
1.7.5.4
From 09450ddacf41af469ce70f4d0d832cd9ccfff2b8 Mon Sep 17 00:00:00 2001
From: NoiseByNorthwest <[email protected]>
Date: Thu, 26 Jan 2012 00:38:46 +0100
Subject: [PATCH 4/4] Replace static var by property, see "Add magnetic
effect..." commit
---
include/knob.h | 2 ++
src/gui/widgets/knob.cpp | 7 +++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/knob.h b/include/knob.h
index 3e13dec..aa2767c 100644
--- a/include/knob.h
+++ b/include/knob.h
@@ -151,6 +151,8 @@ private:
QPoint m_origMousePos;
bool m_buttonPressed;
+ int m_magneticDecay;
+
float m_totalAngle;
int m_angle;
QImage m_cache;
diff --git a/src/gui/widgets/knob.cpp b/src/gui/widgets/knob.cpp
index 0df4a8b..efb4b6e 100644
--- a/src/gui/widgets/knob.cpp
+++ b/src/gui/widgets/knob.cpp
@@ -63,6 +63,7 @@ knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) :
m_volumeKnob( false ),
m_mouseOffset( 0.0f ),
m_buttonPressed( false ),
+ m_magneticDecay( 0 ),
m_angle( -10 ),
m_outerColor( NULL )
{
@@ -563,11 +564,9 @@ void knob::setPosition( const QPoint & _p )
if( model()->initValue() == current )
{
- // not critical but should be a property
- static int magnet_dec = 0;
- if( ++magnet_dec > 20 )
+ if( ++m_magneticDecay > 20 )
{
- magnet_dec = 0;
+ m_magneticDecay = 0;
model()->setValue( next );
}
--
1.7.5.4
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
LMMS-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lmms-devel