Commit 80d8ab03 authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Gradient widget modified so as to manage correctly the displacement of stops...

Gradient widget modified so as to manage correctly the displacement of stops using the mouse in the case of multiple stops with the same values.
parent a8e782f7
......@@ -337,6 +337,7 @@ void GradientWidget::mouseDoubleClickEvent( QMouseEvent *evt )
void GradientWidget::mousePressEvent( QMouseEvent *evt )
{
m_SelectedStop = m_BelowCursor;
m_PreviousMouseX = evt->x();
update();
}
......@@ -345,6 +346,14 @@ void GradientWidget::mouseMoveEvent( QMouseEvent *evt )
{
if( (evt->buttons() & Qt::LeftButton) && m_SelectedStop >= 0 )
{
if( m_BelowCursorRight != m_BelowCursor )
{
if( evt->x()-m_PreviousMouseX > 0 )
m_SelectedStop = m_BelowCursor = m_BelowCursorRight;
else
m_BelowCursorRight = m_BelowCursor;
}
float value = clampValueToStopInterval( m_SelectedStop, float(evt->x()) / (width()-1) );
if( value != m_Stops[m_SelectedStop].value() )
{
......@@ -367,6 +376,14 @@ void GradientWidget::mouseMoveEvent( QMouseEvent *evt )
if( belowCursor != m_BelowCursor )
{
m_BelowCursor = belowCursor;
if( belowCursor >= 0 )
{
m_BelowCursorRight = belowCursor;
while( m_BelowCursorRight<m_Stops.size()-1 && m_Stops[m_BelowCursorRight+1].value() == m_Stops[belowCursor].value() )
++ m_BelowCursorRight;
}
setCursor( belowCursor<0? Qt::ArrowCursor : Qt::PointingHandCursor );
}
}
......
......@@ -42,6 +42,8 @@ private:
QVector< Stop > m_Stops;
int m_SelectedStop;
int m_BelowCursor;
int m_BelowCursorRight;
int m_PreviousMouseX;
QString m_KeyboardInputValue;
int getInterval( float value ) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment