From 286696268e2316d7ddd161072ce8ed70371cea9f Mon Sep 17 00:00:00 2001 From: Sandro Giessl Date: Sat, 26 Mar 2005 13:09:52 +0000 Subject: [PATCH] - 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 --- lib/kcommondecoration.cpp | 37 +++++++++++++++++++++++++++++++++++-- lib/kcommondecoration.h | 7 +++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/lib/kcommondecoration.cpp b/lib/kcommondecoration.cpp index 24acacfcde..b4ee7dea24 100644 --- a/lib/kcommondecoration.cpp +++ b/lib/kcommondecoration.cpp @@ -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; diff --git a/lib/kcommondecoration.h b/lib/kcommondecoration.h index 5889abdf99..3a68864989 100644 --- a/lib/kcommondecoration.h +++ b/lib/kcommondecoration.h @@ -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.