Commit dc0cc9a7 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 keyboard input in the case of multiple stops with the same values.
parent 58710c28
......@@ -337,6 +337,7 @@ void GradientWidget::mouseDoubleClickEvent( QMouseEvent *evt )
void GradientWidget::mousePressEvent( QMouseEvent *evt )
{
m_SelectedStop = m_BelowCursor;
m_SelectedStopRight = m_BelowCursorRight;
m_PreviousMouseX = evt->x();
update();
}
......@@ -346,12 +347,12 @@ void GradientWidget::mouseMoveEvent( QMouseEvent *evt )
{
if( (evt->buttons() & Qt::LeftButton) && m_SelectedStop >= 0 )
{
if( m_BelowCursorRight != m_BelowCursor )
if( m_SelectedStopRight != m_SelectedStop )
{
if( evt->x()-m_PreviousMouseX > 0 )
m_SelectedStop = m_BelowCursor = m_BelowCursorRight;
m_SelectedStop = m_SelectedStopRight;
else
m_BelowCursorRight = m_BelowCursor;
m_SelectedStopRight = m_SelectedStop;
}
float value = clampValueToStopInterval( m_SelectedStop, float(evt->x()) / (width()-1) );
......@@ -457,9 +458,19 @@ void GradientWidget::keyPressEvent( QKeyEvent *evt )
if( m_KeyboardInputValue.isEmpty() )
break;
float value = clampValueToStopInterval( m_SelectedStop, m_KeyboardInputValue.toFloat() );
float value = m_KeyboardInputValue.toFloat();
m_KeyboardInputValue = QString();
if( m_SelectedStop != m_SelectedStopRight )
{
if( value > m_Stops[m_SelectedStop].value() )
m_SelectedStop = m_SelectedStopRight;
else
m_SelectedStopRight = m_SelectedStop;
}
value = clampValueToStopInterval( m_SelectedStop, value );
if( value != m_Stops[m_SelectedStop].value() )
{
m_Stops[m_SelectedStop].setValue( value );
......
......@@ -41,6 +41,7 @@ public:
private:
QVector< Stop > m_Stops;
int m_SelectedStop;
int m_SelectedStopRight;
int m_BelowCursor;
int m_BelowCursorRight;
int m_PreviousMouseX;
......
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