~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kstyles/oxygen/animations/oxygentabbardata.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef oxygentabbar_datah
 
2
#define oxygentabbar_datah
 
3
 
 
4
//////////////////////////////////////////////////////////////////////////////
 
5
// oxygentabbardata.h
 
6
// data container for QTabBar animations
 
7
// -------------------
 
8
//
 
9
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
 
10
//
 
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:
 
17
//
 
18
// The above copyright notice and this permission notice shall be included in
 
19
// all copies or substantial portions of the Software.
 
20
//
 
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
 
27
// IN THE SOFTWARE.
 
28
//////////////////////////////////////////////////////////////////////////////
 
29
 
 
30
#include "oxygenanimationdata.h"
 
31
 
 
32
#include <QtGui/QTabBar>
 
33
 
 
34
namespace Oxygen
 
35
{
 
36
 
 
37
    //! tabbars
 
38
    class TabBarData: public AnimationData
 
39
    {
 
40
 
 
41
        Q_OBJECT
 
42
 
 
43
        //! declare opacity property
 
44
        Q_PROPERTY( qreal currentOpacity READ currentOpacity WRITE setCurrentOpacity )
 
45
        Q_PROPERTY( qreal previousOpacity READ previousOpacity WRITE setPreviousOpacity )
 
46
 
 
47
        public:
 
48
 
 
49
        //! constructor
 
50
        TabBarData( QObject* parent, QWidget* target, int duration );
 
51
 
 
52
        //! destructor
 
53
        virtual ~TabBarData( void )
 
54
        {}
 
55
 
 
56
        //! duration
 
57
        void setDuration( int duration )
 
58
        {
 
59
            currentIndexAnimation().data()->setDuration( duration );
 
60
            previousIndexAnimation().data()->setDuration( duration );
 
61
        }
 
62
 
 
63
        //! update state
 
64
        bool updateState( const QPoint&, bool );
 
65
 
 
66
        //!@name current index handling
 
67
        //@{
 
68
 
 
69
        //! current opacity
 
70
        virtual qreal currentOpacity( void ) const
 
71
        { return _current._opacity; }
 
72
 
 
73
        //! current opacity
 
74
        virtual void setCurrentOpacity( qreal value )
 
75
        {
 
76
            if( _current._opacity == value ) return;
 
77
            _current._opacity = value;
 
78
            setDirty();
 
79
        }
 
80
 
 
81
        //! current index
 
82
        virtual int currentIndex( void ) const
 
83
        { return _current._index; }
 
84
 
 
85
        //! current index
 
86
        virtual void setCurrentIndex( int index )
 
87
        { _current._index = index; }
 
88
 
 
89
        //! current index animation
 
90
        virtual const Animation::Pointer& currentIndexAnimation( void ) const
 
91
        { return _current._animation; }
 
92
 
 
93
        //@}
 
94
 
 
95
        //!@name previous index handling
 
96
        //@{
 
97
 
 
98
        //! previous opacity
 
99
        virtual qreal previousOpacity( void ) const
 
100
        { return _previous._opacity; }
 
101
 
 
102
        //! previous opacity
 
103
        virtual void setPreviousOpacity( qreal value )
 
104
        {
 
105
            if( _previous._opacity == value ) return;
 
106
            _previous._opacity = value;
 
107
            setDirty();
 
108
        }
 
109
 
 
110
        //! previous index
 
111
        virtual int previousIndex( void ) const
 
112
        { return _previous._index; }
 
113
 
 
114
        //! previous index
 
115
        virtual void setPreviousIndex( int index )
 
116
        { _previous._index = index; }
 
117
 
 
118
        //! previous index Animation
 
119
        virtual const Animation::Pointer& previousIndexAnimation( void ) const
 
120
        { return _previous._animation; }
 
121
 
 
122
        //@}
 
123
 
 
124
        //! return Animation associated to action at given position, if any
 
125
        virtual Animation::Pointer animation( const QPoint& position ) const;
 
126
 
 
127
        //! return opacity associated to action at given position, if any
 
128
        virtual qreal opacity( const QPoint& position ) const;
 
129
 
 
130
        private:
 
131
 
 
132
        //! container for needed animation data
 
133
        class Data
 
134
        {
 
135
            public:
 
136
 
 
137
            //! default constructor
 
138
            Data( void ):
 
139
                _opacity(0),
 
140
                _index(-1)
 
141
            {}
 
142
 
 
143
            Animation::Pointer _animation;
 
144
            qreal _opacity;
 
145
            int _index;
 
146
        };
 
147
 
 
148
        //! current tab animation data (for hover enter animations)
 
149
        Data _current;
 
150
 
 
151
        //! previous tab animations data (for hover leave animations)
 
152
        Data _previous;
 
153
 
 
154
    };
 
155
 
 
156
}
 
157
 
 
158
#endif