1
#ifndef oxygendockseparator_datah
2
#define oxygendockseparator_datah
4
//////////////////////////////////////////////////////////////////////////////
5
// oxygendockseparatordata.h
6
// generic data container for widgetstate hover (mouse-over) animations
9
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
11
// Permission is hereby granted, free of charge, to any person obtaining a copy
12
// of this software and associated documentation files (the "Software"), to
13
// deal in the Software without restriction, including without limitation the
14
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15
// sell copies of the Software, and to permit persons to whom the Software is
16
// furnished to do so, subject to the following conditions:
18
// The above copyright notice and this permission notice shall be included in
19
// all copies or substantial portions of the Software.
21
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28
//////////////////////////////////////////////////////////////////////////////
30
#include "oxygengenericdata.h"
31
#include "oxygenanimation.h"
36
//! dock widget splitters hover effect
37
class DockSeparatorData: public AnimationData
42
//! declare opacity property
43
Q_PROPERTY( qreal verticalOpacity READ verticalOpacity WRITE setVerticalOpacity )
44
Q_PROPERTY( qreal horizontalOpacity READ horizontalOpacity WRITE setHorizontalOpacity )
49
DockSeparatorData( QObject* parent, QWidget* target, int duration );
52
virtual ~DockSeparatorData( void )
58
returns true if hover has Changed
59
and starts timer accordingly
61
virtual void updateRect( const QRect&, const Qt::Orientation&, bool hovered );
63
//! returns true if current splitter is animated
64
virtual bool isAnimated( QRect r, const Qt::Orientation& orientation ) const
65
{ return orientation == Qt::Vertical ? _verticalData.isAnimated( r ):_horizontalData.isAnimated( r ); }
67
//! opacity for given orientation
68
qreal opacity( const Qt::Orientation& orientation ) const
69
{ return orientation == Qt::Vertical ? verticalOpacity():horizontalOpacity(); }
72
virtual void setDuration( int duration )
74
horizontalAnimation().data()->setDuration( duration );
75
verticalAnimation().data()->setDuration( duration );
78
//!@name horizontal splitter data
81
Animation::Pointer horizontalAnimation( void ) const
82
{ return _horizontalData._animation; }
84
const QRect& horizontalRect( void ) const
85
{ return _horizontalData._rect; }
87
void setHorizontalRect( const QRect& r )
88
{ _horizontalData._rect = r; }
90
qreal horizontalOpacity( void ) const
91
{ return _horizontalData._opacity; }
93
void setHorizontalOpacity( qreal value )
96
value = digitize( value );
97
if( _horizontalData._opacity == value ) return;
98
_horizontalData._opacity = value;
99
if( target() && !horizontalRect().isEmpty() ) target().data()->update( horizontalRect() );
106
//!@name vertical splitter data
109
Animation::Pointer verticalAnimation( void ) const
110
{ return _verticalData._animation; }
112
const QRect& verticalRect( void ) const
113
{ return _verticalData._rect; }
115
void setVerticalRect( const QRect& r )
116
{ _verticalData._rect = r; }
118
qreal verticalOpacity( void ) const
119
{ return _verticalData._opacity; }
121
void setVerticalOpacity( qreal value )
123
value = digitize( value );
124
if( _verticalData._opacity == value ) return;
125
_verticalData._opacity = value;
126
if( target() && !verticalRect().isEmpty() ) target().data()->update( verticalRect() );
134
//! stores data needed for animation
142
_opacity( AnimationData::OpacityInvalid )
145
//! true if is animated
146
bool isAnimated( QRect r ) const
147
{ return r == _rect && _animation.data()->isRunning(); }
149
//! animation pointer
150
Animation::Pointer _animation;
155
//! stores active separator rect
161
Data _horizontalData;