From bd208a7c31236d4f9c2d2ff34c626e960a76fcb4 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Sat, 9 May 2020 09:27:55 +0200 Subject: [PATCH 1/5] Fix #4201: BB editor: adjust cursor position This fixes an offset for cursors whose pointer position varies between different themes. TODO: Offset is not 100% accurate yet. (16, 16) is wrong, but it's good for testing. --- data/themes/default/style.css | 2 ++ include/Track.h | 12 +++++++++++- src/core/Track.cpp | 12 ++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/data/themes/default/style.css b/data/themes/default/style.css index a9af1139fef..e1c99bc92df 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -653,6 +653,8 @@ TrackContentObjectView { qproperty-textColor: #fff; qproperty-textShadowColor: rgba(0,0,0,200); qproperty-gradient: false; /* boolean property, set true to have a gradient */ + qproperty-mouseHotspotX: 16; + qproperty-mouseHotspotY: 16; } /* instrument pattern */ diff --git a/include/Track.h b/include/Track.h index bc9f161a9b3..78540f86e49 100644 --- a/include/Track.h +++ b/include/Track.h @@ -201,6 +201,8 @@ class TrackContentObjectView : public selectableObject, public ModelView Q_PROPERTY( QColor textShadowColor READ textShadowColor WRITE setTextShadowColor ) Q_PROPERTY( QColor BBPatternBackground READ BBPatternBackground WRITE setBBPatternBackground ) Q_PROPERTY( bool gradient READ gradient WRITE setGradient ) + Q_PROPERTY( int mouseHotspotX READ getMouseHotspotX WRITE setMouseHotspotX ) + Q_PROPERTY( int mouseHotspotY READ getMouseHotspotY WRITE setMouseHotspotY ) public: TrackContentObjectView( TrackContentObject * tco, TrackView * tv ); @@ -226,6 +228,8 @@ class TrackContentObjectView : public selectableObject, public ModelView QColor textShadowColor() const; QColor BBPatternBackground() const; bool gradient() const; + int getMouseHotspotX() const { return m_mouseHotspotX; } + int getMouseHotspotY() const { return m_mouseHotspotY; } void setMutedColor( const QColor & c ); void setMutedBackgroundColor( const QColor & c ); void setSelectedColor( const QColor & c ); @@ -233,6 +237,9 @@ class TrackContentObjectView : public selectableObject, public ModelView void setTextShadowColor( const QColor & c ); void setBBPatternBackground( const QColor & c ); void setGradient( const bool & b ); + void setMouseHotspotX(int x) { m_mouseHotspotX = x; } + void setMouseHotspotY(int y) { m_mouseHotspotY = y; } + // access needsUpdate member variable bool needsUpdate(); @@ -302,8 +309,11 @@ protected slots: QColor m_textShadowColor; QColor m_BBPatternBackground; bool m_gradient; + int m_mouseHotspotX; + int m_mouseHotspotY; + bool m_cursorSetYet = false; - bool m_needsUpdate; + bool m_needsUpdate; inline void setInitialMousePos( QPoint pos ) { m_initialMousePos = pos; diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 6a6b0deb133..089041fb4d9 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -257,6 +257,8 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco, m_textShadowColor( 0, 0, 0 ), m_BBPatternBackground( 0, 0, 0 ), m_gradient( true ), + m_mouseHotspotX(0), + m_mouseHotspotY(0), m_needsUpdate( true ) { if( s_textFloat == NULL ) @@ -268,7 +270,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_mouseHotspotX, m_mouseHotspotY ) ); move( 0, 0 ); show(); @@ -317,6 +319,12 @@ TrackContentObjectView::~TrackContentObjectView() */ void TrackContentObjectView::update() { + if( !m_cursorSetYet ) + { + setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotX, m_mouseHotspotY ) ); + m_cursorSetYet = true; + } + if( fixedTCOs() ) { updateLength(); @@ -572,7 +580,7 @@ void TrackContentObjectView::leaveEvent( QEvent * e ) { if( cursor().shape() != Qt::BitmapCursor ) { - setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) ); + setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotX, m_mouseHotspotY ) ); } if( e != NULL ) { From 47ca90c5ec6c51d95ec4d13441bdabc205a0aff0 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Sat, 9 May 2020 11:54:58 +0200 Subject: [PATCH 2/5] TCO view: Use exact finger tip offsets (#4201) --- data/themes/classic/style.css | 3 +++ data/themes/default/style.css | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index 112d8f05cab..40b8ff6fb44 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -618,6 +618,9 @@ TrackContentObjectView { qproperty-textColor: rgb( 255, 255, 255 ); qproperty-textShadowColor: rgb( 0, 0, 0 ); qproperty-gradient: true; /* boolean property, set true to have a gradient */ + /* finger tip offset of cursor */ + qproperty-mouseHotspotX: 3; + qproperty-mouseHotspotY: 3; } /* instrument pattern */ diff --git a/data/themes/default/style.css b/data/themes/default/style.css index e1c99bc92df..9b870d6bf0d 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -653,8 +653,9 @@ TrackContentObjectView { qproperty-textColor: #fff; qproperty-textShadowColor: rgba(0,0,0,200); qproperty-gradient: false; /* boolean property, set true to have a gradient */ - qproperty-mouseHotspotX: 16; - qproperty-mouseHotspotY: 16; + /* finger tip offset of cursor */ + qproperty-mouseHotspotX: 7; + qproperty-mouseHotspotY: 2; } /* instrument pattern */ From fc36f1c270fadc7475e5c491c2607eef75951538 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Sat, 9 May 2020 12:46:08 +0200 Subject: [PATCH 3/5] Fix CI: avoid C++11 in Track.h --- include/Track.h | 2 +- src/core/Track.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/Track.h b/include/Track.h index 78540f86e49..587833b47ff 100644 --- a/include/Track.h +++ b/include/Track.h @@ -311,7 +311,7 @@ protected slots: bool m_gradient; int m_mouseHotspotX; int m_mouseHotspotY; - bool m_cursorSetYet = false; + bool m_cursorSetYet; bool m_needsUpdate; inline void setInitialMousePos( QPoint pos ) diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 089041fb4d9..567b6e66cae 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -257,8 +257,9 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco, m_textShadowColor( 0, 0, 0 ), m_BBPatternBackground( 0, 0, 0 ), m_gradient( true ), - m_mouseHotspotX(0), - m_mouseHotspotY(0), + m_mouseHotspotX( 0 ), + m_mouseHotspotY( 0 ), + m_cursorSetYet( false ), m_needsUpdate( true ) { if( s_textFloat == NULL ) From 47caf3251e836c67ffed3358a8ce932a3b5bc850 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Sat, 16 May 2020 08:11:51 +0200 Subject: [PATCH 4/5] Track.h: Remove unused mouse hotspot getters --- include/Track.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/Track.h b/include/Track.h index 587833b47ff..1c5f2033e34 100644 --- a/include/Track.h +++ b/include/Track.h @@ -201,8 +201,8 @@ class TrackContentObjectView : public selectableObject, public ModelView Q_PROPERTY( QColor textShadowColor READ textShadowColor WRITE setTextShadowColor ) Q_PROPERTY( QColor BBPatternBackground READ BBPatternBackground WRITE setBBPatternBackground ) Q_PROPERTY( bool gradient READ gradient WRITE setGradient ) - Q_PROPERTY( int mouseHotspotX READ getMouseHotspotX WRITE setMouseHotspotX ) - Q_PROPERTY( int mouseHotspotY READ getMouseHotspotY WRITE setMouseHotspotY ) + Q_PROPERTY( int mouseHotspotX WRITE setMouseHotspotX ) + Q_PROPERTY( int mouseHotspotY WRITE setMouseHotspotY ) public: TrackContentObjectView( TrackContentObject * tco, TrackView * tv ); @@ -228,8 +228,6 @@ class TrackContentObjectView : public selectableObject, public ModelView QColor textShadowColor() const; QColor BBPatternBackground() const; bool gradient() const; - int getMouseHotspotX() const { return m_mouseHotspotX; } - int getMouseHotspotY() const { return m_mouseHotspotY; } void setMutedColor( const QColor & c ); void setMutedBackgroundColor( const QColor & c ); void setSelectedColor( const QColor & c ); From 943062a5ffded3e6c06662bc73f97e739a09f899 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Thu, 21 May 2020 20:52:24 +0200 Subject: [PATCH 5/5] mouseHotspotHand: Use QSize instead of 2 variables --- data/themes/classic/style.css | 3 +-- data/themes/default/style.css | 3 +-- include/Track.h | 13 ++++++------- src/core/Track.cpp | 14 +++++++++----- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index 40b8ff6fb44..50a0155c947 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -619,8 +619,7 @@ TrackContentObjectView { qproperty-textShadowColor: rgb( 0, 0, 0 ); qproperty-gradient: true; /* boolean property, set true to have a gradient */ /* finger tip offset of cursor */ - qproperty-mouseHotspotX: 3; - qproperty-mouseHotspotY: 3; + qproperty-mouseHotspotHand: 3px 3px; } /* instrument pattern */ diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 9b870d6bf0d..3ba61f48c09 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -654,8 +654,7 @@ TrackContentObjectView { qproperty-textShadowColor: rgba(0,0,0,200); qproperty-gradient: false; /* boolean property, set true to have a gradient */ /* finger tip offset of cursor */ - qproperty-mouseHotspotX: 7; - qproperty-mouseHotspotY: 2; + qproperty-mouseHotspotHand: 7px 2px; } /* instrument pattern */ diff --git a/include/Track.h b/include/Track.h index 1c5f2033e34..bd1a9f36d71 100644 --- a/include/Track.h +++ b/include/Track.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -201,8 +202,9 @@ class TrackContentObjectView : public selectableObject, public ModelView Q_PROPERTY( QColor textShadowColor READ textShadowColor WRITE setTextShadowColor ) Q_PROPERTY( QColor BBPatternBackground READ BBPatternBackground WRITE setBBPatternBackground ) Q_PROPERTY( bool gradient READ gradient WRITE setGradient ) - Q_PROPERTY( int mouseHotspotX WRITE setMouseHotspotX ) - Q_PROPERTY( int mouseHotspotY WRITE setMouseHotspotY ) + // We have to use a QSize here because using QPoint isn't supported. + // width -> x, height -> y + Q_PROPERTY( QSize mouseHotspotHand WRITE setMouseHotspotHand ) public: TrackContentObjectView( TrackContentObject * tco, TrackView * tv ); @@ -235,9 +237,7 @@ class TrackContentObjectView : public selectableObject, public ModelView void setTextShadowColor( const QColor & c ); void setBBPatternBackground( const QColor & c ); void setGradient( const bool & b ); - void setMouseHotspotX(int x) { m_mouseHotspotX = x; } - void setMouseHotspotY(int y) { m_mouseHotspotY = y; } - + void setMouseHotspotHand(const QSize & s); // access needsUpdate member variable bool needsUpdate(); @@ -307,8 +307,7 @@ protected slots: QColor m_textShadowColor; QColor m_BBPatternBackground; bool m_gradient; - int m_mouseHotspotX; - int m_mouseHotspotY; + QSize m_mouseHotspotHand; // QSize must be used because QPoint isn't supported by property system bool m_cursorSetYet; bool m_needsUpdate; diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 567b6e66cae..3f9e04fe641 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -257,8 +257,7 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco, m_textShadowColor( 0, 0, 0 ), m_BBPatternBackground( 0, 0, 0 ), m_gradient( true ), - m_mouseHotspotX( 0 ), - m_mouseHotspotY( 0 ), + m_mouseHotspotHand( 0, 0 ), m_cursorSetYet( false ), m_needsUpdate( true ) { @@ -271,7 +270,7 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco, setAttribute( Qt::WA_OpaquePaintEvent, true ); setAttribute( Qt::WA_DeleteOnClose, true ); setFocusPolicy( Qt::StrongFocus ); - setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotX, m_mouseHotspotY ) ); + setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) ); move( 0, 0 ); show(); @@ -322,7 +321,7 @@ void TrackContentObjectView::update() { if( !m_cursorSetYet ) { - setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotX, m_mouseHotspotY ) ); + setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) ); m_cursorSetYet = true; } @@ -396,6 +395,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; } @@ -581,7 +585,7 @@ void TrackContentObjectView::leaveEvent( QEvent * e ) { if( cursor().shape() != Qt::BitmapCursor ) { - setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotX, m_mouseHotspotY ) ); + setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotHand.width(), m_mouseHotspotHand.height() ) ); } if( e != NULL ) {