Back to index

unity  6.0.0
Animator.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Marco Trevisan (TreviƱo) <mail@3v1n0.net>
00018  */
00019 
00020 #ifndef UNITY_ANIMATOR_H_
00021 #define UNITY_ANIMATOR_H_
00022 
00023 #include <cstdint>
00024 #include <UnityCore/GLibSource.h>
00025 
00026 namespace unity
00027 {
00028 class Animator : boost::noncopyable
00029 {
00030 public:
00031   Animator(unsigned int default_duration, unsigned int fps_rate = 30);
00032   ~Animator();
00033 
00034   void SetRate(unsigned int fps_rate);
00035   void SetDuration(unsigned int duration);
00036 
00037   unsigned int GetRate() const;
00038   unsigned int GetDuration() const;
00039   double GetProgress() const;
00040   bool IsRunning() const;
00041 
00042   void Start(double start_progress = 0.0f);
00043   void Start(unsigned int one_time_duration, double start_progress = 0.0f);
00044   bool DoStep();
00045   void Stop();
00046 
00047   sigc::signal<void> animation_started;
00048   sigc::signal<void> animation_ended;
00049 
00050   sigc::signal<void, double> animation_updated;
00051   sigc::signal<void, double> animation_stopped;
00052 
00053 private:
00054   glib::Source::UniquePtr timeout_;
00055   int64_t start_time_;
00056   unsigned int rate_;
00057   unsigned int duration_;
00058   unsigned int one_time_duration_;
00059   double start_progress_;
00060   double progress_;
00061 };
00062 
00063 }
00064 #endif