1 #ifndef oxygenwidgetstatedata_h
2 #define oxygenwidgetstatedata_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 "oxygentimeline.h"
24 #include "../oxygengtkutils.h"
25 
26 #include <gtk/gtk.h>
27 
28 namespace Oxygen
29 {
30     //! track widget state changes events
31     class WidgetStateData
32     {
33 
34         public:
35 
36         //! constructor
WidgetStateData(void)37         explicit WidgetStateData( void ):
38             _target( 0L ),
39             _dirtyRect( Gtk::gdk_rectangle() ),
40             _state( false )
41         {}
42 
43         //! destructor
~WidgetStateData(void)44         virtual ~WidgetStateData( void )
45         {}
46 
47         //! setup connections
48         void connect( GtkWidget* );
49 
50         //! disconnect
51         void disconnect( GtkWidget* );
52 
53         //! update state
54         bool updateState( bool value, const GdkRectangle& );
55 
56         //! update state
updateState(bool value)57         bool updateState( bool value )
58         { return updateState( value, Gtk::gdk_rectangle() ); }
59 
60         //! true if animated
isAnimated(void)61         bool isAnimated( void ) const
62         { return _timeLine.isRunning(); }
63 
64         //! opacity
opacity(void)65         double opacity( void ) const
66         { return _timeLine.value(); }
67 
68         //! enable state
setEnabled(bool value)69         void setEnabled( bool value )
70         { _timeLine.setEnabled( value ); }
71 
72         //! duration
setDuration(int value)73         void setDuration( int value )
74         { _timeLine.setDuration( value ); }
75 
76         protected:
77 
78         //! delayed update
79         static gboolean delayedUpdate( gpointer );
80 
81         private:
82 
83         //! target
84         GtkWidget* _target;
85 
86         //! timeline
87         TimeLine _timeLine;
88 
89         //! dirty rect
90         GdkRectangle _dirtyRect;
91 
92         //! state
93         bool _state;
94 
95     };
96 
97 }
98 
99 #endif
100