1
#ifndef oxygenspinbox_datah
2
#define oxygenspinbox_datah
4
//////////////////////////////////////////////////////////////////////////////
6
// spinbox data container for up/down arrow 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 "oxygenanimationdata.h"
32
#include <QtGui/QStyle>
37
//! handles spinbox arrows hover
38
class SpinBoxData: public AnimationData
43
//! declare opacity property
44
Q_PROPERTY( qreal upArrowOpacity READ upArrowOpacity WRITE setUpArrowOpacity )
45
Q_PROPERTY( qreal downArrowOpacity READ downArrowOpacity WRITE setDownArrowOpacity )
50
SpinBoxData( QObject*, QWidget*, int );
53
virtual ~SpinBoxData( void )
57
virtual bool updateState( QStyle::SubControl subControl, bool value )
59
if( subControl == QStyle::SC_SpinBoxUp ) return _upArrowData.updateState( value );
60
else if( subControl == QStyle::SC_SpinBoxDown ) return _downArrowData.updateState( value );
65
virtual bool isAnimated( QStyle::SubControl subControl ) const
68
( subControl == QStyle::SC_SpinBoxUp && upArrowAnimation().data()->isRunning() ) ||
69
( subControl == QStyle::SC_SpinBoxDown && downArrowAnimation().data()->isRunning() ) );
73
virtual qreal opacity( QStyle::SubControl subControl ) const
75
if( subControl == QStyle::SC_SpinBoxUp ) return upArrowOpacity();
76
else if( subControl == QStyle::SC_SpinBoxDown ) return downArrowOpacity();
77
else return OpacityInvalid;
81
virtual void setDuration( int duration )
83
upArrowAnimation().data()->setDuration( duration );
84
downArrowAnimation().data()->setDuration( duration );
87
//!@name up arrow animation
91
qreal upArrowOpacity( void ) const
92
{ return _upArrowData._opacity; }
95
void setUpArrowOpacity( qreal value )
97
value = digitize( value );
98
if( _upArrowData._opacity == value ) return;
99
_upArrowData._opacity = value;
104
Animation::Pointer upArrowAnimation( void ) const
105
{ return _upArrowData._animation; }
109
//!@name down arrow animation
113
qreal downArrowOpacity( void ) const
114
{ return _downArrowData._opacity; }
117
void setDownArrowOpacity( qreal value )
119
value = digitize( value );
120
if( _downArrowData._opacity == value ) return;
121
_downArrowData._opacity = value;
126
Animation::Pointer downArrowAnimation( void ) const
127
{ return _downArrowData._animation; }
133
//! container for needed animation data
139
//! default constructor
146
bool updateState( bool );
152
Animation::Pointer _animation;