From 75cd993b93fc95492b136897b480fb02500c4e42 Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Mon, 17 Mar 2008 08:44:55 +0000 Subject: [PATCH] Fixed sunken borders git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@801 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 4 +- src/core/lmms_style.cpp | 166 +++++++++++++++++++-------------------- src/widgets/combobox.cpp | 15 ++-- 3 files changed, 93 insertions(+), 92 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7be78259b..067cc4ec1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,7 +13,7 @@ * src/core/lmms_style.cpp: * include/lmms_style.h: - Re-added lmmsStyle. I don't know why these files disappeared - - Getting ready to draw pretty borders + - Improve appearance of sunken borders * plugins/sf2_player/sf2_player.cpp: * plugins/sf2_player/sf2_player.h: @@ -24,7 +24,7 @@ the synth due to a file load. * src/widgets/combobox.cpp: - Draw styled border. Don't worry, the style will be improved + Draw styled border. * src/core/fx_mixer.cpp: Improved drawing of LCD Channel numbers. diff --git a/src/core/lmms_style.cpp b/src/core/lmms_style.cpp index c3a1f4634..1f14381ac 100644 --- a/src/core/lmms_style.cpp +++ b/src/core/lmms_style.cpp @@ -11,100 +11,98 @@ void lmmsStyle::drawPrimitive( PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { - QPlastiqueStyle::drawPrimitive( element, option, painter, widget ); - /* - if( element == QStyle::PE_Frame ) { - printf("Frame\n"); + if( element == QStyle::PE_Frame ) + { + const QRect rect = option->rect; - QFrame::Shadow shadow = QFrame::Plain; - if (option->state & State_Sunken) - shadow = QFrame::Sunken; - else if (option->state & State_Raised) - shadow = QFrame::Raised; + QColor black = QColor( 0, 0, 0 ); + QColor shadow = option->palette.shadow().color(); + QColor highlight = option->palette.highlight().color(); - QPen oldPen = painter->pen(); - QBrush border; - QBrush corner; - QBrush innerTopLeft; - QBrush innerBottomRight; + int a100 = 165; + int a75 = a100 * .75; + int a50 = a100 * .6; + int a25 = a100 * .33; - if (shadow != QFrame::Plain && (option->state & QStyle::State_HasFocus)) { - border = option->palette.highlight(); - qBrushSetAlphaF(&border, 0.8); - corner = option->palette.highlight(); - qBrushSetAlphaF(&corner, 0.5); - innerTopLeft = qBrushDark(option->palette.highlight(), 125); - innerBottomRight = option->palette.highlight(); - qBrushSetAlphaF(&innerBottomRight, 0.65); - } else { - border = option->palette.shadow(); - qBrushSetAlphaF(&border, 0.4); - corner = option->palette.shadow(); - qBrushSetAlphaF(&corner, 0.25); - innerTopLeft = option->palette.shadow(); - innerBottomRight = option->palette.highlight(); - if (shadow == QFrame::Sunken) { - qBrushSetAlphaF(&innerTopLeft, 0.23); - qBrushSetAlphaF(&innerBottomRight, 0.075); - } else { - qBrushSetAlphaF(&innerTopLeft, 0.075); - qBrushSetAlphaF(&innerBottomRight, 0.23); - } - } + QLine lines[4]; + QPoint points[4]; - QLine lines[4]; - QPoint points[8]; + // black inside lines + // 50% + black.setAlpha(a100); + painter->setPen(QPen(black, 0)); + lines[0] = QLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, rect.top() + 1); + lines[1] = QLine(rect.left() + 2, rect.bottom() - 1, rect.right() - 2, rect.bottom() - 1); + lines[2] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2); + lines[3] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); + painter->drawLines(lines, 4); - // Opaque corner lines - painter->setPen(QPen(border, 0)); - lines[0] = QLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top()); - lines[1] = QLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom()); - lines[2] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2); - lines[3] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2); - painter->drawLines(lines, 4); + // black inside dots + black.setAlpha(a50); + painter->setPen(QPen(black, 0)); + points[0] = QPoint(rect.left() + 2, rect.top() + 2); + points[1] = QPoint(rect.left() + 2, rect.bottom() - 2); + points[2] = QPoint(rect.right() - 2, rect.top() + 2); + points[3] = QPoint(rect.right() - 2, rect.bottom() - 2); + painter->drawPoints(points, 4); - // Opaque corner dots - points[0] = QPoint(rect.left() + 1, rect.top() + 1); - points[1] = QPoint(rect.left() + 1, rect.bottom() - 1); - points[2] = QPoint(rect.right() - 1, rect.top() + 1); - points[3] = QPoint(rect.right() - 1, rect.bottom() - 1); - painter->drawPoints(points, 4); - // Shaded corner dots - painter->setPen(QPen(corner, 0)); - points[0] = QPoint(rect.left(), rect.top() + 1); - points[1] = QPoint(rect.left(), rect.bottom() - 1); - points[2] = QPoint(rect.left() + 1, rect.top()); - points[3] = QPoint(rect.left() + 1, rect.bottom()); - points[4] = QPoint(rect.right(), rect.top() + 1); - points[5] = QPoint(rect.right(), rect.bottom() - 1); - points[6] = QPoint(rect.right() - 1, rect.top()); - points[7] = QPoint(rect.right() - 1, rect.bottom()); - painter->drawPoints(points, 8); - - // Shadows - if (shadow != QFrame::Plain) { - painter->setPen(QPen(innerTopLeft, 0)); - lines[0] = QLine(rect.left() + 2, rect.top() + 1, rect.right() - 2, rect.top() + 1); - lines[1] = QLine(rect.left() + 1, rect.top() + 2, rect.left() + 1, rect.bottom() - 2); - painter->drawLines(lines, 2); - painter->setPen(QPen(innerBottomRight, 0)); - lines[0] = QLine(rect.left() + 2, rect.bottom() - 1, rect.right() - 2, rect.bottom() - 1); - lines[1] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); - painter->drawLines(lines, 2); - } - - painter->setPen(oldPen); + // outside lines - shadow + // 100% + shadow.setAlpha(a75); + painter->setPen(QPen(shadow, 0)); + lines[0] = QLine(rect.left() + 2, rect.top(), rect.right() - 2, rect.top()); + lines[1] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2); + painter->drawLines(lines, 2); + + // outside corner dots - shadow + // 75% + shadow.setAlpha(a50); + painter->setPen(QPen(shadow, 0)); + points[0] = QPoint(rect.left() + 1, rect.top() + 1); + points[1] = QPoint(rect.right() - 1, rect.top() + 1); + painter->drawPoints(points, 2); + + // outside end dots - shadow + // 50% + shadow.setAlpha(a25); + painter->setPen(QPen(shadow, 0)); + points[0] = QPoint(rect.left() + 1, rect.top()); + points[1] = QPoint(rect.left(), rect.top() + 1); + points[2] = QPoint(rect.right() - 1, rect.top()); + points[3] = QPoint(rect.left(), rect.bottom() - 1); + painter->drawPoints(points, 4); + + // outside lines - highlight + // 100% + highlight.setAlpha(a75); + painter->setPen(QPen(highlight, 0)); + lines[0] = QLine(rect.left() + 2, rect.bottom(), rect.right() - 2, rect.bottom()); + lines[1] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2); + painter->drawLines(lines, 2); + + // outside corner dots - highlight + // 75% + highlight.setAlpha(a50); + painter->setPen(QPen(highlight, 0)); + points[0] = QPoint(rect.left() + 1, rect.bottom() - 1); + points[1] = QPoint(rect.right() - 1, rect.bottom() - 1); + painter->drawPoints(points, 2); + + // outside end dots - highlight + // 50% + highlight.setAlpha(a25); + painter->setPen(QPen(highlight, 0)); + points[0] = QPoint(rect.right() - 1, rect.bottom()); + points[1] = QPoint(rect.right(), rect.bottom() - 1); + points[2] = QPoint(rect.left() + 1, rect.bottom()); + points[3] = QPoint(rect.right(), rect.top() + 1); + painter->drawPoints(points, 4); } - else { + else + { QPlastiqueStyle::drawPrimitive( element, option, painter, widget ); } - // brighter line at bottom/right - p.setPen( QColor( 160, 160, 160 ) ); - p.drawLine( width() - 1, 0, width() - 1, height() - 1 ); - p.drawLine( 0, height() - 1, width() - 1, height() - 1 ); -*/ - } diff --git a/src/widgets/combobox.cpp b/src/widgets/combobox.cpp index f2b140e05..c56315912 100644 --- a/src/widgets/combobox.cpp +++ b/src/widgets/combobox.cpp @@ -165,17 +165,20 @@ void comboBox::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); - for( int x = 1; x < width() - 1; x += s_background->width() ) - { - p.drawPixmap( x, 1, *s_background ); - } + p.fillRect( 2, 2, width()-2, height()-4, *s_background ); + + QColor shadow = palette().shadow().color(); + QColor highlight = palette().highlight().color(); + + shadow.setAlpha(124); + highlight.setAlpha(124); // button-separator - p.setPen( palette().color( QPalette::Normal, QPalette::Dark ) ); + p.setPen( shadow ); p.drawLine( width() - CB_ARROW_BTN_WIDTH - 1, 1, width() - CB_ARROW_BTN_WIDTH - 1, height() - 3 ); - p.setPen( palette().color( QPalette::Normal, QPalette::Mid ) ); + p.setPen( highlight ); p.drawLine( width() - CB_ARROW_BTN_WIDTH, 1, width() - CB_ARROW_BTN_WIDTH, height() - 3 );