Merge branch 'stable-1.2' into master

This commit is contained in:
Lukas W
2020-06-01 15:19:20 +02:00
18 changed files with 121 additions and 58 deletions

View File

@@ -1207,8 +1207,18 @@ MidiClient * Mixer::tryMidiClients()
printf( "midi apple didn't work: client_name=%s\n", client_name.toUtf8().constData());
#endif
printf( "Couldn't create MIDI-client, neither with ALSA nor with "
"OSS. Will use dummy-MIDI-client.\n" );
if(client_name != MidiDummy::name())
{
if (client_name.isEmpty())
{
printf("Unknown MIDI-client. ");
}
else
{
printf("Couldn't create %s MIDI-client. ", client_name.toUtf8().constData());
}
printf("Will use dummy-MIDI-client.\n");
}
m_midiClientName = MidiDummy::name();

View File

@@ -282,6 +282,8 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco,
m_textShadowColor( 0, 0, 0 ),
m_BBPatternBackground( 0, 0, 0 ),
m_gradient( true ),
m_mouseHotspotHand( 0, 0 ),
m_cursorSetYet( false ),
m_needsUpdate( true )
{
if( s_textFloat == NULL )
@@ -293,7 +295,7 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco,
setAttribute( Qt::WA_OpaquePaintEvent, true );
setAttribute( Qt::WA_DeleteOnClose, true );
setFocusPolicy( Qt::StrongFocus );
setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) );
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) );
move( 0, 0 );
show();
@@ -342,6 +344,12 @@ TrackContentObjectView::~TrackContentObjectView()
*/
void TrackContentObjectView::update()
{
if( !m_cursorSetYet )
{
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) );
m_cursorSetYet = true;
}
if( fixedTCOs() )
{
updateLength();
@@ -422,6 +430,11 @@ void TrackContentObjectView::setBBPatternBackground( const QColor & c )
void TrackContentObjectView::setGradient( const bool & b )
{ m_gradient = b; }
void TrackContentObjectView::setMouseHotspotHand(const QSize & s)
{
m_mouseHotspotHand = s;
}
// access needsUpdate member variable
bool TrackContentObjectView::needsUpdate()
{ return m_needsUpdate; }
@@ -609,7 +622,7 @@ void TrackContentObjectView::leaveEvent( QEvent * e )
{
if( cursor().shape() != Qt::BitmapCursor )
{
setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) );
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) );
}
if( e != NULL )
{

View File

@@ -55,6 +55,8 @@ AudioJack::AudioJack( bool & _success_ful, Mixer* _mixer ) :
m_framesDoneInCurBuf( 0 ),
m_framesToDoInCurBuf( 0 )
{
m_stopped = true;
_success_ful = initJackClient();
if( _success_ful )
{
@@ -200,8 +202,6 @@ bool AudioJack::initJackClient()
void AudioJack::startProcessing()
{
m_stopped = false;
if( m_active || m_client == NULL )
{
return;
@@ -244,6 +244,7 @@ void AudioJack::startProcessing()
}
}
m_stopped = false;
free( ports );
}
@@ -344,8 +345,8 @@ int AudioJack::processCallback( jack_nframes_t _nframes, void * _udata )
// add to the following sound processing
if( m_midiClient && _nframes > 0 )
{
m_midiClient->JackMidiRead(_nframes);
m_midiClient->JackMidiWrite(_nframes);
m_midiClient.load()->JackMidiRead(_nframes);
m_midiClient.load()->JackMidiWrite(_nframes);
}
for( int c = 0; c < channels(); ++c )

View File

@@ -95,6 +95,8 @@ MidiJack::MidiJack() :
/* jack midi out not implemented
JackMidiWrite and sendByte needs to be functional
before enabling this
If you enable this, also enable the
corresponding jack_port_unregister line below
m_output_port = jack_port_register(
jackClient(), "MIDI out", JACK_DEFAULT_MIDI_TYPE,
JackPortIsOutput, 0);
@@ -116,13 +118,18 @@ MidiJack::~MidiJack()
{
if(jackClient())
{
// remove ourselves first (atomically), so we will not get called again
m_jackAudio->removeMidiClient();
if( jack_port_unregister( jackClient(), m_input_port) != 0){
printf("Failed to unregister jack midi input\n");
}
/* Unused yet, see the corresponding jack_port_register call
if( jack_port_unregister( jackClient(), m_output_port) != 0){
printf("Failed to unregister jack midi output\n");
}
*/
if(m_jackClient)
{
@@ -174,19 +181,22 @@ void MidiJack::JackMidiRead(jack_nframes_t nframes)
jack_nframes_t event_index = 0;
jack_nframes_t event_count = jack_midi_get_event_count(port_buf);
jack_midi_event_get(&in_event, port_buf, 0);
for(i=0; i<nframes; i++)
int rval = jack_midi_event_get(&in_event, port_buf, 0);
if (rval == 0 /* 0 = success */)
{
if((in_event.time == i) && (event_index < event_count))
for(i=0; i<nframes; i++)
{
// lmms is setup to parse bytes coming from a device
// parse it byte by byte as it expects
for(b=0;b<in_event.size;b++)
parseData( *(in_event.buffer + b) );
if((in_event.time == i) && (event_index < event_count))
{
// lmms is setup to parse bytes coming from a device
// parse it byte by byte as it expects
for(b=0;b<in_event.size;b++)
parseData( *(in_event.buffer + b) );
event_index++;
if(event_index < event_count)
jack_midi_event_get(&in_event, port_buf, event_index);
event_index++;
if(event_index < event_count)
jack_midi_event_get(&in_event, port_buf, event_index);
}
}
}
}

View File

@@ -25,6 +25,7 @@
#include <QMouseEvent>
#include <QPainter>
#include <QPainterPath>
#include <QMenu>
#include "AutomationEditor.h"

View File

@@ -28,6 +28,7 @@
#include <QApplication>
#include <QFrame>
#include <QPainter>
#include <QPainterPath>
#include <QStyleFactory>
#include <QStyleOption>

View File

@@ -35,6 +35,7 @@
#include <QLayout>
#include <QMdiArea>
#include <QPainter>
#include <QPainterPath>
#include <QScrollBar>
#include <QStyleOption>
#include <QToolTip>

View File

@@ -1772,6 +1772,11 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
// then resize the note
m_action = ActionResizeNote;
for (Note *note : getSelectedNotes())
{
if (note->oldLength() <= 0) { note->setOldLength(4); }
}
// set resize-cursor
setCursor( Qt::SizeHorCursor );
}

View File

@@ -496,8 +496,8 @@ float Knob::getValue( const QPoint & _p )
{
float value;
// arcane mathemagicks for calculating knob movement
value = ( ( _p.y() + _p.y() * qMin( qAbs( _p.y() / 2.5f ), 6.0f ) ) ) / 12.0f;
// knob value increase is linear to mouse movement
value = .4f * _p.y();
// if shift pressed we want slower movement
if( gui->mainWindow()->isShiftPressed() )
@@ -585,13 +585,11 @@ void Knob::mousePressEvent( QMouseEvent * _me )
}
const QPoint & p = _me->pos();
m_origMousePos = p;
m_mouseOffset = QPoint(0, 0);
m_lastMousePos = p;
m_leftOver = 0.0f;
emit sliderPressed();
QApplication::setOverrideCursor( Qt::BlankCursor );
s_textFloat->setText( displayValue() );
s_textFloat->moveGlobal( this,
QPoint( width() + 2, 0 ) );
@@ -616,12 +614,13 @@ void Knob::mousePressEvent( QMouseEvent * _me )
void Knob::mouseMoveEvent( QMouseEvent * _me )
{
if( m_buttonPressed && _me->pos() != m_origMousePos )
if( m_buttonPressed && _me->pos() != m_lastMousePos )
{
m_mouseOffset = _me->pos() - m_origMousePos;
setPosition( m_mouseOffset );
// knob position is changed depending on last mouse position
setPosition( _me->pos() - m_lastMousePos );
emit sliderMoved( model()->value() );
QCursor::setPos( mapToGlobal( m_origMousePos ) );
// original position for next time is current position
m_lastMousePos = _me->pos();
}
s_textFloat->setText( displayValue() );
}

View File

@@ -23,6 +23,7 @@
*
*/
#include <cmath>
#include <QApplication>
#include <QLabel>
#include <QMouseEvent>
@@ -40,8 +41,9 @@
LcdSpinBox::LcdSpinBox( int numDigits, QWidget* parent, const QString& name ) :
LcdWidget( numDigits, parent, name ),
IntModelView( new IntModel( 0, 0, 0, NULL, name, true ), this ),
m_remainder( 0.f ),
m_mouseMoving( false ),
m_origMousePos(),
m_lastMousePos(),
m_displayOffset( 0 )
{
}
@@ -52,8 +54,9 @@ LcdSpinBox::LcdSpinBox( int numDigits, QWidget* parent, const QString& name ) :
LcdSpinBox::LcdSpinBox( int numDigits, const QString& style, QWidget* parent, const QString& name ) :
LcdWidget( numDigits, parent, name ),
IntModelView( new IntModel( 0, 0, 0, NULL, name, true ), this ),
m_remainder( 0.f ),
m_mouseMoving( false ),
m_origMousePos(),
m_lastMousePos(),
m_displayOffset( 0 )
{
}
@@ -90,8 +93,7 @@ void LcdSpinBox::mousePressEvent( QMouseEvent* event )
event->y() < cellHeight() + 2 )
{
m_mouseMoving = true;
m_origMousePos = event->globalPos();
QApplication::setOverrideCursor( Qt::BlankCursor );
m_lastMousePos = event->globalPos();
AutomatableModel *thisModel = model();
if( thisModel )
@@ -113,15 +115,20 @@ void LcdSpinBox::mouseMoveEvent( QMouseEvent* event )
{
if( m_mouseMoving )
{
int dy = event->globalY() - m_origMousePos.y();
if( event->modifiers() & Qt::ShiftModifier )
dy = qBound( -4, dy/4, 4 );
if( dy > 1 || dy < -1 )
int dy = event->globalY() - m_lastMousePos.y();
if( dy )
{
model()->setInitValue( model()->value() -
dy / 2 * model()->step<int>() );
float fdy = static_cast<float>(dy);
if( event->modifiers() & Qt::ShiftModifier ) {
fdy = qBound( -4.f, fdy/4.f, 4.f );
}
float floatValNotRounded =
model()->value() + m_remainder - fdy / 2.f * model()->step<int>();
float floatValRounded = roundf( floatValNotRounded );
m_remainder = floatValNotRounded - floatValRounded;
model()->setInitValue( floatValRounded );
emit manualChange();
QCursor::setPos( m_origMousePos );
m_lastMousePos = event->globalPos();
}
}
}
@@ -134,10 +141,7 @@ void LcdSpinBox::mouseReleaseEvent( QMouseEvent* )
if( m_mouseMoving )
{
model()->restoreJournallingState();
QCursor::setPos( m_origMousePos );
QApplication::restoreOverrideCursor();
m_mouseMoving = false;
}
}
@@ -179,5 +183,3 @@ void LcdSpinBox::enterValue()
}
}