From 68a5cc9ab02f41ddbec4211be7fcb43026c915dd Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Thu, 29 Jan 2009 14:13:36 +0000 Subject: [PATCH] Improve Cusis scrollbar, fix code style git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1989 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 9 +++++ include/cusis_style.h | 2 + src/gui/cusis_style.cpp | 87 ++++++++++++++++++++++------------------- src/tracks/pattern.cpp | 6 +-- 4 files changed, 60 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9d923b395..73d265b7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-01-28 Paul Giblock + + * src/tracks/pattern.cpp: + Code style + + * src/gui/cusis_style.cpp: + * include/cusis_style.h: + Fix blending aronund scrollbar buttons + 2009-01-28 Paul Giblock * src/gui/embed.cpp: diff --git a/include/cusis_style.h b/include/cusis_style.h index 5eab06d4f..41096aa71 100644 --- a/include/cusis_style.h +++ b/include/cusis_style.h @@ -72,6 +72,8 @@ public: private: QImage colorizeXpm( const char * const * _xpm, const QBrush & _fill ) const; + void hoverColors( bool sunken, bool hover, bool active, + QColor & color, QColor & blend ) const; QColor m_colors[ LmmsStyle::NumColorRoles ]; }; diff --git a/src/gui/cusis_style.cpp b/src/gui/cusis_style.cpp index 82d4634a5..911443faf 100644 --- a/src/gui/cusis_style.cpp +++ b/src/gui/cusis_style.cpp @@ -147,7 +147,7 @@ CusisStyle::CusisStyle() : m_colors[PianoRollDefaultNote] = QColor( 0x99, 0xff, 0x00 ); // or 00 ff 99 m_colors[PianoRollFrozenNote] = QColor( 0x00, 0xE0, 0xFF ); - m_colors[PianoRollMutedNote] = QColor( 160, 160, 160 ); + m_colors[PianoRollMutedNote] = QColor( 0x99, 0x99, 0x99 ); m_colors[PianoRollStepNote] = QColor( 0xff, 0x99, 0x00 ); m_colors[PianoRollSelectedNote] = QColor( 0x00, 0x99, 0xff ); m_colors[PianoRollEditHandle] = QColor( 0xff, 0x99, 0x33 ); @@ -194,6 +194,36 @@ QPalette CusisStyle::standardPalette( void ) const +void CusisStyle::hoverColors( bool sunken, bool hover, bool active, + QColor & color, QColor & blend ) const +{ + if( active ) + { + if( sunken ) + { + color = QColor( 75, 75, 75 ); + blend = QColor( 65, 65, 65 ); + } + else if( hover ) + { + color = QColor( 100, 100, 100 ); + blend = QColor( 75, 75, 75 ); + } + else + { + color = QColor( 21, 21, 21 ); + blend = QColor( 33, 33, 33 ); + } + } + else + { + color = QColor( 21, 21, 21 ); + blend = QColor( 33, 33, 33 ); + } +} + + + void CusisStyle::drawComplexControl( ComplexControl _control, const QStyleOptionComplex * _option, QPainter * _painter, const QWidget * _widget ) const @@ -438,21 +468,12 @@ void CusisStyle::drawControl( ControlElement _element, const QStyleOption * _opt cache = QPixmap( _option->rect.size() ); QPainter cachePainter( &cache ); - cache.fill( QColor( 48, 48, 48 ) ); // TODO: Fill with CSS background - QColor sliderColor = QColor( 21, 21, 21 ); // TODO: option->palette.background() - if( ( scrollBar->activeSubControls & SC_ScrollBarAddLine ) ) - { - if( sunken ) - { - sliderColor = QColor( 75, 75, 75 ); - } - else if( hover ) - { - sliderColor = QColor( 100, 100, 100 ); - } - } - - QColor blurColor = QColor( 33, 33, 33 ); // TODO: Mix colors + cache.fill( QColor( 48, 48, 48 ) ); + QColor sliderColor; + QColor blurColor; + hoverColors(sunken, hover, + scrollBar->activeSubControls & SC_ScrollBarAddLine && isEnabled, + sliderColor, blurColor); int scrollBarExtent = pixelMetric( PM_ScrollBarExtent, _option, _widget ); cachePainter.setPen( QPen( sliderColor, 0 ) ); @@ -526,19 +547,11 @@ void CusisStyle::drawControl( ControlElement _element, const QStyleOption * _opt QPainter cachePainter( &cache ); cache.fill( QColor( 48, 48, 48 ) ); // TODO: Fill with CSS background - QColor sliderColor = QColor( 21, 21, 21 ); // TODO: option->palette.background() - if ((scrollBar->activeSubControls & SC_ScrollBarSubLine)) - { - if( sunken ) - { - sliderColor = QColor( 75, 75, 75 ); - } - else if( hover ) - { - sliderColor = QColor( 100, 100, 100 ); - } - } - QColor blurColor = QColor( 33, 33, 33 ); // TODO: Mix colors + QColor sliderColor; + QColor blurColor; + hoverColors(sunken, hover, + scrollBar->activeSubControls & SC_ScrollBarSubLine && isEnabled, + sliderColor, blurColor); int scrollBarExtent = pixelMetric( PM_ScrollBarExtent, _option, _widget ); cachePainter.setPen( QPen( sliderColor, 0 ) ); @@ -605,18 +618,10 @@ void CusisStyle::drawControl( ControlElement _element, const QStyleOption * _opt bool sunken = scrollBar->state & State_Sunken; bool hover = scrollBar->state & State_MouseOver; - QColor sliderColor = QColor( 21, 21, 21 ); // TODO: option->palette.background() - if ((scrollBar->activeSubControls & SC_ScrollBarSlider)) - { - if( sunken ) - { - sliderColor = QColor( 75, 75, 75 ); - } - else if( hover ) - { - sliderColor = QColor( 100, 100, 100 ); - } - } + QColor sliderColor, blendColor; + hoverColors(sunken, hover, + (scrollBar->activeSubControls & SC_ScrollBarSlider) & isEnabled, + sliderColor, blendColor); QColor background = QColor( 48, 48, 48 ); QRect rc = scrollBar->rect; diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index a8f5061b3..51faee1c5 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -1205,15 +1205,15 @@ void patternView::paintEvent( QPaintEvent * ) if( m_pat->getTrack()->isMuted() || m_pat->isMuted() ) { - p.setPen( lStyle->color(LmmsStyle::PianoRollMutedNote) ); + p.setPen( lStyle->color( LmmsStyle::PianoRollMutedNote ) ); } else if( m_pat->m_frozenPattern != NULL ) { - p.setPen( lStyle->color(LmmsStyle::PianoRollFrozenNote) ); + p.setPen( lStyle->color( LmmsStyle::PianoRollFrozenNote ) ); } else { - p.setPen( lStyle->color(LmmsStyle::PianoRollDefaultNote) ); + p.setPen( lStyle->color( LmmsStyle::PianoRollDefaultNote ) ); } for( noteVector::iterator it =