mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
make it work correctly
This commit is contained in:
parent
0793b1b516
commit
cbb54dbade
@ -24,6 +24,7 @@ void GuiListBox::ListFunctor::doit(GuiBehavior* b) {
|
|||||||
|
|
||||||
void GuiListBox::recompute_frame(void) {
|
void GuiListBox::recompute_frame(void) {
|
||||||
GuiBehavior::recompute_frame();
|
GuiBehavior::recompute_frame();
|
||||||
|
this->freeze();
|
||||||
LVector3f p = _pos;
|
LVector3f p = _pos;
|
||||||
float lft = 100000.;
|
float lft = 100000.;
|
||||||
float rgt = -100000.;
|
float rgt = -100000.;
|
||||||
@ -31,7 +32,7 @@ void GuiListBox::recompute_frame(void) {
|
|||||||
float btm = 100000.;
|
float btm = 100000.;
|
||||||
LVector4f frm;
|
LVector4f frm;
|
||||||
for (ItemVector::iterator i=_visible.begin(); i!=_visible.end();
|
for (ItemVector::iterator i=_visible.begin(); i!=_visible.end();
|
||||||
p+=((*i)->get_height() * LVector3f::up()), ++i) {
|
p-=((*i)->get_height() * LVector3f::up()), ++i) {
|
||||||
(*i)->set_pos(p);
|
(*i)->set_pos(p);
|
||||||
frm = (*i)->get_frame();
|
frm = (*i)->get_frame();
|
||||||
if (frm[0] < lft)
|
if (frm[0] < lft)
|
||||||
@ -47,6 +48,7 @@ void GuiListBox::recompute_frame(void) {
|
|||||||
_right = rgt;
|
_right = rgt;
|
||||||
_top = tp;
|
_top = tp;
|
||||||
_bottom = btm;
|
_bottom = btm;
|
||||||
|
this->thaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiListBox::visible_patching(void) {
|
void GuiListBox::visible_patching(void) {
|
||||||
@ -193,26 +195,51 @@ void GuiListBox::add_item(GuiItem* item) {
|
|||||||
|
|
||||||
int GuiListBox::freeze(void) {
|
int GuiListBox::freeze(void) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
ItemVector::iterator i;
|
||||||
|
ItemDeque::iterator j;
|
||||||
|
|
||||||
for (ItemVector::iterator i=_visible.begin(); i!=_visible.end(); ++i) {
|
for (i=_top_stack.begin(); i!=_top_stack.end(); ++i) {
|
||||||
int count = (*i)->freeze();
|
int count = (*i)->freeze();
|
||||||
result = max(result, count);
|
result = max(result, count);
|
||||||
}
|
}
|
||||||
|
for (i=_visible.begin(); i!=_visible.end(); ++i) {
|
||||||
|
int count = (*i)->freeze();
|
||||||
|
result = max(result, count);
|
||||||
|
}
|
||||||
|
for (j=_bottom_stack.begin(); j!=_bottom_stack.end(); ++j) {
|
||||||
|
int count = (*j)->freeze();
|
||||||
|
result = max(result, count);
|
||||||
|
}
|
||||||
|
_up_arrow->freeze();
|
||||||
|
_down_arrow->freeze();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GuiListBox::thaw(void) {
|
int GuiListBox::thaw(void) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
ItemVector::iterator i;
|
||||||
|
ItemDeque::iterator j;
|
||||||
|
|
||||||
for (ItemVector::iterator i=_visible.begin(); i!=_visible.end(); ++i) {
|
for (i=_top_stack.begin(); i!=_top_stack.end(); ++i) {
|
||||||
int count = (*i)->thaw();
|
int count = (*i)->thaw();
|
||||||
result = max(result, count);
|
result = max(result, count);
|
||||||
}
|
}
|
||||||
|
for (i=_visible.begin(); i!=_visible.end(); ++i) {
|
||||||
|
int count = (*i)->thaw();
|
||||||
|
result = max(result, count);
|
||||||
|
}
|
||||||
|
for (j=_bottom_stack.begin(); j!=_bottom_stack.end(); ++j) {
|
||||||
|
int count = (*j)->thaw();
|
||||||
|
result = max(result, count);
|
||||||
|
}
|
||||||
|
_up_arrow->thaw();
|
||||||
|
_down_arrow->thaw();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiListBox::manage(GuiManager* mgr, EventHandler& eh) {
|
void GuiListBox::manage(GuiManager* mgr, EventHandler& eh) {
|
||||||
if (_mgr == (GuiManager*)0L) {
|
if (_mgr == (GuiManager*)0L) {
|
||||||
|
this->recompute_frame();
|
||||||
for (ItemVector::iterator i=_visible.begin(); i!=_visible.end(); ++i)
|
for (ItemVector::iterator i=_visible.begin(); i!=_visible.end(); ++i)
|
||||||
(*i)->manage(mgr, eh);
|
(*i)->manage(mgr, eh);
|
||||||
GuiBehavior::manage(mgr, eh);
|
GuiBehavior::manage(mgr, eh);
|
||||||
@ -331,14 +358,14 @@ void GuiListBox::output(ostream& os) const {
|
|||||||
os << " Top stack (" << _top_stack.size() << "):" << endl;
|
os << " Top stack (" << _top_stack.size() << "):" << endl;
|
||||||
ItemVector::const_iterator i;
|
ItemVector::const_iterator i;
|
||||||
for (i=_top_stack.begin(); i!=_top_stack.end(); ++i)
|
for (i=_top_stack.begin(); i!=_top_stack.end(); ++i)
|
||||||
os << " 0x" << (void*)(*i) << endl;
|
os << " 0x" << (void*)(*i) << " (" << (*i)->get_name() << ")" << endl;
|
||||||
os << " Visible (" << _visible.size() << "):" << endl;
|
os << " Visible (" << _visible.size() << "):" << endl;
|
||||||
for (i=_visible.begin(); i!=_visible.end(); ++i)
|
for (i=_visible.begin(); i!=_visible.end(); ++i)
|
||||||
os << " 0x" << (void*)(*i) << endl;
|
os << " 0x" << (void*)(*i) << " (" << (*i)->get_name() << ")" << endl;
|
||||||
os << " Bottom stack (" << _bottom_stack.size() << "):" << endl;
|
os << " Bottom stack (" << _bottom_stack.size() << "):" << endl;
|
||||||
ItemDeque::const_iterator j;
|
ItemDeque::const_iterator j;
|
||||||
for (j=_bottom_stack.begin(); j!=_bottom_stack.end(); ++j)
|
for (j=_bottom_stack.begin(); j!=_bottom_stack.end(); ++j)
|
||||||
os << " 0x" << (void*)(*j) << endl;
|
os << " 0x" << (void*)(*j) << " (" << (*j)->get_name() << ")" << endl;
|
||||||
for (i=_top_stack.begin(); i!=_top_stack.end(); ++i)
|
for (i=_top_stack.begin(); i!=_top_stack.end(); ++i)
|
||||||
os << *(*i);
|
os << *(*i);
|
||||||
for (i=_visible.begin(); i!=_visible.end(); ++i)
|
for (i=_visible.begin(); i!=_visible.end(); ++i)
|
||||||
|
@ -596,8 +596,10 @@ PT(GuiListBox) lb1;
|
|||||||
static void test11(GuiManager* mgr, Node* font) {
|
static void test11(GuiManager* mgr, Node* font) {
|
||||||
GuiLabel* ul = GuiLabel::make_simple_text_label("upup", font);
|
GuiLabel* ul = GuiLabel::make_simple_text_label("upup", font);
|
||||||
GuiSign* us = new GuiSign("up_arrow", ul);
|
GuiSign* us = new GuiSign("up_arrow", ul);
|
||||||
|
us->set_scale(0.1);
|
||||||
GuiLabel* dl = GuiLabel::make_simple_text_label("dndn", font);
|
GuiLabel* dl = GuiLabel::make_simple_text_label("dndn", font);
|
||||||
GuiSign* ds = new GuiSign("down_arrow", dl);
|
GuiSign* ds = new GuiSign("down_arrow", dl);
|
||||||
|
ds->set_scale(0.1);
|
||||||
lb1 = new GuiListBox("list_box", 4, us, ds);
|
lb1 = new GuiListBox("list_box", 4, us, ds);
|
||||||
GuiLabel* l1 = GuiLabel::make_simple_text_label("hyena", font);
|
GuiLabel* l1 = GuiLabel::make_simple_text_label("hyena", font);
|
||||||
GuiSign* s1 = new GuiSign("hyena", l1);
|
GuiSign* s1 = new GuiSign("hyena", l1);
|
||||||
@ -629,6 +631,13 @@ static void test11(GuiManager* mgr, Node* font) {
|
|||||||
l3->set_width(w);
|
l3->set_width(w);
|
||||||
l4->set_width(w);
|
l4->set_width(w);
|
||||||
l5->set_width(w);
|
l5->set_width(w);
|
||||||
|
ul->set_background_color(0., 0., 0., 1.);
|
||||||
|
dl->set_background_color(0., 0., 0., 1.);
|
||||||
|
l1->set_background_color(0., 0., 0., 1.);
|
||||||
|
l2->set_background_color(0., 0., 0., 1.);
|
||||||
|
l3->set_background_color(0., 0., 0., 1.);
|
||||||
|
l4->set_background_color(0., 0., 0., 1.);
|
||||||
|
l5->set_background_color(0., 0., 0., 1.);
|
||||||
lb1->add_item(s1);
|
lb1->add_item(s1);
|
||||||
lb1->add_item(s2);
|
lb1->add_item(s2);
|
||||||
lb1->add_item(s3);
|
lb1->add_item(s3);
|
||||||
@ -636,6 +645,7 @@ static void test11(GuiManager* mgr, Node* font) {
|
|||||||
lb1->add_item(s5);
|
lb1->add_item(s5);
|
||||||
lb1->thaw();
|
lb1->thaw();
|
||||||
lb1->manage(mgr, event_handler);
|
lb1->manage(mgr, event_handler);
|
||||||
|
cout << *lb1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test12(GuiManager* mgr, Node* font) {
|
static void test12(GuiManager* mgr, Node* font) {
|
||||||
@ -686,9 +696,9 @@ static void setup_gui(void) {
|
|||||||
// test 10
|
// test 10
|
||||||
// test10(mgr, font);
|
// test10(mgr, font);
|
||||||
// test 11
|
// test 11
|
||||||
// test11(mgr, font);
|
test11(mgr, font);
|
||||||
// test 12
|
// test 12
|
||||||
test12(mgr, font);
|
// test12(mgr, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void event_2(CPT_Event) {
|
static void event_2(CPT_Event) {
|
||||||
@ -789,12 +799,10 @@ void gui_keys(EventHandler&) {
|
|||||||
have_dlight = true;
|
have_dlight = true;
|
||||||
|
|
||||||
event_handler.add_hook("2", event_2);
|
event_handler.add_hook("2", event_2);
|
||||||
/*
|
|
||||||
// for tests 7-11
|
// for tests 7-11
|
||||||
event_handler.add_hook("3", event_3);
|
event_handler.add_hook("3", event_3);
|
||||||
// for test 11
|
// for test 11
|
||||||
event_handler.add_hook("4", event_4);
|
event_handler.add_hook("4", event_4);
|
||||||
*/
|
|
||||||
event_handler.add_hook("demo-event-thing", event_demo);
|
event_handler.add_hook("demo-event-thing", event_demo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user