File indexing completed on 2024-05-12 05:34:33
0001 #ifndef oxygenfollowmousedata_h 0002 #define oxygenfollowmousedata_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 "../oxygengtkutils.h" 0011 #include "oxygentimeline.h" 0012 0013 #include <gdk/gdk.h> 0014 0015 namespace Oxygen 0016 { 0017 //! stores data needed for follow-mouse animations 0018 class FollowMouseData 0019 { 0020 public: 0021 0022 //! constructor 0023 FollowMouseData( void ): 0024 _followMouse( false ), 0025 _startRect( Gtk::gdk_rectangle() ), 0026 _endRect( Gtk::gdk_rectangle() ), 0027 _animatedRect( Gtk::gdk_rectangle() ), 0028 _dirtyRect( Gtk::gdk_rectangle() ) 0029 {} 0030 0031 //! destructor 0032 virtual ~FollowMouseData( void ) 0033 {} 0034 0035 //!@name modifiers 0036 //@{ 0037 0038 //! enable state 0039 virtual void setEnabled( bool value ) 0040 { _timeLine.setEnabled( value ); } 0041 0042 //! follow-mouse animation 0043 virtual void setFollowMouse( bool value ) 0044 { _followMouse = value; } 0045 0046 //! follow-mouse animation duration 0047 virtual void setFollowMouseAnimationsDuration( int value ) 0048 { _timeLine.setDuration( value ); } 0049 0050 //@} 0051 0052 //!@name accessors 0053 //@{ 0054 0055 //! returns true if animated rectangle is valid 0056 virtual bool animatedRectangleIsValid( void ) const 0057 { return _timeLine.isRunning() && Gtk::gdk_rectangle_is_valid( &_animatedRect ); } 0058 0059 //! animated rectangle 0060 virtual const GdkRectangle& animatedRectangle( void ) const 0061 { return _animatedRect; } 0062 0063 //@} 0064 0065 protected: 0066 0067 //! connect 0068 virtual void connect( GSourceFunc function, gpointer data ) 0069 { 0070 _timeLine.connect( function, data ); 0071 _timeLine.setDirection( TimeLine::Forward ); 0072 } 0073 0074 //! disconnect 0075 virtual void disconnect( void ) 0076 { _timeLine.disconnect(); } 0077 0078 //! true if enabled 0079 virtual bool followMouse( void ) const 0080 { return _followMouse; } 0081 0082 //! follow-mouse dirty rect 0083 virtual GdkRectangle dirtyRect( void ); 0084 0085 //! start follow-mouse animation 0086 virtual void startAnimation( const GdkRectangle&, const GdkRectangle& ); 0087 0088 //! update animated rect 0089 virtual void updateAnimatedRect( void ); 0090 0091 private: 0092 0093 //! true if enabled 0094 bool _followMouse; 0095 0096 //! timeline 0097 TimeLine _timeLine; 0098 0099 //! start rectangle 0100 GdkRectangle _startRect; 0101 0102 //! end rectangle 0103 GdkRectangle _endRect; 0104 0105 //! animated rectangle 0106 GdkRectangle _animatedRect; 0107 0108 //! dirty rect 0109 GdkRectangle _dirtyRect; 0110 0111 }; 0112 0113 0114 } 0115 0116 #endif