more cleanup. Made sure methods are declared and implemented in the same order (blush)
svn path=/trunk/KDE/kdebase/workspace/; revision=1035206
This commit is contained in:
parent
01ae18d6a7
commit
f898d1193f
2 changed files with 138 additions and 118 deletions
|
@ -148,7 +148,84 @@ namespace Oxygen
|
|||
}
|
||||
}
|
||||
|
||||
//___________________________________________
|
||||
//_________________________________________________________
|
||||
KCommonDecorationButton *OxygenClient::createButton(::ButtonType type)
|
||||
{
|
||||
switch (type) {
|
||||
case MenuButton:
|
||||
return new OxygenButton(*this, i18n("Menu"), ButtonMenu);
|
||||
|
||||
case HelpButton:
|
||||
return new OxygenButton(*this, i18n("Help"), ButtonHelp);
|
||||
|
||||
case MinButton:
|
||||
return new OxygenButton(*this, i18n("Minimize"), ButtonMin);
|
||||
|
||||
case MaxButton:
|
||||
return new OxygenButton(*this, i18n("Maximize"), ButtonMax);
|
||||
|
||||
case CloseButton:
|
||||
return new OxygenButton(*this, i18n("Close"), ButtonClose);
|
||||
|
||||
case AboveButton:
|
||||
return new OxygenButton(*this, i18n("Keep Above Others"), ButtonAbove);
|
||||
|
||||
case BelowButton:
|
||||
return new OxygenButton(*this, i18n("Keep Below Others"), ButtonBelow);
|
||||
|
||||
case OnAllDesktopsButton:
|
||||
return new OxygenButton(*this, i18n("On All Desktops"), ButtonSticky);
|
||||
|
||||
case ShadeButton:
|
||||
return new OxygenButton(*this, i18n("Shade Button"), ButtonShade);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
QColor reduceContrast(const QColor &c0, const QColor &c1, double t)
|
||||
{
|
||||
double s = KColorUtils::contrastRatio(c0, c1);
|
||||
if (s < t)
|
||||
return c1;
|
||||
|
||||
double l = 0.0, h = 1.0;
|
||||
double x = s, a;
|
||||
QColor r = c1;
|
||||
for (int maxiter = 16; maxiter; --maxiter)
|
||||
{
|
||||
|
||||
a = 0.5 * (l + h);
|
||||
r = KColorUtils::mix(c0, c1, a);
|
||||
x = KColorUtils::contrastRatio(c0, r);
|
||||
|
||||
if (fabs(x - t) < 0.01) break;
|
||||
if (x > t) h = a;
|
||||
else l = a;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
QRegion OxygenClient::calcMask( void ) const
|
||||
{
|
||||
|
||||
if( isMaximized() )
|
||||
{ return widget()->rect(); }
|
||||
|
||||
QRect frame( widget()->rect().adjusted(
|
||||
layoutMetric( LM_OuterPaddingLeft ), layoutMetric( LM_OuterPaddingTop ),
|
||||
-layoutMetric( LM_OuterPaddingRight ), -layoutMetric( LM_OuterPaddingBottom ) ) );
|
||||
|
||||
if( configuration().frameBorder() == OxygenConfiguration::BorderNone && !isShade() ) return helper().roundedMask( frame, 1, 1, 1, 0 );
|
||||
else return helper().roundedMask( frame );
|
||||
|
||||
}
|
||||
|
||||
//___________________________________________
|
||||
int OxygenClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const
|
||||
{
|
||||
|
||||
|
@ -267,79 +344,49 @@ namespace Oxygen
|
|||
}
|
||||
|
||||
//_________________________________________________________
|
||||
KCommonDecorationButton *OxygenClient::createButton(::ButtonType type)
|
||||
QRect OxygenClient::titleRect( const QRect& frame ) const
|
||||
{
|
||||
switch (type) {
|
||||
case MenuButton:
|
||||
return new OxygenButton(*this, i18n("Menu"), ButtonMenu);
|
||||
|
||||
case HelpButton:
|
||||
return new OxygenButton(*this, i18n("Help"), ButtonHelp);
|
||||
int extraBorder = ( isMaximized() && compositingActive() ) ? 0 : EXTENDED_HITAREA;
|
||||
|
||||
case MinButton:
|
||||
return new OxygenButton(*this, i18n("Minimize"), ButtonMin);
|
||||
// dimensions
|
||||
const int titleHeight = layoutMetric(LM_TitleHeight);
|
||||
const int titleTop = layoutMetric(LM_TitleEdgeTop) + frame.top() - extraBorder;
|
||||
const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
|
||||
const int marginLeft = layoutMetric(LM_TitleBorderLeft);
|
||||
const int marginRight = layoutMetric(LM_TitleBorderRight);
|
||||
|
||||
case MaxButton:
|
||||
return new OxygenButton(*this, i18n("Maximize"), ButtonMax);
|
||||
const int titleLeft = frame.left() + titleEdgeLeft + buttonsLeftWidth() + marginLeft;
|
||||
const int titleWidth = frame.width() -
|
||||
titleEdgeLeft - layoutMetric(LM_TitleEdgeRight) -
|
||||
buttonsLeftWidth() - buttonsRightWidth() -
|
||||
marginLeft - marginRight;
|
||||
|
||||
case CloseButton:
|
||||
return new OxygenButton(*this, i18n("Close"), ButtonClose);
|
||||
// maximum rect allocated for title
|
||||
return QRect( titleLeft, titleTop-1, titleWidth, titleHeight );
|
||||
|
||||
case AboveButton:
|
||||
return new OxygenButton(*this, i18n("Keep Above Others"), ButtonAbove);
|
||||
|
||||
case BelowButton:
|
||||
return new OxygenButton(*this, i18n("Keep Below Others"), ButtonBelow);
|
||||
|
||||
case OnAllDesktopsButton:
|
||||
return new OxygenButton(*this, i18n("On All Desktops"), ButtonSticky);
|
||||
|
||||
case ShadeButton:
|
||||
return new OxygenButton(*this, i18n("Shade Button"), ButtonShade);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
QColor reduceContrast(const QColor &c0, const QColor &c1, double t)
|
||||
{
|
||||
double s = KColorUtils::contrastRatio(c0, c1);
|
||||
if (s < t)
|
||||
return c1;
|
||||
|
||||
double l = 0.0, h = 1.0;
|
||||
double x = s, a;
|
||||
QColor r = c1;
|
||||
for (int maxiter = 16; maxiter; --maxiter)
|
||||
{
|
||||
|
||||
a = 0.5 * (l + h);
|
||||
r = KColorUtils::mix(c0, c1, a);
|
||||
x = KColorUtils::contrastRatio(c0, r);
|
||||
|
||||
if (fabs(x - t) < 0.01) break;
|
||||
if (x > t) h = a;
|
||||
else l = a;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
QRegion OxygenClient::calcMask( void ) const
|
||||
QRect OxygenClient::titleBoundingRect( QPainter* painter, const QRect& frame, const QString& caption ) const
|
||||
{
|
||||
|
||||
if( isMaximized() )
|
||||
{ return widget()->rect(); }
|
||||
QRect titleRect( OxygenClient::titleRect( frame ) );
|
||||
|
||||
QRect frame( widget()->rect().adjusted(
|
||||
layoutMetric( LM_OuterPaddingLeft ), layoutMetric( LM_OuterPaddingTop ),
|
||||
-layoutMetric( LM_OuterPaddingRight ), -layoutMetric( LM_OuterPaddingBottom ) ) );
|
||||
// get title bounding rect
|
||||
QRect boundingRect = painter->boundingRect( titleRect, configuration().titleAlignment() | Qt::AlignVCenter, caption );
|
||||
|
||||
if( configuration().frameBorder() == OxygenConfiguration::BorderNone && !isShade() ) return helper().roundedMask( frame, 1, 1, 1, 0 );
|
||||
else return helper().roundedMask( frame );
|
||||
// adjust to make sure bounding rect
|
||||
// 1/ has same vertical alignment as original titleRect
|
||||
// 2/ does not exceeds available horizontal space
|
||||
boundingRect.setTop( titleRect.top() );
|
||||
boundingRect.setBottom( titleRect.bottom() );
|
||||
boundingRect.setLeft( qMax( boundingRect.left(), titleRect.left() ) );
|
||||
boundingRect.setRight( qMin( boundingRect.right(), titleRect.right() ) );
|
||||
|
||||
// finally translate one pixel up
|
||||
if( compositingActive() && !isMaximized() ) boundingRect.translate(0, -1 );
|
||||
return boundingRect;
|
||||
|
||||
}
|
||||
|
||||
|
@ -557,53 +604,6 @@ namespace Oxygen
|
|||
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
QRect OxygenClient::titleRect( const QRect& frame ) const
|
||||
{
|
||||
|
||||
int extraBorder = ( isMaximized() && compositingActive() ) ? 0 : EXTENDED_HITAREA;
|
||||
|
||||
// dimensions
|
||||
const int titleHeight = layoutMetric(LM_TitleHeight);
|
||||
const int titleTop = layoutMetric(LM_TitleEdgeTop) + frame.top() - extraBorder;
|
||||
const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
|
||||
const int marginLeft = layoutMetric(LM_TitleBorderLeft);
|
||||
const int marginRight = layoutMetric(LM_TitleBorderRight);
|
||||
|
||||
const int titleLeft = frame.left() + titleEdgeLeft + buttonsLeftWidth() + marginLeft;
|
||||
const int titleWidth = frame.width() -
|
||||
titleEdgeLeft - layoutMetric(LM_TitleEdgeRight) -
|
||||
buttonsLeftWidth() - buttonsRightWidth() -
|
||||
marginLeft - marginRight;
|
||||
|
||||
// maximum rect allocated for title
|
||||
return QRect( titleLeft, titleTop-1, titleWidth, titleHeight );
|
||||
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
QRect OxygenClient::titleBoundingRect( QPainter* painter, const QRect& frame, const QString& caption ) const
|
||||
{
|
||||
|
||||
QRect titleRect( OxygenClient::titleRect( frame ) );
|
||||
|
||||
// get title bounding rect
|
||||
QRect boundingRect = painter->boundingRect( titleRect, configuration().titleAlignment() | Qt::AlignVCenter, caption );
|
||||
|
||||
// adjust to make sure bounding rect
|
||||
// 1/ has same vertical alignment as original titleRect
|
||||
// 2/ does not exceeds available horizontal space
|
||||
boundingRect.setTop( titleRect.top() );
|
||||
boundingRect.setBottom( titleRect.bottom() );
|
||||
boundingRect.setLeft( qMax( boundingRect.left(), titleRect.left() ) );
|
||||
boundingRect.setRight( qMin( boundingRect.right(), titleRect.right() ) );
|
||||
|
||||
// finally translate one pixel up
|
||||
if( compositingActive() && !isMaximized() ) boundingRect.translate(0, -1 );
|
||||
return boundingRect;
|
||||
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void OxygenClient::renderTitleOutline( QPainter* painter, const QRect& rect, const QPalette& palette ) const
|
||||
{
|
||||
|
|
|
@ -54,13 +54,18 @@ namespace Oxygen
|
|||
//! destructor
|
||||
virtual ~OxygenClient();
|
||||
|
||||
//! decoration name
|
||||
virtual QString visibleName() const;
|
||||
|
||||
//! buttons
|
||||
virtual KCommonDecorationButton *createButton(::ButtonType type);
|
||||
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
|
||||
|
||||
//!@name flags
|
||||
//@{
|
||||
|
||||
//! true if decoration has iquired behavior
|
||||
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
|
||||
|
||||
//! true if window is maximized
|
||||
virtual bool isMaximized( void ) const
|
||||
{ return maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows(); }
|
||||
|
@ -88,9 +93,6 @@ namespace Oxygen
|
|||
|
||||
//@}
|
||||
|
||||
//! dimensions
|
||||
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
|
||||
|
||||
//! window shape
|
||||
virtual void updateWindowShape();
|
||||
|
||||
|
@ -124,6 +126,18 @@ namespace Oxygen
|
|||
return qreal( frame )/qreal( timeLine_.endFrame() );
|
||||
}
|
||||
|
||||
//!@name metrics and color definitions
|
||||
//@{
|
||||
|
||||
//! dimensions
|
||||
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
|
||||
|
||||
//! get maximum space available for title
|
||||
virtual QRect titleRect( const QRect& ) const;
|
||||
|
||||
//! get title bounding rect
|
||||
virtual QRect titleBoundingRect( QPainter*, const QRect&, const QString& ) const;
|
||||
|
||||
//! palette background
|
||||
QPalette backgroundPalette( const QWidget*, QPalette ) const;
|
||||
|
||||
|
@ -134,6 +148,11 @@ namespace Oxygen
|
|||
//! background
|
||||
QColor backgroundColor( const QWidget*, QPalette, bool ) const;
|
||||
|
||||
//@}
|
||||
|
||||
//!@name rendering methods (called in paintEvent)
|
||||
//@{
|
||||
|
||||
//! window background
|
||||
virtual void renderWindowBackground( QPainter*, const QRect&, const QWidget*, const QPalette& ) const;
|
||||
|
||||
|
@ -144,12 +163,6 @@ namespace Oxygen
|
|||
//! separator
|
||||
virtual void renderSeparator( QPainter*, const QRect&, const QWidget*, const QColor& ) const;
|
||||
|
||||
//! get maximum space available for title
|
||||
virtual QRect titleRect( const QRect& ) const;
|
||||
|
||||
//! get title bounding rect
|
||||
virtual QRect titleBoundingRect( QPainter*, const QRect&, const QString& ) const;
|
||||
|
||||
//! title outline
|
||||
virtual void renderTitleOutline( QPainter*, const QRect&, const QPalette& ) const;
|
||||
|
||||
|
@ -162,6 +175,11 @@ namespace Oxygen
|
|||
//! render dots
|
||||
virtual void renderDots( QPainter*, const QRect&, const QColor& ) const;
|
||||
|
||||
//@}
|
||||
|
||||
//!@name status change methods (overloaded from KCommonDecorationUnstable)
|
||||
//@{
|
||||
|
||||
//! triggered when window activity is changed
|
||||
virtual void activeChange();
|
||||
|
||||
|
@ -174,6 +192,8 @@ namespace Oxygen
|
|||
//! triggered when window shade is changed
|
||||
virtual void captionChange();
|
||||
|
||||
//@}
|
||||
|
||||
public slots:
|
||||
|
||||
//! reset configuration
|
||||
|
|
Loading…
Reference in a new issue