mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
update gui slider for ivalMgr intervals
This commit is contained in:
parent
24f194bd45
commit
cab9905657
@ -85,6 +85,7 @@
|
||||
if not hasattr(self, "setTHooks"):
|
||||
self.setTHooks = []
|
||||
self.setTHooks.append(update)
|
||||
self.setWantsTCallback(1)
|
||||
# Clear out function on destroy
|
||||
def onDestroy(e, s=self, u=update):
|
||||
if u in s.setTHooks:
|
||||
|
@ -228,6 +228,10 @@ class MetaInterval(CMetaInterval):
|
||||
def getManager(self):
|
||||
return self.__manager
|
||||
|
||||
def setT(self, t):
|
||||
self.__updateIvals()
|
||||
CMetaInterval.setT(self, t)
|
||||
|
||||
def start(self, startT = 0.0, endT = -1.0, playRate = 1.0):
|
||||
self.__updateIvals()
|
||||
self.setupPlay(startT, endT, playRate, 0)
|
||||
|
@ -143,6 +143,32 @@ get_interruptible() const {
|
||||
return _interruptible;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CInterval::set_wants_t_callback
|
||||
// Access: Published
|
||||
// Description: Changes the state of the 'wants_t_callback' flag. If
|
||||
// this is true, the interval will be returned by
|
||||
// CIntervalManager::get_event() each time the
|
||||
// interval's time value has been changed, regardless of
|
||||
// whether it has any external events.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CInterval::
|
||||
set_wants_t_callback(bool wants_t_callback) {
|
||||
_wants_t_callback = wants_t_callback;
|
||||
_last_t_callback = -1.0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CInterval::get_wants_t_callback
|
||||
// Access: Published
|
||||
// Description: Returns the state of the 'wants_t_callback' flag.
|
||||
// See set_wants_t_callback().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool CInterval::
|
||||
get_wants_t_callback() const {
|
||||
return _wants_t_callback;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CInterval::set_manager
|
||||
// Access: Published
|
||||
@ -172,6 +198,22 @@ get_manager() const {
|
||||
return _manager;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CInterval::check_t_callback
|
||||
// Access: Public
|
||||
// Description: Returns true if the wants_t_callback() flag is true
|
||||
// and the interval's t value has changed since the last
|
||||
// call to check_t_callback(), false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool CInterval::
|
||||
check_t_callback() {
|
||||
if (get_wants_t_callback() && get_t() != _last_t_callback) {
|
||||
_last_t_callback = get_t();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CInterval::recompute
|
||||
// Access: Protected
|
||||
|
@ -40,6 +40,8 @@ CInterval(const string &name, double duration, bool open_ended) :
|
||||
_dirty(false)
|
||||
{
|
||||
_interruptible = false;
|
||||
_wants_t_callback = false;
|
||||
_last_t_callback = -1.0;
|
||||
_manager = CIntervalManager::get_global_ptr();
|
||||
_clock_start = 0.0;
|
||||
_start_t = 0.0;
|
||||
|
@ -78,6 +78,9 @@ PUBLISHED:
|
||||
INLINE void set_interruptible(bool interruptible);
|
||||
INLINE bool get_interruptible() const;
|
||||
|
||||
INLINE void set_wants_t_callback(bool wants_t_callback);
|
||||
INLINE bool get_wants_t_callback() const;
|
||||
|
||||
INLINE void set_manager(CIntervalManager *manager);
|
||||
INLINE CIntervalManager *get_manager() const;
|
||||
|
||||
@ -117,6 +120,7 @@ PUBLISHED:
|
||||
|
||||
public:
|
||||
void mark_dirty();
|
||||
INLINE bool check_t_callback();
|
||||
|
||||
protected:
|
||||
void interval_done();
|
||||
@ -133,6 +137,8 @@ protected:
|
||||
double _duration;
|
||||
|
||||
bool _interruptible;
|
||||
bool _wants_t_callback;
|
||||
double _last_t_callback;
|
||||
CIntervalManager *_manager;
|
||||
|
||||
// For setup_play() and step_play().
|
||||
|
@ -276,8 +276,12 @@ int CIntervalManager::
|
||||
get_next_event() {
|
||||
while (_next_event_index < (int)_intervals.size()) {
|
||||
IntervalDef &def = _intervals[_next_event_index];
|
||||
if (def._interval != (CInterval *)NULL &&
|
||||
(def._flags & F_meta_interval) != 0) {
|
||||
if (def._interval != (CInterval *)NULL) {
|
||||
if ((def._flags & F_external) != 0 &&
|
||||
def._interval->check_t_callback()) {
|
||||
return _next_event_index;
|
||||
}
|
||||
if ((def._flags & F_meta_interval) != 0) {
|
||||
CMetaInterval *meta_interval;
|
||||
DCAST_INTO_R(meta_interval, def._interval, -1);
|
||||
if (meta_interval->is_event_ready()) {
|
||||
@ -285,6 +289,7 @@ get_next_event() {
|
||||
return _next_event_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
_next_event_index++;
|
||||
}
|
||||
|
||||
|
@ -367,6 +367,14 @@ priv_initialize(double t) {
|
||||
|
||||
int now = double_to_int_time(t);
|
||||
|
||||
// One special case: if we step to t == 0.0, it really means to the
|
||||
// very beginning of the interval, *before* any events that occurred
|
||||
// at time 0. (Most of the time, stepping to a particular time
|
||||
// means *after* any events that occurred at that time.)
|
||||
if (t == 0.0) {
|
||||
now = -1;
|
||||
}
|
||||
|
||||
// Now look for events from the beginning up to the current time.
|
||||
_processing_events = true;
|
||||
ActiveEvents new_active;
|
||||
@ -559,6 +567,14 @@ priv_reverse_initialize(double t) {
|
||||
|
||||
int now = double_to_int_time(t);
|
||||
|
||||
// One special case: if we step to t == 0.0, it really means to the
|
||||
// very beginning of the interval, *before* any events that occurred
|
||||
// at time 0. (Most of the time, stepping to a particular time
|
||||
// means *after* any events that occurred at that time.)
|
||||
if (t == 0.0) {
|
||||
now = -1;
|
||||
}
|
||||
|
||||
// Now look for events from the end down to the current time.
|
||||
_processing_events = true;
|
||||
ActiveEvents new_active;
|
||||
|
Loading…
x
Reference in New Issue
Block a user