00001 /*************************************************************************** 00002 * Copyright (C) 2004 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the papyrus library. * 00006 * * 00007 * papyrus is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU Lesser General Public License * 00009 * version 3.0 as published by the Free Software Foundation. * 00010 * * 00011 * papyrus is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU Lesser General Public License version 3.0 for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with the papyrus library. If not, see * 00018 * <http://www.gnu.org/licenses/>. * 00019 ***************************************************************************/ 00020 #ifndef PAPYRUSANIMATOR_H 00021 #define PAPYRUSANIMATOR_H 00022 00023 #include <glib.h> 00024 00025 #include <papyrus/controller.h> 00026 00027 namespace Papyrus 00028 { 00029 00034 class Animator : public Controller 00035 { 00036 protected: 00037 Animator(const Glib::ustring& id); 00038 00039 public: 00040 typedef PapyrusPointer<Animator> pointer; 00041 00042 virtual ~Animator(); 00043 00045 virtual int advance ( int n=1 ); 00046 00048 virtual int reverse ( int n=1 ); 00049 00050 virtual void set_interval ( unsigned int interval_ms ); 00051 00052 virtual unsigned int interval( ); 00053 00054 virtual double frame_rate( ); 00055 00068 virtual void set_frame_rate ( unsigned int frames_per_second ); 00069 00070 virtual void start(); 00071 00072 virtual void start ( unsigned int interval_ms ); 00073 00074 virtual void stop(); 00075 00076 virtual bool is_started(); 00077 00079 int bounce_frames(); 00080 00088 int bounce_direction(); 00089 00106 void set_bounce_frames ( int frames ); 00107 00108 sigc::signal<void, int> signal_advanced(); 00109 00110 protected: 00111 unsigned int m_interval; 00112 int m_bounce_frames; 00113 int m_bounce_direction; 00114 int m_bounce_position; 00115 guint m_timeout_source_id; 00116 00117 sigc::signal<void, int> m_signal_advanced; 00118 00119 bool timeout_handler(); 00120 00132 virtual int animate ( int n ) = 0; 00133 00134 private: 00135 static gboolean timeout_handler_proxy ( gpointer data ); 00136 }; 00137 00138 } 00139 00140 #endif