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

« back to all changes in this revision

Viewing changes to kstyles/oxygen/animations/oxygensplitterengine.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 oxygensplitterengine_h
 
2
#define oxygensplitterengine_h
 
3
 
 
4
//////////////////////////////////////////////////////////////////////////////
 
5
// oxygensplitterengine.h
 
6
// QSplitter engine
 
7
// -------------------
 
8
//
 
9
// Copyright (c) 2010 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 "oxygenwidgetstatedata.h"
 
33
 
 
34
namespace Oxygen
 
35
{
 
36
 
 
37
    //! QSplitter animation engine
 
38
    class SplitterEngine: public BaseEngine
 
39
    {
 
40
 
 
41
        Q_OBJECT
 
42
 
 
43
        public:
 
44
 
 
45
        //! constructor
 
46
        SplitterEngine( QObject* parent ):
 
47
        BaseEngine( parent )
 
48
        {}
 
49
 
 
50
        //! destructor
 
51
        virtual ~SplitterEngine( void )
 
52
        {}
 
53
 
 
54
        //! enability
 
55
        virtual void setEnabled( bool value )
 
56
        {
 
57
            BaseEngine::setEnabled( value );
 
58
            _data.setEnabled( value );
 
59
        }
 
60
 
 
61
        //! duration
 
62
        virtual void setDuration( int value )
 
63
        {
 
64
            BaseEngine::setDuration( value );
 
65
            _data.setDuration( value );
 
66
        }
 
67
 
 
68
        //! register widget
 
69
        virtual bool registerWidget( QWidget* );
 
70
 
 
71
        //! true if widget hover state is changed
 
72
        virtual bool updateState( const QPaintDevice*, bool );
 
73
 
 
74
        //! true if widget is animated
 
75
        virtual bool isAnimated( const QPaintDevice* );
 
76
 
 
77
        //! animation opacity
 
78
        virtual qreal opacity( const QPaintDevice* object )
 
79
        { return isAnimated( object ) ? data( object ).data()->opacity(): AnimationData::OpacityInvalid; }
 
80
 
 
81
        public slots:
 
82
 
 
83
        //! remove widget from map
 
84
        virtual bool unregisterWidget( QObject* data )
 
85
        {
 
86
 
 
87
            if( !data ) return false;
 
88
 
 
89
            // reinterpret_cast is safe here since only the address is used to find
 
90
            // data in the map
 
91
            return _data.unregisterWidget( reinterpret_cast<QPaintDevice*>(data) );
 
92
 
 
93
        }
 
94
 
 
95
        protected:
 
96
 
 
97
        //! returns data associated to widget
 
98
        PaintDeviceDataMap<WidgetStateData>::Value data( const QPaintDevice* object )
 
99
        { return _data.find( object ).data(); }
 
100
 
 
101
        private:
 
102
 
 
103
        //! engine enability
 
104
        bool _enabled;
 
105
 
 
106
        //! animation duration
 
107
        int _duration;
 
108
 
 
109
        //! map
 
110
        PaintDeviceDataMap<WidgetStateData> _data;
 
111
 
 
112
    };
 
113
 
 
114
}
 
115
 
 
116
#endif