From 01ae18d6a74444f11fb7f749fc485be1861d7406 Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Wed, 14 Oct 2009 14:28:37 +0000 Subject: [PATCH] moved dots and float frame rendering to separate methods (for clean-up and to make merging with tab branch easier) svn path=/trunk/KDE/kdebase/workspace/; revision=1035200 --- clients/oxygen/oxygenclient.cpp | 184 ++++++++++++++++++-------------- clients/oxygen/oxygenclient.h | 6 ++ 2 files changed, 108 insertions(+), 82 deletions(-) diff --git a/clients/oxygen/oxygenclient.cpp b/clients/oxygen/oxygenclient.cpp index f307b152d4..89a006f4ee 100644 --- a/clients/oxygen/oxygenclient.cpp +++ b/clients/oxygen/oxygenclient.cpp @@ -658,6 +658,104 @@ namespace Oxygen } + //_______________________________________________________________________ + void OxygenClient::renderFloatFrame( QPainter* painter, const QRect& frame, const QPalette& palette ) const + { + + // shadow and resize handles + if( !isMaximized() ) + { + + if( configuration().frameBorder() >= OxygenConfiguration::BorderTiny ) + { + + helper().drawFloatFrame( + painter, frame, backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ), + !compositingActive(), isActive() && configuration().useOxygenShadows(), + KDecoration::options()->color(ColorTitleBar) + ); + + } else if( drawTitleOutline() ) { + + // for small borders, use a frame that matches the titlebar only + QRect local( frame.topLeft(), QSize( frame.width(), HFRAMESIZE ) ); + helper().drawFloatFrame( + painter, local, backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ), + false, isActive() && configuration().useOxygenShadows(), + KDecoration::options()->color(ColorTitleBar) + ); + + } else { + + // for small borders, use a frame that matches the titlebar only + QRect local( frame.topLeft(), QSize( frame.width(), layoutMetric(LM_TitleHeight) + layoutMetric(LM_TitleEdgeTop) ) ); + helper().drawFloatFrame( + painter, local, backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ), + false, isActive() && configuration().useOxygenShadows(), + KDecoration::options()->color(ColorTitleBar) + ); + } + + } else if( isShade() ) { + + // for shaded maximized windows adjust frame and draw the bottom part of it + helper().drawFloatFrame( + painter, frame.adjusted( -4, 0, 4, 0 ), backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ), + !compositingActive(), isActive(), + KDecoration::options()->color(ColorTitleBar), + TileSet::Bottom + ); + + } + + } + + //____________________________________________________________________________ + void OxygenClient::renderDots( QPainter* painter, const QRect& frame, const QColor& color ) const + { + + if( configuration().frameBorder() >= OxygenConfiguration::BorderTiny ) + { + + + // dimensions + int x,y,w,h; + frame.getRect(&x, &y, &w, &h); + + if( isResizable() && !isShade() && !isMaximized() ) + { + + // Draw right side 3-dots resize handles + qreal cenY = h / 2 + y + 0.5; + qreal posX = w + x - 2.5; + + painter->setPen(Qt::NoPen); + painter->setBrush( color ); + renderDot( painter, QPointF(posX, cenY - 3), 1.8); + renderDot( painter, QPointF(posX, cenY), 1.8); + renderDot( painter, QPointF(posX, cenY + 3), 1.8); + + } + + // Draw bottom-right cornet 3-dots resize handles + if( isResizable() && !isShade() && !configuration().drawSizeGrip() ) + { + + painter->setPen(Qt::NoPen); + painter->setBrush( color ); + + painter->save(); + painter->translate(x + w-9, y + h-9); + renderDot( painter, QPointF(2.5, 6.5), 1.8); + renderDot( painter, QPointF(5.5, 5.5), 1.8); + renderDot( painter, QPointF(6.5, 2.5), 1.8); + painter->restore(); + } + + } + + } + //_________________________________________________________ void OxygenClient::activeChange( void ) { @@ -897,89 +995,11 @@ namespace Oxygen // adjust if there are shadows if( compositingActive() ) frame.adjust(-1,-1, 1, 1); - // shadow and resize handles - if( !isMaximized() ) - { + // float frame + renderFloatFrame( &painter, frame, palette ); - if( configuration().frameBorder() >= OxygenConfiguration::BorderTiny ) - { - - helper().drawFloatFrame( - &painter, frame, backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ), - !compositingActive(), isActive() && configuration().useOxygenShadows(), - KDecoration::options()->color(ColorTitleBar) - ); - - } else if( drawTitleOutline() ) { - - // for small borders, use a frame that matches the titlebar only - QRect local( frame.topLeft(), QSize( frame.width(), HFRAMESIZE ) ); - helper().drawFloatFrame( - &painter, local, backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ), - false, isActive() && configuration().useOxygenShadows(), - KDecoration::options()->color(ColorTitleBar) - ); - - } else { - - // for small borders, use a frame that matches the titlebar only - QRect local( frame.topLeft(), QSize( frame.width(), layoutMetric(LM_TitleHeight) + layoutMetric(LM_TitleEdgeTop) ) ); - helper().drawFloatFrame( - &painter, local, backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ), - false, isActive() && configuration().useOxygenShadows(), - KDecoration::options()->color(ColorTitleBar) - ); - } - - } else if( isShade() ) { - - // for shaded maximized windows adjust frame and draw the bottom part of it - helper().drawFloatFrame( - &painter, frame.adjusted( -4, 0, 4, 0 ), backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ), - !compositingActive(), isActive(), - KDecoration::options()->color(ColorTitleBar), - TileSet::Bottom - ); - - } - - if( configuration().frameBorder() >= OxygenConfiguration::BorderTiny ) - { - - - // dimensions - int x,y,w,h; - frame.getRect(&x, &y, &w, &h); - - if( isResizable() && !isShade() && !isMaximized() ) - { - - // Draw right side 3-dots resize handles - qreal cenY = h / 2 + y + 0.5; - qreal posX = w + x - 2.5; - - painter.setPen(Qt::NoPen); - painter.setBrush(QColor(0, 0, 0, 66)); - renderDot(&painter, QPointF(posX, cenY - 3), 1.8); - renderDot(&painter, QPointF(posX, cenY), 1.8); - renderDot(&painter, QPointF(posX, cenY + 3), 1.8); - - } - - // Draw bottom-right cornet 3-dots resize handles - if( isResizable() && !isShade() && !configuration().drawSizeGrip() ) - { - - painter.setPen(Qt::NoPen); - painter.setBrush(QColor(0, 0, 0, 66)); - - painter.translate(x + w-9, y + h-9); - renderDot(&painter, QPointF(2.5, 6.5), 1.8); - renderDot(&painter, QPointF(5.5, 5.5), 1.8); - renderDot(&painter, QPointF(6.5, 2.5), 1.8); - } - - } + //! dots + renderDots( &painter, frame, QColor(0, 0, 0, 66)); } diff --git a/clients/oxygen/oxygenclient.h b/clients/oxygen/oxygenclient.h index ea27bbdba3..2311753407 100644 --- a/clients/oxygen/oxygenclient.h +++ b/clients/oxygen/oxygenclient.h @@ -156,6 +156,12 @@ namespace Oxygen //! title text virtual void renderTitleText( QPainter*, const QRect&, Qt::Alignment, QColor ) const; + //! render float frame + virtual void renderFloatFrame( QPainter*, const QRect&, const QPalette& ) const; + + //! render dots + virtual void renderDots( QPainter*, const QRect&, const QColor& ) const; + //! triggered when window activity is changed virtual void activeChange();