2009-09-15 07:12:54 +00:00
|
|
|
#ifndef oxygenclient_h
|
|
|
|
#define oxygenclient_h
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-08-24 16:14:11 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-09-15 07:12:54 +00:00
|
|
|
// oxygenclient.h
|
2009-08-24 16:14:11 +00:00
|
|
|
// -------------------
|
2009-09-09 00:55:55 +00:00
|
|
|
//
|
2009-08-24 16:14:11 +00:00
|
|
|
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
|
2009-08-25 04:15:13 +00:00
|
|
|
// Copyright (c) 2003, 2004 David Johnson <david@usermode.org>
|
|
|
|
// Copyright (c) 2006, 2007 Riccardo Iaconelli <ruphy@fsfe.org>
|
2009-08-24 16:14:11 +00:00
|
|
|
//
|
|
|
|
// 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
|
2009-09-09 00:55:55 +00:00
|
|
|
// IN THE SOFTWARE.
|
2009-08-24 16:14:11 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
#include <kcommondecoration.h>
|
2009-09-20 07:42:03 +00:00
|
|
|
#include <QtCore/QTimeLine>
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-10-13 01:45:01 +00:00
|
|
|
#include "oxygen.h"
|
2009-09-15 07:12:54 +00:00
|
|
|
#include "oxygenconfiguration.h"
|
2009-08-22 08:24:06 +00:00
|
|
|
#include "lib/helper.h"
|
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
namespace Oxygen
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
class OxygenSizeGrip;
|
|
|
|
class OxygenClient : public KCommonDecorationUnstable
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
Q_OBJECT
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
public:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
//! constructor
|
2009-10-13 01:45:01 +00:00
|
|
|
OxygenClient(KDecorationBridge *b, OxygenFactory *f);
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! destructor
|
2009-09-15 07:12:54 +00:00
|
|
|
virtual ~OxygenClient();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-14 14:37:58 +00:00
|
|
|
//! decoration name
|
2009-08-22 08:24:06 +00:00
|
|
|
virtual QString visibleName() const;
|
2009-10-14 14:37:58 +00:00
|
|
|
|
|
|
|
//! buttons
|
2009-08-22 08:24:06 +00:00
|
|
|
virtual KCommonDecorationButton *createButton(::ButtonType type);
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-18 06:54:42 +00:00
|
|
|
//!@name flags
|
|
|
|
//@{
|
|
|
|
|
2009-10-14 14:37:58 +00:00
|
|
|
//! true if decoration has iquired behavior
|
|
|
|
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! true if window is maximized
|
2009-09-18 06:54:42 +00:00
|
|
|
virtual bool isMaximized( void ) const
|
|
|
|
{ return maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows(); }
|
|
|
|
|
|
|
|
//! return true if timeLine is running
|
|
|
|
bool timeLineIsRunning( void ) const
|
|
|
|
{ return timeLine_.state() == QTimeLine::Running; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-07 17:26:56 +00:00
|
|
|
//! true when separator is to be drawn
|
2009-09-18 01:32:27 +00:00
|
|
|
bool drawSeparator( void ) const
|
|
|
|
{
|
2009-10-15 16:03:30 +00:00
|
|
|
return
|
|
|
|
( timeLineIsRunning() || isActive() ) &&
|
|
|
|
configuration().drawSeparator() &&
|
|
|
|
!configuration().drawTitleOutline();
|
2009-09-18 01:32:27 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-18 06:54:42 +00:00
|
|
|
//@}
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! window shape
|
|
|
|
virtual void updateWindowShape();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! initialization
|
|
|
|
virtual void init();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-10 05:13:25 +00:00
|
|
|
// reset
|
|
|
|
virtual void reset( unsigned long changed );
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! return associated configuration
|
2009-09-18 06:54:42 +00:00
|
|
|
const OxygenConfiguration& configuration( void ) const
|
|
|
|
{ return configuration_; }
|
|
|
|
|
|
|
|
//! return timeLine
|
|
|
|
const QTimeLine& timeLine( void ) const
|
|
|
|
{ return timeLine_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! helper class
|
2009-09-04 04:22:26 +00:00
|
|
|
OxygenHelper& helper( void ) const
|
2009-10-13 01:45:01 +00:00
|
|
|
{ return factory_->helper(); }
|
|
|
|
|
|
|
|
//! helper class
|
|
|
|
OxygenShadowCache& shadowCache( void ) const
|
|
|
|
{ return factory_->shadowCache(); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-18 06:54:42 +00:00
|
|
|
//! return animation opacity
|
|
|
|
qreal opacity( void ) const
|
2009-10-12 07:26:07 +00:00
|
|
|
{
|
2009-10-15 16:03:30 +00:00
|
|
|
int frame( timeLine_.currentFrame() );
|
|
|
|
if( timeLine_.direction() == QTimeLine::Backward ) frame -= timeLine_.startFrame();
|
|
|
|
return qreal( frame )/qreal( timeLine_.endFrame() );
|
2009-10-12 07:26:07 +00:00
|
|
|
}
|
2009-09-18 06:54:42 +00:00
|
|
|
|
2009-10-14 14:37:58 +00:00
|
|
|
//!@name metrics and color definitions
|
|
|
|
//@{
|
|
|
|
|
|
|
|
//! dimensions
|
|
|
|
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
|
|
|
|
|
2009-10-15 16:03:30 +00:00
|
|
|
//! get title bounding rect
|
|
|
|
virtual QRect titleBoundingRect( QPainter* painter, const QString& caption ) const
|
|
|
|
{ return titleBoundingRect( painter, titleRect(), caption ); }
|
2009-10-14 14:37:58 +00:00
|
|
|
|
|
|
|
//! get title bounding rect
|
|
|
|
virtual QRect titleBoundingRect( QPainter*, const QRect&, const QString& ) const;
|
|
|
|
|
2009-09-09 17:00:13 +00:00
|
|
|
//! palette background
|
|
|
|
QPalette backgroundPalette( const QWidget*, QPalette ) const;
|
|
|
|
|
2009-09-26 04:57:27 +00:00
|
|
|
//! background
|
|
|
|
QColor backgroundColor( const QWidget* widget, QPalette palette ) const
|
|
|
|
{ return backgroundColor( widget, palette, isActive() ); }
|
|
|
|
|
|
|
|
//! background
|
|
|
|
QColor backgroundColor( const QWidget*, QPalette, bool ) const;
|
|
|
|
|
2009-10-14 14:37:58 +00:00
|
|
|
//@}
|
|
|
|
|
2009-10-17 06:57:17 +00:00
|
|
|
//!@name status change methods (overloaded from KCommonDecorationUnstable)
|
|
|
|
//@{
|
|
|
|
|
|
|
|
//! triggered when window activity is changed
|
|
|
|
virtual void activeChange();
|
|
|
|
|
|
|
|
//! triggered when maximize state changed
|
|
|
|
virtual void maximizeChange();
|
|
|
|
|
|
|
|
//! triggered when window shade is changed
|
|
|
|
virtual void shadeChange();
|
|
|
|
|
|
|
|
//! triggered when window shade is changed
|
|
|
|
virtual void captionChange();
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
//! reset configuration
|
|
|
|
void resetConfiguration( void );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
//! paint
|
|
|
|
virtual void paintEvent( QPaintEvent* );
|
|
|
|
|
2009-10-14 14:37:58 +00:00
|
|
|
//!@name rendering methods (called in paintEvent)
|
|
|
|
//@{
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! window background
|
|
|
|
virtual void renderWindowBackground( QPainter*, const QRect&, const QWidget*, const QPalette& ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
//! window border
|
|
|
|
// this draws a "blue" border around active window
|
2009-10-15 16:03:30 +00:00
|
|
|
virtual void renderWindowBorder( QPainter*, const QRect&, const QWidget*, const QPalette& ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-18 01:32:27 +00:00
|
|
|
//! separator
|
|
|
|
virtual void renderSeparator( QPainter*, const QRect&, const QWidget*, const QColor& ) const;
|
|
|
|
|
2009-09-04 18:58:40 +00:00
|
|
|
//! title outline
|
|
|
|
virtual void renderTitleOutline( QPainter*, const QRect&, const QPalette& ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-02 02:52:41 +00:00
|
|
|
//! title text
|
2009-10-15 16:03:30 +00:00
|
|
|
virtual void renderTitleText( QPainter*, const QRect&, QColor ) const;
|
|
|
|
|
|
|
|
//! title text
|
|
|
|
virtual void renderTitleText( QPainter*, const QRect&, const QString&, const QColor& ) const;
|
2009-10-02 02:52:41 +00:00
|
|
|
|
2009-10-14 14:28:37 +00:00
|
|
|
//! render float frame
|
|
|
|
virtual void renderFloatFrame( QPainter*, const QRect&, const QPalette& ) const;
|
|
|
|
|
|
|
|
//! render dots
|
|
|
|
virtual void renderDots( QPainter*, const QRect&, const QColor& ) const;
|
|
|
|
|
2009-10-14 14:37:58 +00:00
|
|
|
//@}
|
|
|
|
|
2009-10-02 02:52:41 +00:00
|
|
|
//! title timeline
|
|
|
|
bool titleTimeLineIsRunning( void ) const
|
|
|
|
{ return titleTimeLine_.state() == QTimeLine::Running; }
|
|
|
|
|
|
|
|
//! title opacity
|
|
|
|
qreal titleOpacity( void ) const
|
|
|
|
{ return qreal( titleTimeLine_.currentFrame() )/qreal( titleTimeLine_.endFrame() ); }
|
|
|
|
|
|
|
|
//! old caption if any
|
|
|
|
const QString& oldCaption( void ) const
|
|
|
|
{ return oldCaption_; }
|
|
|
|
|
|
|
|
//! old caption
|
|
|
|
void setOldCaption( const QString& value )
|
|
|
|
{ oldCaption_ = value; }
|
|
|
|
|
2009-09-18 01:32:27 +00:00
|
|
|
//! return true when activity change are animated
|
|
|
|
bool animateActiveChange( void ) const
|
2009-10-07 15:38:18 +00:00
|
|
|
{ return ( configuration().useAnimations() && !isPreview() ); }
|
2009-09-18 01:32:27 +00:00
|
|
|
|
2009-10-02 02:52:41 +00:00
|
|
|
//! return true when activity change are animated
|
|
|
|
bool animateTitleChange( void ) const
|
|
|
|
{
|
2009-10-15 16:03:30 +00:00
|
|
|
return
|
|
|
|
configuration().useAnimations() &&
|
|
|
|
!configuration().drawTitleOutline() &&
|
|
|
|
!isPreview();
|
2009-10-02 02:52:41 +00:00
|
|
|
}
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! calculate mask
|
|
|
|
QRegion calcMask( void ) const;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! text color
|
|
|
|
QColor titlebarTextColor(const QPalette&);
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-18 19:47:53 +00:00
|
|
|
//! text color
|
|
|
|
QColor titlebarTextColor(const QPalette&, bool active);
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//!@name size grip
|
|
|
|
//@{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! create size grip
|
|
|
|
void createSizeGrip( void );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! delete size grip
|
|
|
|
void deleteSizeGrip( void );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// size grip
|
|
|
|
bool hasSizeGrip( void ) const
|
2009-09-14 23:10:19 +00:00
|
|
|
{ return (bool)sizeGrip_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! size grip
|
2009-09-15 07:12:54 +00:00
|
|
|
OxygenSizeGrip& sizeGrip( void ) const
|
2009-09-14 23:10:19 +00:00
|
|
|
{ return *sizeGrip_; }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//@}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-15 16:03:30 +00:00
|
|
|
protected slots:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-15 16:03:30 +00:00
|
|
|
//! update old caption with current
|
|
|
|
void updateOldCaption( void )
|
|
|
|
{ setOldCaption( caption() ); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-15 16:03:30 +00:00
|
|
|
private:
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-13 01:45:01 +00:00
|
|
|
//! factory
|
|
|
|
OxygenFactory* factory_;
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! size grip widget
|
2009-09-15 07:12:54 +00:00
|
|
|
OxygenSizeGrip* sizeGrip_;
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-10-15 16:03:30 +00:00
|
|
|
//! configuration
|
|
|
|
OxygenConfiguration configuration_;
|
|
|
|
|
2009-09-18 01:32:27 +00:00
|
|
|
//! animation timeLine
|
|
|
|
QTimeLine timeLine_;
|
|
|
|
|
2009-10-02 02:52:41 +00:00
|
|
|
//! title animation timeLine
|
|
|
|
QTimeLine titleTimeLine_;
|
|
|
|
|
|
|
|
//! old caption
|
|
|
|
QString oldCaption_;
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//! true when initialized
|
|
|
|
bool initialized_;
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
};
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-14 15:36:08 +00:00
|
|
|
//!@name utility functions
|
|
|
|
//@{
|
|
|
|
|
|
|
|
// dot
|
|
|
|
void renderDot(QPainter*, const QPointF&, qreal );
|
|
|
|
|
|
|
|
// contrast
|
|
|
|
QColor reduceContrast(const QColor&, const QColor&, double t);
|
|
|
|
|
|
|
|
//@}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
} // namespace Oxygen
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
#endif // EXAMPLECLIENT_H
|