1 #ifndef oxygenfollowmousedata_h
2 #define oxygenfollowmousedata_h
3 /*
4 * this file is part of the oxygen gtk engine
5 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
6 *
7 * This  library is free  software; you can  redistribute it and/or
8 * modify it  under  the terms  of the  GNU Lesser  General  Public
9 * License  as published  by the Free  Software  Foundation; either
10 * version 2 of the License, or(at your option ) any later version.
11 *
12 * This library is distributed  in the hope that it will be useful,
13 * but  WITHOUT ANY WARRANTY; without even  the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License  along  with  this library;  if not,  write to  the Free
19 * Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
21 */
22 
23 #include "../oxygengtkutils.h"
24 #include "oxygentimeline.h"
25 
26 #include <gdk/gdk.h>
27 
28 namespace Oxygen
29 {
30     //! stores data needed for follow-mouse animations
31     class FollowMouseData
32     {
33         public:
34 
35         //! constructor
FollowMouseData(void)36         FollowMouseData( void ):
37             _followMouse( false ),
38             _startRect( Gtk::gdk_rectangle() ),
39             _endRect( Gtk::gdk_rectangle() ),
40             _animatedRect( Gtk::gdk_rectangle() ),
41             _dirtyRect( Gtk::gdk_rectangle() )
42         {}
43 
44         //! destructor
~FollowMouseData(void)45         virtual ~FollowMouseData( void )
46         {}
47 
48         //!@name modifiers
49         //@{
50 
51         //! enable state
setEnabled(bool value)52         virtual void setEnabled( bool value )
53         { _timeLine.setEnabled( value ); }
54 
55         //! follow-mouse animation
setFollowMouse(bool value)56         virtual void setFollowMouse( bool value )
57         { _followMouse = value; }
58 
59         //! follow-mouse animation duration
setFollowMouseAnimationsDuration(int value)60         virtual void setFollowMouseAnimationsDuration( int value )
61         { _timeLine.setDuration( value ); }
62 
63         //@}
64 
65         //!@name accessors
66         //@{
67 
68         //! returns true if animated rectangle is valid
animatedRectangleIsValid(void)69         virtual bool animatedRectangleIsValid( void ) const
70         { return _timeLine.isRunning() && Gtk::gdk_rectangle_is_valid( &_animatedRect ); }
71 
72         //! animated rectangle
animatedRectangle(void)73         virtual const GdkRectangle& animatedRectangle( void ) const
74         { return _animatedRect; }
75 
76         //@}
77 
78         protected:
79 
80         //! connect
connect(GSourceFunc function,gpointer data)81         virtual void connect( GSourceFunc function, gpointer data )
82         {
83             _timeLine.connect( function, data );
84             _timeLine.setDirection( TimeLine::Forward );
85         }
86 
87         //! disconnect
disconnect(void)88         virtual void disconnect( void )
89         { _timeLine.disconnect(); }
90 
91         //! true if enabled
followMouse(void)92         virtual bool followMouse( void ) const
93         { return _followMouse; }
94 
95         //! follow-mouse dirty rect
96         virtual GdkRectangle dirtyRect( void );
97 
98         //! start follow-mouse animation
99         virtual void startAnimation( const GdkRectangle&, const GdkRectangle& );
100 
101         //! update animated rect
102         virtual void updateAnimatedRect( void );
103 
104         private:
105 
106         //! true if enabled
107         bool _followMouse;
108 
109         //! timeline
110         TimeLine _timeLine;
111 
112         //! start rectangle
113         GdkRectangle _startRect;
114 
115         //! end rectangle
116         GdkRectangle _endRect;
117 
118         //! animated rectangle
119         GdkRectangle _animatedRect;
120 
121         //! dirty rect
122         GdkRectangle _dirtyRect;
123 
124     };
125 
126 
127 }
128 
129 #endif
130