diff --git a/panda/src/gui/guiButton.I b/panda/src/gui/guiButton.I index d8e84b8579..b9fce99de3 100644 --- a/panda/src/gui/guiButton.I +++ b/panda/src/gui/guiButton.I @@ -231,3 +231,12 @@ INLINE GuiBehavior::BehaviorFunctor* GuiButton::get_behavior_functor(void) const { 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; +} diff --git a/panda/src/gui/guiButton.cxx b/panda/src/gui/guiButton.cxx index 24531e279d..ec7d7ba6d9 100644 --- a/panda/src/gui/guiButton.cxx +++ b/panda/src/gui/guiButton.cxx @@ -324,8 +324,12 @@ void GuiButton::run_button_up(void) { gui_cat->debug() << "doing work" << endl; _eh->remove_hook(_up_event, GuiButton::behavior_up, (void*)this); _eh->remove_hook(_up_rollover_event, GuiButton::behavior_up, (void*)this); - if (!_behavior_event.empty()) - throw_event(_behavior_event); + if (!_behavior_event.empty()) { + if (_have_event_param) + throw_event(_behavior_event, EventParameter(_event_param)); + else + throw_event(_behavior_event); + } if (_behavior_functor != (GuiBehavior::BehaviorFunctor*)0L) _behavior_functor->doit(this); } @@ -348,7 +352,7 @@ GuiButton::GuiButton(const string& name, GuiLabel* up, GuiLabel* down) _down_event(name +"-down"), _down_rollover_event(""), _inactive_event(""), _up_scale(up->get_scale()), _upr_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) { GetExtents(up, down, _up_rollover, _down_rollover, _inactive, _left, _right, _bottom, _top); @@ -372,6 +376,7 @@ GuiButton::GuiButton(const string& name, GuiLabel* up, GuiLabel* down, _inactive_event(name + "-inactive"), _up_scale(up->get_scale()), _upr_scale(1.), _down_scale(down->get_scale()), _downr_scale(1.), _inactive_scale(inactive->get_scale()), _state(GuiButton::NONE), + _have_event_param(false), _event_param(0), _behavior_functor((GuiBehavior::BehaviorFunctor*)0L) { GetExtents(up, down, _up_rollover, _down_rollover, inactive, _left, _right, _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()), _downr_scale(down_roll->get_scale()), _inactive_scale(inactive->get_scale()), _state(GuiButton::NONE), + _have_event_param(false), _event_param(0), _behavior_functor((GuiBehavior::BehaviorFunctor*)0L) { GetExtents(up, down, up_roll, down_roll, inactive, _left, _right, _bottom, _top); diff --git a/panda/src/gui/guiButton.h b/panda/src/gui/guiButton.h index 09063d93e9..208f3f64b1 100644 --- a/panda/src/gui/guiButton.h +++ b/panda/src/gui/guiButton.h @@ -33,6 +33,8 @@ private: States _state; string _behavior_event; + bool _have_event_param; + int _event_param; GuiBehavior::BehaviorFunctor* _behavior_functor; INLINE GuiButton(void); @@ -91,6 +93,9 @@ PUBLISHED: INLINE void set_behavior_functor(GuiBehavior::BehaviorFunctor*); 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, float, float); virtual void set_pos(const LVector3f&); diff --git a/panda/src/gui/guiListBox.cxx b/panda/src/gui/guiListBox.cxx index 54f7c83b80..5d685ac5b5 100644 --- a/panda/src/gui/guiListBox.cxx +++ b/panda/src/gui/guiListBox.cxx @@ -278,9 +278,12 @@ void GuiListBox::set_scale(float f) { for (ItemDeque::iterator j=_bottom_stack.begin(); j!=_bottom_stack.end(); ++j) (*j)->set_scale(f); + /* _up_arrow->set_scale(f); _down_arrow->set_scale(f); + */ GuiBehavior::set_scale(f); + this->recompute_frame(); } 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(); ++j) (*j)->set_scale(x, y, z); + /* _up_arrow->set_scale(x, y, z); _down_arrow->set_scale(x, y, z); + */ GuiBehavior::set_scale(x, y, z); + this->recompute_frame(); } void GuiListBox::set_pos(const LVector3f& p) { + /* ItemVector::iterator i; for (i=_top_stack.begin(); i!=_top_stack.end(); ++i) (*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(); ++j) (*j)->set_pos(p); + */ + /* _up_arrow->set_pos(p); _down_arrow->set_pos(p); + */ GuiBehavior::set_pos(p); + this->recompute_frame(); } void GuiListBox::start_behavior(void) {