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

Limit the automation-editor scaled-level tooltip to the grid #4308

Merged
merged 6 commits into from Apr 26, 2018
Merged
Diff settings

Always

Just for now

Copy path View file
@@ -173,6 +173,7 @@ protected slots:

// some constants...
static const int SCROLLBAR_SIZE = 12;
static const int LEFT_MARGIN = 63;

This comment has been minimized.

Copy link
@PhysSong

PhysSong Apr 22, 2018

Member

I guess you can calculate the left margin using VALUES_WIDTH.

This comment has been minimized.

Copy link
@Sawuare

Sawuare Apr 22, 2018

Author Member

As in using VALUES_WIDTH instead of LEFT_MARGIN in drawCross()?

This comment has been minimized.

Copy link
@PhysSong

PhysSong Apr 22, 2018

Member

Yes, though it doesn't need to be simple replacing.

This comment has been minimized.

Copy link
@Sawuare

Sawuare Apr 22, 2018

Author Member

Done in 19b0342.

static const int TOP_MARGIN = 16;

static const int DEFAULT_Y_DELTA = 6;
@@ -1076,23 +1076,36 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent )
inline void AutomationEditor::drawCross( QPainter & p )
{
QPoint mouse_pos = mapFromGlobal( QCursor::pos() );
float level = getLevel( mouse_pos.y() );
int grid_bottom = height() - SCROLLBAR_SIZE - 1;
float level = getLevel( mouse_pos.y() );
float cross_y = m_y_auto ?
grid_bottom - ( ( grid_bottom - TOP_MARGIN )
* ( level - m_minLevel )
/ (float)( m_maxLevel - m_minLevel ) ) :
grid_bottom - ( level - m_bottomLevel ) * m_y_delta;

int right_margin = width() - SCROLLBAR_SIZE;
int bottom_margin = height() - SCROLLBAR_SIZE;

p.setPen( crossColor() );
p.drawLine( VALUES_WIDTH, (int) cross_y, width(), (int) cross_y );
p.drawLine( mouse_pos.x(), TOP_MARGIN, mouse_pos.x(),
height() - SCROLLBAR_SIZE );
p.drawLine( mouse_pos.x(), TOP_MARGIN, mouse_pos.x(), bottom_margin );


QPoint tt_pos = QCursor::pos();
tt_pos.ry() -= 64;
tt_pos.rx() += 32;
tt_pos.ry() -= 51;
tt_pos.rx() += 26;

float scaledLevel = m_pattern->firstObject()->scaledValue( level );
QToolTip::showText( tt_pos, QString::number( scaledLevel ), this );

// Limit the scaled-level tooltip to the grid
if( mouse_pos.x() > LEFT_MARGIN &&

This comment has been minimized.

Copy link
@PhysSong

PhysSong Apr 22, 2018

Member

Why did you put a tab inside parentheses instead of a space?

This comment has been minimized.

Copy link
@Sawuare

Sawuare Apr 22, 2018

Author Member

Mistake. Fixed in d1dfe32.

mouse_pos.x() < right_margin &&
mouse_pos.y() > TOP_MARGIN &&
mouse_pos.y() < bottom_margin )
{
QToolTip::showText( tt_pos, QString::number( scaledLevel ), this );
}
}


ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.