1 #ifndef oxygentreeviewstatedata_h
2 #define oxygentreeviewstatedata_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 "../oxygenanimationdata.h"
25 #include "../oxygengtkcellinfo.h"
26 #include "../oxygengtkutils.h"
27 
28 #include <gtk/gtk.h>
29 
30 namespace Oxygen
31 {
32     //! track arrow state changes events,
33     /*! used to deal with spinbox and Notebook arrows */
34     class TreeViewStateData
35     {
36 
37         public:
38 
39         //! constructor
TreeViewStateData(void)40         explicit TreeViewStateData( void ):
41             _target( 0L ),
42             _dirtyRect( Gtk::gdk_rectangle() )
43         {}
44 
45         //! destructor
~TreeViewStateData(void)46         virtual ~TreeViewStateData( void )
47         {}
48 
49         //! setup connections
50         void connect( GtkWidget* );
51 
52         //! disconnect
53         void disconnect( GtkWidget* );
54 
55         //! update state
56         bool updateState( const Gtk::CellInfo&, bool );
57 
58         //! enable state
setEnabled(bool value)59         void setEnabled( bool value )
60         {
61             _current._timeLine.setEnabled( value );
62             _previous._timeLine.setEnabled( value );
63         }
64 
65         //! duration
setDuration(int value)66         void setDuration( int value )
67         {
68             _current._timeLine.setDuration( value );
69             _previous._timeLine.setDuration( value );
70         }
71 
72         //! true if tab info is animated
isAnimated(const Gtk::CellInfo & info)73         bool isAnimated( const Gtk::CellInfo& info ) const
74         {
75             if( info == _current._info ) return _current._timeLine.isRunning();
76             else if( info == _previous._info ) return _previous._timeLine.isRunning();
77             else return false;
78         }
79 
80         //! opacity
opacity(const Gtk::CellInfo & info)81         double opacity( const Gtk::CellInfo& info ) const
82         {
83             if( info == _current._info ) return _current._timeLine.value();
84             else if( info == _previous._info ) return _previous._timeLine.value();
85             else return OpacityInvalid;
86         }
87 
88         protected:
89 
90         //! return dirty rect (for update)
91         GdkRectangle dirtyRect( void );
92 
93         //! delayed update
94         static gboolean delayedUpdate( gpointer );
95 
96         private:
97 
98         //! tab data
99         class Data
100         {
101 
102             public:
103 
104             //! constructor
Data(void)105             explicit Data( void )
106             {}
107 
108             //! timeline
109             TimeLine _timeLine;
110 
111             //! tab info
112             Gtk::CellInfo _info;
113 
114         };
115 
116         //! target
117         GtkWidget* _target;
118 
119         //! current tab data
120         Data _current;
121 
122         //! previous tab data
123         Data _previous;
124 
125         //! additional dirty rect
126         GdkRectangle _dirtyRect;
127 
128     };
129 
130 }
131 
132 #endif
133