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

« back to all changes in this revision

Viewing changes to kstyles/oxygen/animations/oxygenmenubarengine.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 oxygenmenubarengine_h
 
2
#define oxygenmenubarengine_h
 
3
 
 
4
//////////////////////////////////////////////////////////////////////////////
 
5
// oxygenmenubarengine.h
 
6
// stores event filters and maps widgets to timelines for animations
 
7
// -------------------
 
8
//
 
9
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
 
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 "oxygenbaseengine.h"
 
31
#include "oxygendatamap.h"
 
32
#include "oxygenmenubardata.h"
 
33
 
 
34
namespace Oxygen
 
35
{
 
36
 
 
37
    //! stores menubar hovered action and timeLine
 
38
    class MenuBarBaseEngine: public BaseEngine
 
39
    {
 
40
 
 
41
        Q_OBJECT
 
42
 
 
43
        public:
 
44
 
 
45
        //! constructor
 
46
        MenuBarBaseEngine( QObject* parent ):
 
47
        BaseEngine( parent )
 
48
        {}
 
49
 
 
50
        //! destructor
 
51
        virtual ~MenuBarBaseEngine( void )
 
52
        {}
 
53
 
 
54
        //! register menubar
 
55
        virtual bool registerWidget( QWidget* ) = 0;
 
56
 
 
57
        //! true if widget is animated
 
58
        virtual bool isAnimated( const QObject*, const QPoint& )
 
59
        { return false; }
 
60
 
 
61
        //! animation opacity
 
62
        virtual qreal opacity( const QObject*, const QPoint& )
 
63
        { return -1; }
 
64
 
 
65
        //! return 'hover' rect position when widget is animated
 
66
        virtual QRect currentRect( const QObject*, const QPoint& )
 
67
        { return QRect(); }
 
68
 
 
69
        //! animated rect
 
70
        virtual QRect animatedRect( const QObject* )
 
71
        { return QRect(); }
 
72
 
 
73
        //! timer
 
74
        virtual bool isTimerActive( const QObject* )
 
75
        { return false; }
 
76
 
 
77
        //! enability
 
78
        virtual void setEnabled( bool ) = 0;
 
79
 
 
80
        //! duration
 
81
        virtual void setDuration( int ) = 0;
 
82
 
 
83
        //! duration
 
84
        virtual void setFollowMouseDuration( int )
 
85
        {}
 
86
 
 
87
    };
 
88
 
 
89
    //! fading menubar animation
 
90
    class MenuBarEngineV1: public MenuBarBaseEngine
 
91
    {
 
92
 
 
93
        Q_OBJECT
 
94
 
 
95
        public:
 
96
 
 
97
        //! constructor
 
98
        MenuBarEngineV1( QObject* parent ):
 
99
        MenuBarBaseEngine( parent )
 
100
        {}
 
101
 
 
102
        //! constructor
 
103
        MenuBarEngineV1( QObject* parent, MenuBarBaseEngine* other );
 
104
 
 
105
        //! destructor
 
106
        virtual ~MenuBarEngineV1( void )
 
107
        {}
 
108
 
 
109
        //! register menubar
 
110
        virtual bool registerWidget( QWidget* );
 
111
 
 
112
        //! true if widget is animated
 
113
        virtual bool isAnimated( const QObject* object, const QPoint& point );
 
114
 
 
115
        //! animation opacity
 
116
        virtual qreal opacity( const QObject* object, const QPoint& point )
 
117
        { return isAnimated( object, point ) ? _data.find( object ).data()->opacity( point ): AnimationData::OpacityInvalid; }
 
118
 
 
119
        //! return 'hover' rect position when widget is animated
 
120
        virtual QRect currentRect( const QObject* object, const QPoint& point)
 
121
        { return isAnimated( object, point ) ? _data.find( object ).data()->currentRect( point ): QRect(); }
 
122
 
 
123
        //! enability
 
124
        virtual void setEnabled( bool value )
 
125
        {
 
126
            BaseEngine::setEnabled( value );
 
127
            _data.setEnabled( value );
 
128
        }
 
129
 
 
130
        //! duration
 
131
        virtual void setDuration( int duration )
 
132
        {
 
133
            BaseEngine::setDuration( duration );
 
134
            _data.setDuration( duration );
 
135
        }
 
136
 
 
137
        //! return list of registered widgets
 
138
        virtual WidgetList registeredWidgets( void ) const;
 
139
 
 
140
        public slots:
 
141
 
 
142
        //! remove widget from map
 
143
        virtual bool unregisterWidget( QObject* object )
 
144
        { return _data.unregisterWidget( object ); }
 
145
 
 
146
        private:
 
147
 
 
148
        //! data map
 
149
        DataMap<MenuBarDataV1> _data;
 
150
 
 
151
    };
 
152
 
 
153
        //! follow-mouse menubar animation
 
154
    class MenuBarEngineV2: public MenuBarBaseEngine
 
155
    {
 
156
 
 
157
        Q_OBJECT
 
158
 
 
159
        public:
 
160
 
 
161
        //! constructor
 
162
        MenuBarEngineV2( QObject* parent ):
 
163
        MenuBarBaseEngine( parent )
 
164
        {}
 
165
 
 
166
        //! constructor
 
167
        MenuBarEngineV2( QObject* parent, MenuBarBaseEngine* other );
 
168
 
 
169
        //! destructor
 
170
        virtual ~MenuBarEngineV2( void )
 
171
        {}
 
172
 
 
173
        //! register menubar
 
174
        virtual bool registerWidget( QWidget* );
 
175
 
 
176
 
 
177
        //! true if widget is animated
 
178
        virtual bool isAnimated( const QObject* object, const QPoint& point );
 
179
 
 
180
        //! animation opacity
 
181
        virtual qreal opacity( const QObject* object, const QPoint& point )
 
182
        { return isAnimated( object, point ) ? _data.find( object ).data()->opacity(): AnimationData::OpacityInvalid; }
 
183
 
 
184
        //! return 'hover' rect position when widget is animated
 
185
        virtual QRect currentRect( const QObject*, const QPoint& );
 
186
 
 
187
        //! return 'hover' rect position when widget is animated
 
188
        virtual QRect animatedRect( const QObject* );
 
189
 
 
190
        //! timer associated to the data
 
191
        virtual bool isTimerActive( const QObject* );
 
192
 
 
193
        //! enability
 
194
        virtual void setEnabled( bool value )
 
195
        {
 
196
            BaseEngine::setEnabled( value );
 
197
            _data.setEnabled( value );
 
198
        }
 
199
 
 
200
        //! duration
 
201
        virtual void setDuration( int value )
 
202
        {
 
203
            BaseEngine::setDuration( value );
 
204
            _data.setDuration( value );
 
205
        }
 
206
 
 
207
        //! duration
 
208
        virtual int followMouseDuration( void ) const
 
209
        { return _followMouseDuration; }
 
210
 
 
211
        //! duration
 
212
        virtual void setFollowMouseDuration( int duration )
 
213
        {
 
214
            _followMouseDuration = duration;
 
215
            foreach( const DataMap<MenuBarDataV2>::Value& value, _data )
 
216
            { if( value ) value.data()->setFollowMouseDuration( duration ); }
 
217
        }
 
218
 
 
219
        //! return list of registered widgets
 
220
        virtual WidgetList registeredWidgets( void ) const;
 
221
 
 
222
        protected slots:
 
223
 
 
224
        //! remove widget from map
 
225
        virtual bool unregisterWidget( QObject* object )
 
226
        { return _data.unregisterWidget( object ); }
 
227
 
 
228
        private:
 
229
 
 
230
        //! follow mouse animation duration
 
231
        int _followMouseDuration;
 
232
 
 
233
        //! data map
 
234
        DataMap<MenuBarDataV2> _data;
 
235
 
 
236
    };
 
237
 
 
238
}
 
239
 
 
240
#endif