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