1
#ifndef oxygenmenubarengine_h
2
#define oxygenmenubarengine_h
4
//////////////////////////////////////////////////////////////////////////////
5
// oxygenmenubarengine.h
6
// stores event filters and maps widgets to timelines for animations
9
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
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 "oxygenbaseengine.h"
31
#include "oxygendatamap.h"
32
#include "oxygenmenubardata.h"
37
//! stores menubar hovered action and timeLine
38
class MenuBarBaseEngine: public BaseEngine
46
MenuBarBaseEngine( QObject* parent ):
51
virtual ~MenuBarBaseEngine( void )
55
virtual bool registerWidget( QWidget* ) = 0;
57
//! true if widget is animated
58
virtual bool isAnimated( const QObject*, const QPoint& )
62
virtual qreal opacity( const QObject*, const QPoint& )
65
//! return 'hover' rect position when widget is animated
66
virtual QRect currentRect( const QObject*, const QPoint& )
70
virtual QRect animatedRect( const QObject* )
74
virtual bool isTimerActive( const QObject* )
78
virtual void setEnabled( bool ) = 0;
81
virtual void setDuration( int ) = 0;
84
virtual void setFollowMouseDuration( int )
89
//! fading menubar animation
90
class MenuBarEngineV1: public MenuBarBaseEngine
98
MenuBarEngineV1( QObject* parent ):
99
MenuBarBaseEngine( parent )
103
MenuBarEngineV1( QObject* parent, MenuBarBaseEngine* other );
106
virtual ~MenuBarEngineV1( void )
110
virtual bool registerWidget( QWidget* );
112
//! true if widget is animated
113
virtual bool isAnimated( const QObject* object, const QPoint& point );
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; }
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(); }
124
virtual void setEnabled( bool value )
126
BaseEngine::setEnabled( value );
127
_data.setEnabled( value );
131
virtual void setDuration( int duration )
133
BaseEngine::setDuration( duration );
134
_data.setDuration( duration );
137
//! return list of registered widgets
138
virtual WidgetList registeredWidgets( void ) const;
142
//! remove widget from map
143
virtual bool unregisterWidget( QObject* object )
144
{ return _data.unregisterWidget( object ); }
149
DataMap<MenuBarDataV1> _data;
153
//! follow-mouse menubar animation
154
class MenuBarEngineV2: public MenuBarBaseEngine
162
MenuBarEngineV2( QObject* parent ):
163
MenuBarBaseEngine( parent )
167
MenuBarEngineV2( QObject* parent, MenuBarBaseEngine* other );
170
virtual ~MenuBarEngineV2( void )
174
virtual bool registerWidget( QWidget* );
177
//! true if widget is animated
178
virtual bool isAnimated( const QObject* object, const QPoint& point );
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; }
184
//! return 'hover' rect position when widget is animated
185
virtual QRect currentRect( const QObject*, const QPoint& );
187
//! return 'hover' rect position when widget is animated
188
virtual QRect animatedRect( const QObject* );
190
//! timer associated to the data
191
virtual bool isTimerActive( const QObject* );
194
virtual void setEnabled( bool value )
196
BaseEngine::setEnabled( value );
197
_data.setEnabled( value );
201
virtual void setDuration( int value )
203
BaseEngine::setDuration( value );
204
_data.setDuration( value );
208
virtual int followMouseDuration( void ) const
209
{ return _followMouseDuration; }
212
virtual void setFollowMouseDuration( int duration )
214
_followMouseDuration = duration;
215
foreach( const DataMap<MenuBarDataV2>::Value& value, _data )
216
{ if( value ) value.data()->setFollowMouseDuration( duration ); }
219
//! return list of registered widgets
220
virtual WidgetList registeredWidgets( void ) const;
224
//! remove widget from map
225
virtual bool unregisterWidget( QObject* object )
226
{ return _data.unregisterWidget( object ); }
230
//! follow mouse animation duration
231
int _followMouseDuration;
234
DataMap<MenuBarDataV2> _data;