mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 18:03:56 -04:00
make the next/prev work
This commit is contained in:
parent
35ae45755e
commit
d2767605e3
@ -4,3 +4,11 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
INLINE GuiChooser::GuiChooser(void) {}
|
||||
|
||||
INLINE void GuiChooser::set_loop(bool b) {
|
||||
_loop = b;
|
||||
}
|
||||
|
||||
INLINE bool GuiChooser::get_loop(void) const {
|
||||
return _loop;
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ void GuiChooser::recompute_frame(void) {
|
||||
}
|
||||
|
||||
GuiChooser::GuiChooser(const string& name, GuiButton* prev, GuiButton* next)
|
||||
: GuiBehavior(name), _curr(-1), _prev_button(prev), _next_button(next),
|
||||
_prev_functor((GuiChooser::ChooseFunctor*)0L),
|
||||
: GuiBehavior(name), _curr(-1), _loop(false), _prev_button(prev),
|
||||
_next_button(next), _prev_functor((GuiChooser::ChooseFunctor*)0L),
|
||||
_next_functor((GuiChooser::ChooseFunctor*)0L) {
|
||||
}
|
||||
|
||||
@ -38,14 +38,55 @@ GuiChooser::~GuiChooser(void) {
|
||||
void GuiChooser::move_prev(void) {
|
||||
if (_curr == -1)
|
||||
return;
|
||||
int tmp = _curr - 1;
|
||||
if (_loop) {
|
||||
if (tmp < 0)
|
||||
tmp += _items.size();
|
||||
}
|
||||
if (_mgr != (GuiManager*)0L) {
|
||||
_items[_curr]->unmanage();
|
||||
_items[tmp]->manage(_mgr, *_eh);
|
||||
if (tmp == 0)
|
||||
_prev_button->inactive();
|
||||
else
|
||||
_prev_button->up();
|
||||
int foo = _items.size() - 1;
|
||||
if (tmp == foo)
|
||||
_next_button->inactive();
|
||||
else
|
||||
_next_button->up();
|
||||
}
|
||||
_curr = tmp;
|
||||
}
|
||||
|
||||
void GuiChooser::move_next(void) {
|
||||
if (_curr == -1)
|
||||
return;
|
||||
int tmp = _curr + 1;
|
||||
if (_loop) {
|
||||
int foo = _items.size();
|
||||
if (tmp == foo)
|
||||
tmp = 0;
|
||||
}
|
||||
if (_mgr != (GuiManager*)0L) {
|
||||
_items[_curr]->unmanage();
|
||||
_items[tmp]->manage(_mgr, *_eh);
|
||||
if (tmp == 0)
|
||||
_prev_button->inactive();
|
||||
else
|
||||
_prev_button->up();
|
||||
if (tmp == (_items.size() - 1))
|
||||
_next_button->inactive();
|
||||
else
|
||||
_next_button->up();
|
||||
}
|
||||
_curr = tmp;
|
||||
}
|
||||
|
||||
void GuiChooser::add_item(GuiItem* item) {
|
||||
_items.push_back(item);
|
||||
if (_curr == -1)
|
||||
_curr = 0;
|
||||
}
|
||||
|
||||
int GuiChooser::freeze(void) {
|
||||
|
@ -32,6 +32,7 @@ private:
|
||||
|
||||
ItemVector _items;
|
||||
int _curr;
|
||||
bool _loop;
|
||||
PT(GuiButton) _prev_button;
|
||||
PT(GuiButton) _next_button;
|
||||
|
||||
@ -62,6 +63,9 @@ PUBLISHED:
|
||||
virtual void reset_behavior(void);
|
||||
|
||||
virtual void output(ostream&) const;
|
||||
|
||||
INLINE void set_loop(bool);
|
||||
INLINE bool get_loop(void) const;
|
||||
public:
|
||||
// type interface
|
||||
static TypeHandle get_class_type(void) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user