Add hover effect to win deco buttons
svn path=/trunk/KDE/kdebase/workspace/; revision=727100
This commit is contained in:
parent
138428a2be
commit
0e65033534
5 changed files with 29 additions and 58 deletions
|
@ -5,7 +5,6 @@ set(kwin_oxy_SRCS
|
||||||
oxygenclient.cpp
|
oxygenclient.cpp
|
||||||
oxygenbutton.cpp
|
oxygenbutton.cpp
|
||||||
oxygen.cpp
|
oxygen.cpp
|
||||||
definitions.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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 <ruphy@fsfe.org>
|
|
||||||
//
|
|
||||||
// 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
|
|
|
@ -33,7 +33,11 @@ namespace Oxygen
|
||||||
{
|
{
|
||||||
// OxygenFactory /////////////////////////////////////////////////////////////
|
// 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 {
|
enum ButtonType {
|
||||||
ButtonHelp=0,
|
ButtonHelp=0,
|
||||||
|
|
|
@ -32,11 +32,12 @@
|
||||||
#include <kdecoration.h>
|
#include <kdecoration.h>
|
||||||
#include <kglobal.h>
|
#include <kglobal.h>
|
||||||
#include <KColorUtils>
|
#include <KColorUtils>
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <KColorScheme>
|
||||||
|
|
||||||
#include "oxygenclient.h"
|
#include "oxygenclient.h"
|
||||||
#include "oxygenbutton.h"
|
#include "oxygenbutton.h"
|
||||||
#include "oxygen.h"
|
#include "oxygen.h"
|
||||||
#include "definitions.cpp"
|
|
||||||
|
|
||||||
namespace Oxygen
|
namespace Oxygen
|
||||||
{
|
{
|
||||||
|
@ -114,11 +115,11 @@ QSize OxygenButton::sizeHint() const
|
||||||
|
|
||||||
void OxygenButton::enterEvent(QEvent *e)
|
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) {
|
if (status_ != Oxygen::Pressed) {
|
||||||
status_ = Oxygen::Hovered;
|
status_ = Oxygen::Hovered;
|
||||||
}
|
}
|
||||||
QAbstractButton::enterEvent(e);
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -128,9 +129,10 @@ void OxygenButton::enterEvent(QEvent *e)
|
||||||
|
|
||||||
void OxygenButton::leaveEvent(QEvent *e)
|
void OxygenButton::leaveEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
|
KCommonDecorationButton::leaveEvent(e);
|
||||||
// if we wanted to do mouseovers, we would keep track of it here
|
// if we wanted to do mouseovers, we would keep track of it here
|
||||||
status_ = Oxygen::Normal;
|
status_ = Oxygen::Normal;
|
||||||
QAbstractButton::leaveEvent(e);
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -170,14 +172,28 @@ void OxygenButton::paintEvent(QPaintEvent *)
|
||||||
pal.setCurrentColorGroup(QPalette::Inactive);
|
pal.setCurrentColorGroup(QPalette::Inactive);
|
||||||
|
|
||||||
if(client_.maximizeMode() == OxygenClient::MaximizeRestore)
|
if(client_.maximizeMode() == OxygenClient::MaximizeRestore)
|
||||||
painter.translate(0,-2);
|
painter.translate(0,-1);
|
||||||
|
|
||||||
QColor bg = helper_.backgroundTopColor(pal.window());
|
QColor bg = helper_.backgroundTopColor(pal.window());
|
||||||
|
|
||||||
|
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.drawPixmap(0, 0, helper_.windecoButton(pal.button()));
|
||||||
|
|
||||||
painter.setRenderHints(QPainter::Antialiasing);
|
painter.setRenderHints(QPainter::Antialiasing);
|
||||||
painter.setBrush(Qt::NoBrush);
|
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));
|
painter.setPen(QPen(lg, 2.2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||||
switch(type_)
|
switch(type_)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,22 +42,9 @@
|
||||||
#include "oxygenbutton.h"
|
#include "oxygenbutton.h"
|
||||||
#include "oxygen.h"
|
#include "oxygen.h"
|
||||||
|
|
||||||
#include "definitions.cpp"
|
|
||||||
|
|
||||||
namespace Oxygen
|
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"))
|
K_GLOBAL_STATIC_WITH_ARGS(OxygenHelper, globalHelper, ("OxygenDeco"))
|
||||||
|
|
||||||
void renderDot(QPainter *p, const QPointF &point, qreal diameter)
|
void renderDot(QPainter *p, const QPointF &point, qreal diameter)
|
||||||
|
@ -314,7 +301,7 @@ void OxygenClient::paintEvent(QPaintEvent *e)
|
||||||
// draw title text
|
// draw title text
|
||||||
painter.setFont(options()->font(isActive(), false));
|
painter.setFont(options()->font(isActive(), false));
|
||||||
painter.setPen(titlebarTextColor(palette));
|
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());
|
OxygenFactory::titleAlign() | Qt::AlignVCenter, caption());
|
||||||
|
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
Loading…
Reference in a new issue