nuclear@6: /* nuclear@6: GoatKit - a themable/animated widget toolkit for games nuclear@6: Copyright (C) 2014 John Tsiombikas nuclear@6: nuclear@6: This program is free software: you can redistribute it and/or modify nuclear@6: it under the terms of the GNU Lesser General Public License as published by nuclear@6: the Free Software Foundation, either version 3 of the License, or nuclear@6: (at your option) any later version. nuclear@6: nuclear@6: This program is distributed in the hope that it will be useful, nuclear@6: but WITHOUT ANY WARRANTY; without even the implied warranty of nuclear@6: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nuclear@6: GNU Lesser General Public License for more details. nuclear@6: nuclear@6: You should have received a copy of the GNU Lesser General Public License nuclear@6: along with this program. If not, see . nuclear@6: */ nuclear@6: #ifndef BOOLANIM_H_ nuclear@6: #define BOOLANIM_H_ nuclear@6: nuclear@6: class BoolAnim { nuclear@6: private: nuclear@6: mutable float value; nuclear@6: mutable float trans_dir; // transition direction (sign) nuclear@6: long trans_start; // transition start time nuclear@6: long trans_dur; nuclear@6: nuclear@6: long (*get_msec)(); nuclear@6: nuclear@6: void update(long tm) const; nuclear@6: nuclear@6: public: nuclear@6: BoolAnim(bool st = false); nuclear@6: nuclear@6: void set_transition_duration(long dur); nuclear@6: void set_time_callback(long (*time_func)()); nuclear@6: nuclear@6: void set(bool st); nuclear@6: nuclear@6: void change(bool st); nuclear@6: void change(bool st, long trans_start); nuclear@6: nuclear@6: bool get_state() const; nuclear@6: bool get_state(long tm) const; nuclear@6: nuclear@6: float get_value() const; nuclear@6: float get_value(long tm) const; nuclear@6: nuclear@6: // transition direction (-1, 0, 1) nuclear@6: float get_dir() const; nuclear@6: float get_dir(long tm) const; nuclear@6: nuclear@6: operator bool() const; // equivalent to get_state nuclear@6: operator float() const; // equivalent to get_value nuclear@6: }; nuclear@6: nuclear@6: #endif // BOOLANIM_H_