Commit 32f0a810 authored by Frédéric Larue's avatar Frédéric Larue

Disabled mode now managed by the GradientWidget::paintEvent() function.

parent c31ea194
......@@ -88,62 +88,65 @@ void GradientWidget::paintEvent( QPaintEvent *evt )
// Display stop cursors.
for( int i=0; i<m_Stops.size(); ++i )
if( isEnabled() )
{
Stop &s = m_Stops[i];
// Vertical bar.
painter.setPen( QPen(QColor(255,255,255),1.0f) );
painter.setOpacity( 0.25f );
painter.drawLine( s.x() , 3, s.x() , h-4 );
painter.setOpacity( 0.22f );
painter.drawLine( s.x()-1, 3, s.x()-1, h-4 );
painter.drawLine( s.x()+1, 3, s.x()+1, h-4 );
painter.setOpacity( 1.0f );
if( i == m_SelectedStop )
for( int i=0; i<m_Stops.size(); ++i )
{
Stop &s = m_Stops[i];
// Vertical bar.
painter.setPen( QPen(QColor(255,255,255),1.0f) );
painter.setOpacity( 0.25f );
painter.drawLine( s.x() , 3, s.x() , h-4 );
painter.setOpacity( 0.22f );
painter.drawLine( s.x()-1, 3, s.x()-1, h-4 );
painter.drawLine( s.x()+1, 3, s.x()+1, h-4 );
painter.setOpacity( 1.0f );
if( i == m_SelectedStop )
painter.setPen( QPen(color,1.0f) );
else
painter.setPen( QPen(color,1.0f,Qt::DotLine) );
painter.drawLine( s.x(), 3, s.x(), h-4 );
painter.setPen( QPen(color,1.0f) );
else
painter.setPen( QPen(color,1.0f,Qt::DotLine) );
painter.drawLine( s.x(), 3, s.x(), h-4 );
painter.setPen( QPen(color,1.0f) );
// Top arrow head.
if( i == m_SelectedStop )
painter.drawLine( s.x()-3, 0, s.x()+3, 0 );
painter.drawLine( s.x()-2, 1, s.x()+2, 1 );
painter.drawLine( s.x()-1, 2, s.x()+1, 2 );
// Bottom arrow head.
if( i == m_SelectedStop )
painter.drawLine( s.x()-3, h-1, s.x()+3, h-1 );
painter.drawLine( s.x()-2, h-2, s.x()+2, h-2 );
painter.drawLine( s.x()-1, h-3, s.x()+1, h-3 );
}
if( m_SelectedStop >= 0 )
{
QString text = m_KeyboardInputValue.isEmpty()? QString::number(m_Stops[m_SelectedStop].value()) : m_KeyboardInputValue;
QFontMetrics fm( font() );
int textW = fm.width( text );
int textX = m_Stops[m_SelectedStop].x() + 4;
int textY = ((h+fm.height()) >> 1) - fm.descent();
if( textX+textW >= w )
textX -= textW + 7;
painter.setOpacity( 0.5f );
painter.setPen( QPen(QColor(255,255,255),1.0f) );
painter.drawText( textX , textY+1, text );
painter.drawText( textX+1, textY , text );
painter.setOpacity( 0.25f );
painter.drawText( textX , textY-1, text );
painter.drawText( textX-1, textY , text );
painter.setOpacity( 1.0f );
painter.setPen( QPen(color,1.0f) );
painter.drawText( textX, textY, text );
// Top arrow head.
if( i == m_SelectedStop )
painter.drawLine( s.x()-3, 0, s.x()+3, 0 );
painter.drawLine( s.x()-2, 1, s.x()+2, 1 );
painter.drawLine( s.x()-1, 2, s.x()+1, 2 );
// Bottom arrow head.
if( i == m_SelectedStop )
painter.drawLine( s.x()-3, h-1, s.x()+3, h-1 );
painter.drawLine( s.x()-2, h-2, s.x()+2, h-2 );
painter.drawLine( s.x()-1, h-3, s.x()+1, h-3 );
}
if( m_SelectedStop >= 0 )
{
QString text = m_KeyboardInputValue.isEmpty()? QString::number(m_Stops[m_SelectedStop].value()) : m_KeyboardInputValue;
QFontMetrics fm( font() );
int textW = fm.width( text );
int textX = m_Stops[m_SelectedStop].x() + 4;
int textY = ((h+fm.height()) >> 1) - fm.descent();
if( textX+textW >= w )
textX -= textW + 7;
painter.setOpacity( 0.5f );
painter.setPen( QPen(QColor(255,255,255),1.0f) );
painter.drawText( textX , textY+1, text );
painter.drawText( textX+1, textY , text );
painter.setOpacity( 0.25f );
painter.drawText( textX , textY-1, text );
painter.drawText( textX-1, textY , text );
painter.setOpacity( 1.0f );
painter.setPen( QPen(color,1.0f) );
painter.drawText( textX, textY, text );
}
}
painter.end();
......
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