mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -04:00
make buttons optionally have a parameter on the behavior event
This commit is contained in:
parent
b601b49c80
commit
3975bc1d18
@ -231,3 +231,12 @@ INLINE GuiBehavior::BehaviorFunctor*
|
|||||||
GuiButton::get_behavior_functor(void) const {
|
GuiButton::get_behavior_functor(void) const {
|
||||||
return _behavior_functor;
|
return _behavior_functor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INLINE void GuiButton::set_behavior_event_parameter(int p) {
|
||||||
|
this->_have_event_param = true;
|
||||||
|
this->_event_param = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
INLINE int GuiButton::get_behavior_event_parameter(void) const {
|
||||||
|
return this->_event_param;
|
||||||
|
}
|
||||||
|
@ -324,8 +324,12 @@ void GuiButton::run_button_up(void) {
|
|||||||
gui_cat->debug() << "doing work" << endl;
|
gui_cat->debug() << "doing work" << endl;
|
||||||
_eh->remove_hook(_up_event, GuiButton::behavior_up, (void*)this);
|
_eh->remove_hook(_up_event, GuiButton::behavior_up, (void*)this);
|
||||||
_eh->remove_hook(_up_rollover_event, GuiButton::behavior_up, (void*)this);
|
_eh->remove_hook(_up_rollover_event, GuiButton::behavior_up, (void*)this);
|
||||||
if (!_behavior_event.empty())
|
if (!_behavior_event.empty()) {
|
||||||
throw_event(_behavior_event);
|
if (_have_event_param)
|
||||||
|
throw_event(_behavior_event, EventParameter(_event_param));
|
||||||
|
else
|
||||||
|
throw_event(_behavior_event);
|
||||||
|
}
|
||||||
if (_behavior_functor != (GuiBehavior::BehaviorFunctor*)0L)
|
if (_behavior_functor != (GuiBehavior::BehaviorFunctor*)0L)
|
||||||
_behavior_functor->doit(this);
|
_behavior_functor->doit(this);
|
||||||
}
|
}
|
||||||
@ -348,7 +352,7 @@ GuiButton::GuiButton(const string& name, GuiLabel* up, GuiLabel* down)
|
|||||||
_down_event(name +"-down"), _down_rollover_event(""),
|
_down_event(name +"-down"), _down_rollover_event(""),
|
||||||
_inactive_event(""), _up_scale(up->get_scale()), _upr_scale(1.),
|
_inactive_event(""), _up_scale(up->get_scale()), _upr_scale(1.),
|
||||||
_down_scale(down->get_scale()), _downr_scale(1.), _inactive_scale(1.),
|
_down_scale(down->get_scale()), _downr_scale(1.), _inactive_scale(1.),
|
||||||
_state(GuiButton::NONE),
|
_state(GuiButton::NONE), _have_event_param(false), _event_param(0),
|
||||||
_behavior_functor((GuiBehavior::BehaviorFunctor*)0L) {
|
_behavior_functor((GuiBehavior::BehaviorFunctor*)0L) {
|
||||||
GetExtents(up, down, _up_rollover, _down_rollover, _inactive, _left, _right,
|
GetExtents(up, down, _up_rollover, _down_rollover, _inactive, _left, _right,
|
||||||
_bottom, _top);
|
_bottom, _top);
|
||||||
@ -372,6 +376,7 @@ GuiButton::GuiButton(const string& name, GuiLabel* up, GuiLabel* down,
|
|||||||
_inactive_event(name + "-inactive"), _up_scale(up->get_scale()),
|
_inactive_event(name + "-inactive"), _up_scale(up->get_scale()),
|
||||||
_upr_scale(1.), _down_scale(down->get_scale()), _downr_scale(1.),
|
_upr_scale(1.), _down_scale(down->get_scale()), _downr_scale(1.),
|
||||||
_inactive_scale(inactive->get_scale()), _state(GuiButton::NONE),
|
_inactive_scale(inactive->get_scale()), _state(GuiButton::NONE),
|
||||||
|
_have_event_param(false), _event_param(0),
|
||||||
_behavior_functor((GuiBehavior::BehaviorFunctor*)0L) {
|
_behavior_functor((GuiBehavior::BehaviorFunctor*)0L) {
|
||||||
GetExtents(up, down, _up_rollover, _down_rollover, inactive, _left, _right,
|
GetExtents(up, down, _up_rollover, _down_rollover, inactive, _left, _right,
|
||||||
_bottom, _top);
|
_bottom, _top);
|
||||||
@ -396,6 +401,7 @@ GuiButton::GuiButton(const string& name, GuiLabel* up, GuiLabel* up_roll,
|
|||||||
_upr_scale(up_roll->get_scale()), _down_scale(down->get_scale()),
|
_upr_scale(up_roll->get_scale()), _down_scale(down->get_scale()),
|
||||||
_downr_scale(down_roll->get_scale()),
|
_downr_scale(down_roll->get_scale()),
|
||||||
_inactive_scale(inactive->get_scale()), _state(GuiButton::NONE),
|
_inactive_scale(inactive->get_scale()), _state(GuiButton::NONE),
|
||||||
|
_have_event_param(false), _event_param(0),
|
||||||
_behavior_functor((GuiBehavior::BehaviorFunctor*)0L) {
|
_behavior_functor((GuiBehavior::BehaviorFunctor*)0L) {
|
||||||
GetExtents(up, down, up_roll, down_roll, inactive, _left, _right, _bottom,
|
GetExtents(up, down, up_roll, down_roll, inactive, _left, _right, _bottom,
|
||||||
_top);
|
_top);
|
||||||
|
@ -33,6 +33,8 @@ private:
|
|||||||
States _state;
|
States _state;
|
||||||
|
|
||||||
string _behavior_event;
|
string _behavior_event;
|
||||||
|
bool _have_event_param;
|
||||||
|
int _event_param;
|
||||||
GuiBehavior::BehaviorFunctor* _behavior_functor;
|
GuiBehavior::BehaviorFunctor* _behavior_functor;
|
||||||
|
|
||||||
INLINE GuiButton(void);
|
INLINE GuiButton(void);
|
||||||
@ -91,6 +93,9 @@ PUBLISHED:
|
|||||||
INLINE void set_behavior_functor(GuiBehavior::BehaviorFunctor*);
|
INLINE void set_behavior_functor(GuiBehavior::BehaviorFunctor*);
|
||||||
INLINE GuiBehavior::BehaviorFunctor* get_behavior_functor(void) const;
|
INLINE GuiBehavior::BehaviorFunctor* get_behavior_functor(void) const;
|
||||||
|
|
||||||
|
INLINE void set_behavior_event_parameter(int);
|
||||||
|
INLINE int get_behavior_event_parameter(void) const;
|
||||||
|
|
||||||
virtual void set_scale(float);
|
virtual void set_scale(float);
|
||||||
virtual void set_scale(float, float, float);
|
virtual void set_scale(float, float, float);
|
||||||
virtual void set_pos(const LVector3f&);
|
virtual void set_pos(const LVector3f&);
|
||||||
|
@ -278,9 +278,12 @@ void GuiListBox::set_scale(float f) {
|
|||||||
for (ItemDeque::iterator j=_bottom_stack.begin(); j!=_bottom_stack.end();
|
for (ItemDeque::iterator j=_bottom_stack.begin(); j!=_bottom_stack.end();
|
||||||
++j)
|
++j)
|
||||||
(*j)->set_scale(f);
|
(*j)->set_scale(f);
|
||||||
|
/*
|
||||||
_up_arrow->set_scale(f);
|
_up_arrow->set_scale(f);
|
||||||
_down_arrow->set_scale(f);
|
_down_arrow->set_scale(f);
|
||||||
|
*/
|
||||||
GuiBehavior::set_scale(f);
|
GuiBehavior::set_scale(f);
|
||||||
|
this->recompute_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiListBox::set_scale(float x, float y, float z) {
|
void GuiListBox::set_scale(float x, float y, float z) {
|
||||||
@ -292,12 +295,16 @@ void GuiListBox::set_scale(float x, float y, float z) {
|
|||||||
for (ItemDeque::iterator j=_bottom_stack.begin(); j!=_bottom_stack.end();
|
for (ItemDeque::iterator j=_bottom_stack.begin(); j!=_bottom_stack.end();
|
||||||
++j)
|
++j)
|
||||||
(*j)->set_scale(x, y, z);
|
(*j)->set_scale(x, y, z);
|
||||||
|
/*
|
||||||
_up_arrow->set_scale(x, y, z);
|
_up_arrow->set_scale(x, y, z);
|
||||||
_down_arrow->set_scale(x, y, z);
|
_down_arrow->set_scale(x, y, z);
|
||||||
|
*/
|
||||||
GuiBehavior::set_scale(x, y, z);
|
GuiBehavior::set_scale(x, y, z);
|
||||||
|
this->recompute_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiListBox::set_pos(const LVector3f& p) {
|
void GuiListBox::set_pos(const LVector3f& p) {
|
||||||
|
/*
|
||||||
ItemVector::iterator i;
|
ItemVector::iterator i;
|
||||||
for (i=_top_stack.begin(); i!=_top_stack.end(); ++i)
|
for (i=_top_stack.begin(); i!=_top_stack.end(); ++i)
|
||||||
(*i)->set_pos(p);
|
(*i)->set_pos(p);
|
||||||
@ -306,9 +313,13 @@ void GuiListBox::set_pos(const LVector3f& p) {
|
|||||||
for (ItemDeque::iterator j=_bottom_stack.begin(); j!=_bottom_stack.end();
|
for (ItemDeque::iterator j=_bottom_stack.begin(); j!=_bottom_stack.end();
|
||||||
++j)
|
++j)
|
||||||
(*j)->set_pos(p);
|
(*j)->set_pos(p);
|
||||||
|
*/
|
||||||
|
/*
|
||||||
_up_arrow->set_pos(p);
|
_up_arrow->set_pos(p);
|
||||||
_down_arrow->set_pos(p);
|
_down_arrow->set_pos(p);
|
||||||
|
*/
|
||||||
GuiBehavior::set_pos(p);
|
GuiBehavior::set_pos(p);
|
||||||
|
this->recompute_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiListBox::start_behavior(void) {
|
void GuiListBox::start_behavior(void) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user