Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4201: BB editor: adjust cursor position #5489

Merged
merged 5 commits into from
May 24, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Spekular marked this conversation as resolved.
Show resolved Hide resolved
qproperty-mouseHotspotY: 3;
}

/* instrument pattern */
Expand Down
3 changes: 3 additions & 0 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,9 @@ TrackContentObjectView {
qproperty-textColor: #fff;
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;
}

/* instrument pattern */
Expand Down
12 changes: 11 additions & 1 deletion include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -226,13 +228,18 @@ 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; }
JohannesLorenz marked this conversation as resolved.
Show resolved Hide resolved
void setMutedColor( const QColor & c );
void setMutedBackgroundColor( const QColor & c );
void setSelectedColor( const QColor & c );
void setTextColor( const QColor & c );
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();
Expand Down Expand Up @@ -302,8 +309,11 @@ protected slots:
QColor m_textShadowColor;
QColor m_BBPatternBackground;
bool m_gradient;
int m_mouseHotspotX;
int m_mouseHotspotY;
bool m_cursorSetYet;

bool m_needsUpdate;
bool m_needsUpdate;
inline void setInitialMousePos( QPoint pos )
{
m_initialMousePos = pos;
Expand Down
13 changes: 11 additions & 2 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +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_cursorSetYet( false ),
m_needsUpdate( true )
{
if( s_textFloat == NULL )
Expand All @@ -268,7 +271,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();

Expand Down Expand Up @@ -317,6 +320,12 @@ TrackContentObjectView::~TrackContentObjectView()
*/
void TrackContentObjectView::update()
{
if( !m_cursorSetYet )
Spekular marked this conversation as resolved.
Show resolved Hide resolved
{
setCursor( QCursor( embed::getIconPixmap( "hand" ), m_mouseHotspotX, m_mouseHotspotY ) );
m_cursorSetYet = true;
}

if( fixedTCOs() )
{
updateLength();
Expand Down Expand Up @@ -572,7 +581,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 ) );
JohannesLorenz marked this conversation as resolved.
Show resolved Hide resolved
}
if( e != NULL )
{
Expand Down