File indexing completed on 2024-05-12 05:34:36

0001 #ifndef oxygentabwidgetstatedata_h
0002 #define oxygentabwidgetstatedata_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 
0013 #include <gtk/gtk.h>
0014 
0015 namespace Oxygen
0016 {
0017     //! track arrow state changes events,
0018     /*! used to deal with spinbox and Notebook arrows */
0019     class TabWidgetStateData
0020     {
0021 
0022         public:
0023 
0024         //! constructor
0025         explicit TabWidgetStateData( void ):
0026             _target( 0L )
0027         {}
0028 
0029         //! destructor
0030         virtual ~TabWidgetStateData( void )
0031         {}
0032 
0033         //! setup connections
0034         void connect( GtkWidget* );
0035 
0036         //! disconnect
0037         void disconnect( GtkWidget* );
0038 
0039         //! update state
0040         bool updateState( int, bool );
0041 
0042         //! enable state
0043         void setEnabled( bool value )
0044         {
0045             _current._timeLine.setEnabled( value );
0046             _previous._timeLine.setEnabled( value );
0047         }
0048 
0049         //! duration
0050         void setDuration( int value )
0051         {
0052             _current._timeLine.setDuration( value );
0053             _previous._timeLine.setDuration( value );
0054         }
0055 
0056         //! true if tab index is animated
0057         bool isAnimated( int index ) const
0058         {
0059             if( index == _current._index ) return _current._timeLine.isRunning();
0060             else if( index == _previous._index ) return _previous._timeLine.isRunning();
0061             else return false;
0062         }
0063 
0064         //! opacity
0065         double opacity( int index ) const
0066         {
0067             if( index == _current._index ) return _current._timeLine.value();
0068             else if( index == _previous._index ) return _previous._timeLine.value();
0069             else return OpacityInvalid;
0070         }
0071 
0072         protected:
0073 
0074         //! return dirty rect (for update)
0075         GdkRectangle dirtyRect( void ) const;
0076 
0077         //! delayed update
0078         static gboolean delayedUpdate( gpointer );
0079 
0080         private:
0081 
0082         //! invalid index
0083         static const int IndexInvalid;
0084 
0085         //! tab data
0086         class Data
0087         {
0088 
0089             public:
0090 
0091             //! constructor
0092             explicit Data( void ):
0093                 _index( IndexInvalid )
0094             {}
0095 
0096             //! timeline
0097             TimeLine _timeLine;
0098 
0099             //! tab index
0100             int _index;
0101 
0102         };
0103 
0104         //! target
0105         GtkWidget* _target;
0106 
0107         //! current tab data
0108         Data _current;
0109 
0110         //! previous tab data
0111         Data _previous;
0112 
0113     };
0114 
0115 }
0116 
0117 #endif