From 0e65033534eea3b3b9e31d84def5f497ca903933 Mon Sep 17 00:00:00 2001 From: Casper Boemann Date: Fri, 19 Oct 2007 19:56:50 +0000 Subject: [PATCH] Add hover effect to win deco buttons svn path=/trunk/KDE/kdebase/workspace/; revision=727100 --- clients/oxygen/CMakeLists.txt | 1 - clients/oxygen/definitions.cpp | 35 --------------------------------- clients/oxygen/oxygen.h | 6 +++++- clients/oxygen/oxygenbutton.cpp | 30 +++++++++++++++++++++------- clients/oxygen/oxygenclient.cpp | 15 +------------- 5 files changed, 29 insertions(+), 58 deletions(-) delete mode 100644 clients/oxygen/definitions.cpp diff --git a/clients/oxygen/CMakeLists.txt b/clients/oxygen/CMakeLists.txt index 7acf5b36d8..06d9bf7e85 100644 --- a/clients/oxygen/CMakeLists.txt +++ b/clients/oxygen/CMakeLists.txt @@ -5,7 +5,6 @@ set(kwin_oxy_SRCS oxygenclient.cpp oxygenbutton.cpp oxygen.cpp - definitions.cpp ) diff --git a/clients/oxygen/definitions.cpp b/clients/oxygen/definitions.cpp deleted file mode 100644 index f4c130d46b..0000000000 --- a/clients/oxygen/definitions.cpp +++ /dev/null @@ -1,35 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// oxygenbutton.h -// ------------------- -// Oxygen window decoration for KDE. Definitions of some global constants using -// preprocessor directives. -// ------------------- -// Copyright (c) 2006, 2007 Riccardo Iaconelli -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -////////////////////////////////////////////////////////////////////////////// - -#define BUTTONSIZE 18 -#define DECOSIZE 8 -#define TITLESIZE 18 -#define TFRAMESIZE 4 -#define BFRAMESIZE 4 -#define LFRAMESIZE 4 -#define RFRAMESIZE 4 -#define FRAMEBUTTONSPACE 67 diff --git a/clients/oxygen/oxygen.h b/clients/oxygen/oxygen.h index 4fc51da206..f62314f1d9 100644 --- a/clients/oxygen/oxygen.h +++ b/clients/oxygen/oxygen.h @@ -33,7 +33,11 @@ namespace Oxygen { // OxygenFactory ///////////////////////////////////////////////////////////// -static const int OXYGEN_BUTTONSIZE = 21; +static const int OXYGEN_BUTTONSIZE = 22; +#define TFRAMESIZE 3 +#define BFRAMESIZE 4 +#define LFRAMESIZE 4 +#define RFRAMESIZE 4 enum ButtonType { ButtonHelp=0, diff --git a/clients/oxygen/oxygenbutton.cpp b/clients/oxygen/oxygenbutton.cpp index a980cef0b6..c7c05b1451 100644 --- a/clients/oxygen/oxygenbutton.cpp +++ b/clients/oxygen/oxygenbutton.cpp @@ -32,11 +32,12 @@ #include #include #include +#include +#include #include "oxygenclient.h" #include "oxygenbutton.h" #include "oxygen.h" -#include "definitions.cpp" namespace Oxygen { @@ -114,11 +115,11 @@ QSize OxygenButton::sizeHint() const void OxygenButton::enterEvent(QEvent *e) { - // if we wanted to do mouseovers, we would keep track of it here + KCommonDecorationButton::enterEvent(e); if (status_ != Oxygen::Pressed) { status_ = Oxygen::Hovered; } - QAbstractButton::enterEvent(e); + update(); } ////////////////////////////////////////////////////////////////////////////// @@ -128,9 +129,10 @@ void OxygenButton::enterEvent(QEvent *e) void OxygenButton::leaveEvent(QEvent *e) { + KCommonDecorationButton::leaveEvent(e); // if we wanted to do mouseovers, we would keep track of it here status_ = Oxygen::Normal; - QAbstractButton::leaveEvent(e); + update(); } ////////////////////////////////////////////////////////////////////////////// @@ -170,14 +172,28 @@ void OxygenButton::paintEvent(QPaintEvent *) pal.setCurrentColorGroup(QPalette::Inactive); if(client_.maximizeMode() == OxygenClient::MaximizeRestore) - painter.translate(0,-2); + painter.translate(0,-1); QColor bg = helper_.backgroundTopColor(pal.window()); - painter.drawPixmap(0, 0, helper_.windecoButton(pal.button())); + + QLinearGradient lg = helper_.decoGradient(QRect(4,4,13,13), buttonDetailColor(pal)); + + if(status_ == Oxygen::Hovered) { + if(type_ == ButtonClose) { + QColor color = KColorScheme(pal.currentColorGroup()).foreground(KColorScheme::NegativeText).color(); + lg = helper_.decoGradient(QRect(4,4,13,13), color); + painter.drawPixmap(0, 0, helper_.windecoButtonFocused(pal.button(), color,7)); + } + else{ + QColor color = KColorScheme(pal.currentColorGroup()).decoration(KColorScheme::HoverColor).color(); + painter.drawPixmap(0, 0, helper_.windecoButtonFocused(pal.button(), color, 7)); + } + } + else + painter.drawPixmap(0, 0, helper_.windecoButton(pal.button())); painter.setRenderHints(QPainter::Antialiasing); painter.setBrush(Qt::NoBrush); - QLinearGradient lg = helper_.decoGradient(QRect(4,4,13,13), buttonDetailColor(pal)); painter.setPen(QPen(lg, 2.2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); switch(type_) { diff --git a/clients/oxygen/oxygenclient.cpp b/clients/oxygen/oxygenclient.cpp index 268e16c40a..eae5091e6e 100644 --- a/clients/oxygen/oxygenclient.cpp +++ b/clients/oxygen/oxygenclient.cpp @@ -42,22 +42,9 @@ #include "oxygenbutton.h" #include "oxygen.h" -#include "definitions.cpp" - namespace Oxygen { -// global constants - -// static const int BUTTONSIZE = 18; -// static const int DECOSIZE = 8; -// static const int TITLESIZE = 18; -// static const int TFRAMESIZE = 8; -// static const int BFRAMESIZE = 7; -// static const int LFRAMESIZE = 8; -// static const int RFRAMESIZE = 7;BUTTONSIZE -// static const int FRAMEBUTTONSPACE = 67; - K_GLOBAL_STATIC_WITH_ARGS(OxygenHelper, globalHelper, ("OxygenDeco")) void renderDot(QPainter *p, const QPointF &point, qreal diameter) @@ -314,7 +301,7 @@ void OxygenClient::paintEvent(QPaintEvent *e) // draw title text painter.setFont(options()->font(isActive(), false)); painter.setPen(titlebarTextColor(palette)); - painter.drawText(titleLeft, titleTop-2, titleWidth, titleHeight, // -2 is to go into top risizearea + painter.drawText(titleLeft, titleTop-1, titleWidth, titleHeight, // -1 is to go into top resizearea OxygenFactory::titleAlign() | Qt::AlignVCenter, caption()); painter.setRenderHint(QPainter::Antialiasing);