- add LM_ButtonMarginTop for more control on how to position buttons.

- don't make layoutMetric() abstract, instead implement it with sane defaults
  and let decorations fall back to it in case they can't handle a LayoutMetric
  case...

svn path=/trunk/kdebase/kwin/; revision=400745
This commit is contained in:
Sandro Giessl 2005-03-26 13:09:52 +00:00
parent 9ecf800caf
commit 286696268e
2 changed files with 40 additions and 4 deletions

View file

@ -72,6 +72,40 @@ bool KCommonDecoration::decorationBehaviour(DecorationBehaviour behaviour) const
return false;
}
int KCommonDecoration::layoutMetric(LayoutMetric lm, bool, const KCommonDecorationButton *) const
{
switch (lm) {
case LM_BorderLeft:
case LM_BorderRight:
case LM_BorderBottom:
case LM_TitleEdgeTop:
case LM_TitleEdgeBottom:
case LM_TitleEdgeLeft:
case LM_TitleEdgeRight:
case LM_TitleBorderLeft:
case LM_TitleBorderRight:
return 5;
case LM_ButtonWidth:
case LM_ButtonHeight:
case LM_TitleHeight:
return 20;
case LM_ButtonSpacing:
return 5;
case LM_ButtonMarginTop:
return 0;
case LM_ExplicitButtonSpacer:
return 5;
default:
return 0;
}
}
void KCommonDecoration::init()
{
createMainWidget(WNoAutoErase);
@ -155,9 +189,9 @@ void KCommonDecoration::updateLayout() const
}
// layout buttons
int y = r_y + layoutMetric(LM_TitleEdgeTop) + layoutMetric(LM_ButtonMarginTop);
if (m_buttonsLeft.count() > 0) {
const int buttonSpacing = layoutMetric(LM_ButtonSpacing);
int y = r_y + layoutMetric(LM_TitleEdgeTop);
int x = r_x + layoutMetric(LM_TitleEdgeLeft);
for (ButtonContainer::const_iterator it = m_buttonsLeft.begin(); it != m_buttonsLeft.end(); ++it) {
bool elementLayouted = false;
@ -180,7 +214,6 @@ void KCommonDecoration::updateLayout() const
const int titleEdgeRightLeft = r_x2-layoutMetric(LM_TitleEdgeRight)+1;
const int buttonSpacing = layoutMetric(LM_ButtonSpacing);
int y = r_y + layoutMetric(LM_TitleEdgeTop);
int x = titleEdgeRightLeft - buttonContainerWidth(m_buttonsRight);
for (ButtonContainer::const_iterator it = m_buttonsRight.begin(); it != m_buttonsRight.end(); ++it) {
bool elementLayouted = false;

View file

@ -85,6 +85,8 @@ class KWIN_EXPORT KCommonDecoration : public KDecoration
*
* Title:
* ___________________________________________________________________________________
* | LM_ButtonMarginTop | | LM_ButtonMarginTop |
* |________________________________| |_________________________________|
* | [Buttons] | LM_TitleBorderLeft | LM_TitleHeight | LM_TitleBorderRight | [Buttons] |
* |___________|____________________|________________|_____________________|___________|
*
@ -110,7 +112,8 @@ class KWIN_EXPORT KCommonDecoration : public KDecoration
LM_ButtonWidth,
LM_ButtonHeight,
LM_ButtonSpacing,
LM_ExplicitButtonSpacer
LM_ExplicitButtonSpacer,
LM_ButtonMarginTop
};
enum DecorationBehaviour
@ -158,7 +161,7 @@ class KWIN_EXPORT KCommonDecoration : public KDecoration
* @param respectWindowState Whether window states should be taken into account or a "default" state should be assumed.
* @param button For LM_ButtonWidth and LM_ButtonHeight, the button.
*/
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton *button = 0) const = 0;
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton *button = 0) const;
/**
* Create a new title bar button. KCommonDecoration takes care of memory management.