File indexing completed on 2024-05-12 17:05:52

0001 #ifndef oxygentreeviewstatedata_h
0002 #define oxygentreeviewstatedata_h
0003 /*
0004 * this file is part of the oxygen gtk engine
0005 * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0006 *
0007 * SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #include "oxygentimeline.h"
0011 #include "../oxygenanimationdata.h"
0012 #include "../oxygengtkcellinfo.h"
0013 #include "../oxygengtkutils.h"
0014 
0015 #include <gtk/gtk.h>
0016 
0017 namespace Oxygen
0018 {
0019     //! track arrow state changes events,
0020     /*! used to deal with spinbox and Notebook arrows */
0021     class TreeViewStateData
0022     {
0023 
0024         public:
0025 
0026         //! constructor
0027         explicit TreeViewStateData( void ):
0028             _target( 0L ),
0029             _dirtyRect( Gtk::gdk_rectangle() )
0030         {}
0031 
0032         //! destructor
0033         virtual ~TreeViewStateData( void )
0034         {}
0035 
0036         //! setup connections
0037         void connect( GtkWidget* );
0038 
0039         //! disconnect
0040         void disconnect( GtkWidget* );
0041 
0042         //! update state
0043         bool updateState( const Gtk::CellInfo&, bool );
0044 
0045         //! enable state
0046         void setEnabled( bool value )
0047         {
0048             _current._timeLine.setEnabled( value );
0049             _previous._timeLine.setEnabled( value );
0050         }
0051 
0052         //! duration
0053         void setDuration( int value )
0054         {
0055             _current._timeLine.setDuration( value );
0056             _previous._timeLine.setDuration( value );
0057         }
0058 
0059         //! true if tab info is animated
0060         bool isAnimated( const Gtk::CellInfo& info ) const
0061         {
0062             if( info == _current._info ) return _current._timeLine.isRunning();
0063             else if( info == _previous._info ) return _previous._timeLine.isRunning();
0064             else return false;
0065         }
0066 
0067         //! opacity
0068         double opacity( const Gtk::CellInfo& info ) const
0069         {
0070             if( info == _current._info ) return _current._timeLine.value();
0071             else if( info == _previous._info ) return _previous._timeLine.value();
0072             else return OpacityInvalid;
0073         }
0074 
0075         protected:
0076 
0077         //! return dirty rect (for update)
0078         GdkRectangle dirtyRect( void );
0079 
0080         //! delayed update
0081         static gboolean delayedUpdate( gpointer );
0082 
0083         private:
0084 
0085         //! tab data
0086         class Data
0087         {
0088 
0089             public:
0090 
0091             //! constructor
0092             explicit Data( void )
0093             {}
0094 
0095             //! timeline
0096             TimeLine _timeLine;
0097 
0098             //! tab info
0099             Gtk::CellInfo _info;
0100 
0101         };
0102 
0103         //! target
0104         GtkWidget* _target;
0105 
0106         //! current tab data
0107         Data _current;
0108 
0109         //! previous tab data
0110         Data _previous;
0111 
0112         //! additional dirty rect
0113         GdkRectangle _dirtyRect;
0114 
0115     };
0116 
0117 }
0118 
0119 #endif