mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
here we go
This commit is contained in:
parent
0acafa7712
commit
1aea5622dc
@ -52,6 +52,7 @@ INLINE void GuiButton::up(void) {
|
||||
gui_cat->warning() << "got up from invalid state (" << (int)_state << "),"
|
||||
<< " button '" << this->get_name() << "'" << endl;
|
||||
}
|
||||
this->reset_behavior();
|
||||
}
|
||||
|
||||
INLINE void GuiButton::down(void) {
|
||||
@ -84,6 +85,7 @@ INLINE void GuiButton::inactive(void) {
|
||||
gui_cat->warning() << "got inactive from invalid state (" << (int)_state
|
||||
<< "), button '" << this->get_name() << "'" << endl;
|
||||
}
|
||||
this->stop_behavior();
|
||||
}
|
||||
|
||||
INLINE void GuiButton::click(void) {
|
||||
@ -124,25 +126,55 @@ INLINE bool GuiButton::is_active(void) const {
|
||||
}
|
||||
|
||||
INLINE void GuiButton::set_up_event(const string& s) {
|
||||
if (_behavior_running)
|
||||
if (_mgr != (GuiManager*)0L)
|
||||
_eh->remove_hook(_up_event, GuiButton::behavior_up, (void*)this);
|
||||
_up_event = s;
|
||||
if (_behavior_running)
|
||||
if (_mgr != (GuiManager*)0L)
|
||||
_eh->add_hook(_up_event, GuiButton::behavior_up, (void*)this);
|
||||
}
|
||||
|
||||
INLINE void GuiButton::set_up_rollover_event(const string& s) {
|
||||
if (_behavior_running)
|
||||
if (_mgr != (GuiManager*)0L)
|
||||
_eh->remove_hook(_up_rollover_event, GuiButton::behavior_up,
|
||||
(void*)this);
|
||||
_up_rollover_event = s;
|
||||
if (_behavior_running)
|
||||
if (_mgr != (GuiManager*)0L)
|
||||
_eh->add_hook(_up_rollover_event, GuiButton::behavior_up, (void*)this);
|
||||
}
|
||||
|
||||
INLINE void GuiButton::set_down_event(const string& s) {
|
||||
if (_behavior_running)
|
||||
if (_mgr != (GuiManager*)0L)
|
||||
_eh->remove_hook(_down_event, GuiButton::behavior_up, (void*)this);
|
||||
_down_event = s;
|
||||
if (_behavior_running)
|
||||
if (_mgr != (GuiManager*)0L)
|
||||
_eh->add_hook(_down_event, GuiButton::behavior_up, (void*)this);
|
||||
}
|
||||
|
||||
INLINE void GuiButton::set_down_rollover_event(const string& s) {
|
||||
if (_behavior_running)
|
||||
if (_mgr != (GuiManager*)0L)
|
||||
_eh->remove_hook(_down_rollover_event, GuiButton::behavior_up,
|
||||
(void*)this);
|
||||
_down_rollover_event = s;
|
||||
if (_behavior_running)
|
||||
if (_mgr != (GuiManager*)0L)
|
||||
_eh->add_hook(_down_rollover_event, GuiButton::behavior_up, (void*)this);
|
||||
}
|
||||
|
||||
INLINE void GuiButton::set_inactive_event(const string& s) {
|
||||
_inactive_event = s;
|
||||
}
|
||||
|
||||
INLINE void GuiButton::set_behavior_event(const string& s) {
|
||||
_behavior_event = s;
|
||||
}
|
||||
|
||||
INLINE const string& GuiButton::get_up_event(void) const {
|
||||
return _up_event;
|
||||
}
|
||||
@ -163,6 +195,10 @@ INLINE const string& GuiButton::get_inactive_event(void) const {
|
||||
return _inactive_event;
|
||||
}
|
||||
|
||||
INLINE const string& GuiButton::get_behavior_event(void) const {
|
||||
return _behavior_event;
|
||||
}
|
||||
|
||||
INLINE void GuiButton::set_up_rollover(GuiLabel* upr) {
|
||||
_up_rollover = upr;
|
||||
if (_up_rollover_event.empty())
|
||||
@ -174,3 +210,12 @@ INLINE void GuiButton::set_down_rollover(GuiLabel* downr) {
|
||||
if (_down_rollover_event.empty())
|
||||
_down_rollover_event = this->get_name() + "-down-rollover";
|
||||
}
|
||||
|
||||
INLINE void GuiButton::set_behavior_functor(GuiBehavior::BehaviorFunctor* f) {
|
||||
_behavior_functor = f;
|
||||
}
|
||||
|
||||
INLINE GuiBehavior::BehaviorFunctor*
|
||||
GuiButton::get_behavior_functor(void) const {
|
||||
return _behavior_functor;
|
||||
}
|
||||
|
@ -395,14 +395,29 @@ void GuiButton::set_pos(const LVector3f& p) {
|
||||
|
||||
void GuiButton::start_behavior(void) {
|
||||
GuiBehavior::start_behavior();
|
||||
if (_mgr == (GuiManager*)0L)
|
||||
return;
|
||||
_eh->add_hook(_down_event, GuiButton::behavior_down, (void*)this);
|
||||
_eh->add_hook(_down_rollover_event, GuiButton::behavior_down, (void*)this);
|
||||
}
|
||||
|
||||
void GuiButton::stop_behavior(void) {
|
||||
GuiBehavior::stop_behavior();
|
||||
if (_mgr == (GuiManager*)0L)
|
||||
return;
|
||||
_eh->remove_hook(_up_event, GuiButton::behavior_up, (void*)this);
|
||||
_eh->remove_hook(_up_rollover_event, GuiButton::behavior_up, (void*)this);
|
||||
_eh->remove_hook(_down_event, GuiButton::behavior_down, (void*)this);
|
||||
_eh->remove_hook(_down_rollover_event, GuiButton::behavior_down,
|
||||
(void*)this);
|
||||
}
|
||||
|
||||
void GuiButton::reset_behavior(void) {
|
||||
GuiBehavior::reset_behavior();
|
||||
if (_mgr == (GuiManager*)0L)
|
||||
return;
|
||||
_eh->remove_hook(_up_event, GuiButton::behavior_up, (void*)this);
|
||||
_eh->remove_hook(_up_rollover_event, GuiButton::behavior_up, (void*)this);
|
||||
}
|
||||
|
||||
void GuiButton::output(ostream& os) const {
|
||||
|
@ -74,16 +74,21 @@ PUBLISHED:
|
||||
INLINE void set_down_event(const string&);
|
||||
INLINE void set_down_rollover_event(const string&);
|
||||
INLINE void set_inactive_event(const string&);
|
||||
INLINE void set_behavior_event(const string&);
|
||||
|
||||
INLINE const string& get_up_event(void) const;
|
||||
INLINE const string& get_up_rollover_event(void) const;
|
||||
INLINE const string& get_down_event(void) const;
|
||||
INLINE const string& get_down_rollover_event(void) const;
|
||||
INLINE const string& get_inactive_event(void) const;
|
||||
INLINE const string& get_behavior_event(void) const;
|
||||
|
||||
INLINE void set_up_rollover(GuiLabel*);
|
||||
INLINE void set_down_rollover(GuiLabel*);
|
||||
|
||||
INLINE void set_behavior_functor(GuiBehavior::BehaviorFunctor*);
|
||||
INLINE GuiBehavior::BehaviorFunctor* get_behavior_functor(void) const;
|
||||
|
||||
virtual void set_scale(float);
|
||||
virtual void set_pos(const LVector3f&);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user