1
#ifndef oxygenscrollbarengine_h
2
#define oxygenscrollbarengine_h
4
//////////////////////////////////////////////////////////////////////////////
5
// oxygenscrollbarengine.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 "oxygenscrollbardata.h"
37
//! stores scrollbar hovered action and timeLine
38
class ScrollBarEngine: public BaseEngine
46
ScrollBarEngine( QObject* parent ):
51
virtual ~ScrollBarEngine( void )
54
//! register scrollbar
55
virtual bool registerWidget( QWidget* );
57
//! true if widget is animated
58
virtual bool isAnimated( const QObject* object, QStyle::SubControl control );
61
virtual qreal opacity( const QObject* object, QStyle::SubControl control )
62
{ return isAnimated( object, control ) ? _data.find( object ).data()->opacity( control ):AnimationData::OpacityInvalid; }
64
//! return true if given subcontrol is hovered
65
virtual bool isHovered( const QObject* object, QStyle::SubControl control )
67
if( DataMap<ScrollBarData>::Value data = _data.find( object ) ) return data.data()->isHovered( control );
71
//! control rect associated to object
72
virtual QRect subControlRect( const QObject* object, QStyle::SubControl control )
74
if( DataMap<ScrollBarData>::Value data = _data.find( object ) ) return data.data()->subControlRect( control );
79
virtual void setSubControlRect( const QObject* object, QStyle::SubControl control, const QRect& rect )
81
if( DataMap<ScrollBarData>::Value data = _data.find( object ) )
82
{ data.data()->setSubControlRect( control, rect ); }
86
virtual void updateState( const QObject* object, bool state )
88
if( DataMap<ScrollBarData>::Value data = _data.find( object ) )
89
{ data.data()->updateState( state ); }
94
virtual void setEnabled( bool value )
96
BaseEngine::setEnabled( value );
98
do not disable the map directly, because the contained OxygenScrollbarData
99
are also used in non animated mode to store scrollbar arrows rect. However
100
do disable all contains DATA object, in order to prevent actual animations
102
foreach( const DataMap<ScrollBarData>::Value data, _data )
103
{ if( data ) data.data()->setEnabled( value ); }
108
virtual void setDuration( int value )
110
BaseEngine::setDuration( value );
111
_data.setDuration( value );
116
//! remove widget from map
117
virtual bool unregisterWidget( QObject* object )
118
{ return _data.unregisterWidget( object ); }
123
DataMap<ScrollBarData> _data;