From fcd294217fdc8723d17a8ff8c7d41f1870f504c8 Mon Sep 17 00:00:00 2001 From: Cary Sandvig Date: Thu, 15 Feb 2001 00:30:45 +0000 Subject: [PATCH] can anyone have this much fun? --- panda/src/gui/guiItem.cxx | 1 + panda/src/gui/guiLabel.cxx | 4 ++ panda/src/gui/guiListBox.cxx | 35 ++++++++++++++++- panda/src/gui/guiSign.cxx | 2 + panda/src/testbed/gui_demo.cxx | 69 +++++++++++++++++++++++++++++++--- 5 files changed, 103 insertions(+), 8 deletions(-) diff --git a/panda/src/gui/guiItem.cxx b/panda/src/gui/guiItem.cxx index 5277eaedf5..4f01c0f40e 100644 --- a/panda/src/gui/guiItem.cxx +++ b/panda/src/gui/guiItem.cxx @@ -29,6 +29,7 @@ int GuiItem::freeze() { } int GuiItem::thaw() { + gui_cat->debug() << "GuiItem::thaw" << endl; return 0; } diff --git a/panda/src/gui/guiLabel.cxx b/panda/src/gui/guiLabel.cxx index 9f5fb891ed..045d79ee79 100644 --- a/panda/src/gui/guiLabel.cxx +++ b/panda/src/gui/guiLabel.cxx @@ -220,6 +220,8 @@ int GuiLabel::freeze() { switch (_type) { case SIMPLE_TEXT: { + gui_cat->debug() << "GuiLabel:: freezing text node (0x" << (void*)this + << ")" << endl; TextNode* n = DCAST(TextNode, _geom); return n->freeze(); } @@ -233,6 +235,8 @@ int GuiLabel::thaw() { switch (_type) { case SIMPLE_TEXT: { + gui_cat->debug() << "GuiLabel:: thawing text node (0x" << (void*)this + << ")" << endl; TextNode* n = DCAST(TextNode, _geom); return n->thaw(); } diff --git a/panda/src/gui/guiListBox.cxx b/panda/src/gui/guiListBox.cxx index a21153e113..93cf85a046 100644 --- a/panda/src/gui/guiListBox.cxx +++ b/panda/src/gui/guiListBox.cxx @@ -43,6 +43,9 @@ void GuiListBox::recompute_frame(void) { btm = frm[2]; if (frm[3] > tp) tp = frm[3]; + (*i)->freeze(); + gui_cat->debug() << "in recompute: freeze lvl (" << (*i)->get_name() + << ") = " << (*i)->thaw() << endl; } _left = lft; _right = rgt; @@ -65,7 +68,8 @@ void GuiListBox::visible_patching(void) { _arrow_top = false; _visible[0]->unmanage(); _visible[0] = *(_top_stack.begin()); - _visible[0]->manage(_mgr, *_eh); + if (_mgr != (GuiManager*)0L) + _visible[0]->manage(_mgr, *_eh); _top_stack.pop_back(); } } else { @@ -76,7 +80,8 @@ void GuiListBox::visible_patching(void) { _visible[0]->unmanage(); _top_stack.push_back(_visible[0]); _visible[0] = _up_arrow; - _up_arrow->manage(_mgr, *_eh); + if (_mgr != (GuiManager*)0L) + _up_arrow->manage(_mgr, *_eh); } } @@ -198,15 +203,28 @@ int GuiListBox::freeze(void) { ItemVector::iterator i; ItemDeque::iterator j; + gui_cat->debug() << "GuiListBox::freeze()" << endl; for (i=_top_stack.begin(); i!=_top_stack.end(); ++i) { + if (*i == _up_arrow) + continue; + if (*i == _down_arrow) + continue; int count = (*i)->freeze(); result = max(result, count); } for (i=_visible.begin(); i!=_visible.end(); ++i) { + if (*i == _up_arrow) + continue; + if (*i == _down_arrow) + continue; int count = (*i)->freeze(); result = max(result, count); } for (j=_bottom_stack.begin(); j!=_bottom_stack.end(); ++j) { + if (*j == _up_arrow) + continue; + if (*j == _down_arrow) + continue; int count = (*j)->freeze(); result = max(result, count); } @@ -220,15 +238,28 @@ int GuiListBox::thaw(void) { ItemVector::iterator i; ItemDeque::iterator j; + gui_cat->debug() << "GuiListBox::thaw()" << endl; for (i=_top_stack.begin(); i!=_top_stack.end(); ++i) { + if (*i == _up_arrow) + continue; + if (*i == _down_arrow) + continue; int count = (*i)->thaw(); result = max(result, count); } for (i=_visible.begin(); i!=_visible.end(); ++i) { + if (*i == _up_arrow) + continue; + if (*i == _down_arrow) + continue; int count = (*i)->thaw(); result = max(result, count); } for (j=_bottom_stack.begin(); j!=_bottom_stack.end(); ++j) { + if (*j == _up_arrow) + continue; + if (*j == _down_arrow) + continue; int count = (*j)->thaw(); result = max(result, count); } diff --git a/panda/src/gui/guiSign.cxx b/panda/src/gui/guiSign.cxx index 75fcae9da1..2736c2ca1b 100644 --- a/panda/src/gui/guiSign.cxx +++ b/panda/src/gui/guiSign.cxx @@ -41,10 +41,12 @@ void GuiSign::unmanage(void) { } int GuiSign::freeze() { + gui_cat->debug() << "GuiSign::freeze (" << this->get_name() << ")" << endl; return _sign->freeze(); } int GuiSign::thaw() { + gui_cat->debug() << "GuiSign::thaw (" << this->get_name() << ")" << endl; return _sign->thaw(); } diff --git a/panda/src/testbed/gui_demo.cxx b/panda/src/testbed/gui_demo.cxx index f5cf8b17c4..623c4c8667 100644 --- a/panda/src/testbed/gui_demo.cxx +++ b/panda/src/testbed/gui_demo.cxx @@ -654,7 +654,7 @@ static void test12(GuiManager* mgr, Node* font) { GuiLabel* l3 = GuiLabel::make_simple_text_label("down", font); GuiLabel* l4 = GuiLabel::make_simple_text_label("downr", font); GuiLabel* l5 = GuiLabel::make_simple_text_label("none", font); - GuiButton* b1 = new GuiButton("test3", l1, l2, l3, l4, l5); + GuiButton* b1 = new GuiButton("test12", l1, l2, l3, l4, l5); b1->set_scale(0.1); b1->set_pos(LVector3f::rfu(-0.25, 0., 0.25)); l2->set_foreground_color(1., 1., 0., 1.); @@ -669,6 +669,61 @@ static void test12(GuiManager* mgr, Node* font) { b1->start_behavior(); } +static void test13(GuiManager* mgr, Node* font) { + GuiLabel* ul = GuiLabel::make_simple_text_label("upup", font); + GuiSign* us = new GuiSign("up_arrow", ul); + us->set_scale(0.1); + GuiLabel* dl = GuiLabel::make_simple_text_label("dndn", font); + GuiSign* ds = new GuiSign("down_arrow", dl); + dl->set_scale(0.1); + lb1 = new GuiListBox("list_box", 4, us, ds); + GuiLabel* l1 = GuiLabel::make_simple_text_label("hyena", font); + GuiSign* s1 = new GuiSign("hyena", l1); + s1->set_scale(0.1); + GuiLabel* l2 = GuiLabel::make_simple_text_label("dingo", font); + GuiSign* s2 = new GuiSign("dingo", l2); + s2->set_scale(0.1); + GuiLabel* l3 = GuiLabel::make_simple_text_label("jackal", font); + GuiSign* s3 = new GuiSign("jackal", l3); + s3->set_scale(0.1); + GuiLabel* l4 = GuiLabel::make_simple_text_label("wolf", font); + GuiSign* s4 = new GuiSign("wolf", l4); + s4->set_scale(0.1); + GuiLabel* l5 = GuiLabel::make_simple_text_label("fox", font); + GuiSign* s5 = new GuiSign("fox", l5); + s5->set_scale(0.1); + float w, w1, w2; + w1 = l1->get_width(); + w2 = l2->get_width(); + w = (w1>w2)?w1:w2; + w2 = l3->get_width(); + w = (w>w2)?w:w2; + w2 = l4->get_width(); + w = (w>w2)?w:w2; + w2 = l5->get_width(); + w = (w>w2)?w:w2; + l1->set_width(w); + l2->set_width(w); + l3->set_width(w); + l4->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(s2); + lb1->add_item(s3); + lb1->add_item(s4); + lb1->add_item(s5); + lb1->thaw(); + lb1->recompute(); + lb1->manage(mgr, event_handler); +} + static void setup_gui(void) { GuiManager* mgr = GuiManager::get_ptr(main_win, mak, (Node*)0L); PT_Node font = ModelPool::load_model("ttf-comic"); @@ -696,9 +751,11 @@ static void setup_gui(void) { // test 10 // test10(mgr, font); // test 11 - test11(mgr, font); + // test11(mgr, font); // test 12 // test12(mgr, font); + // test 13 + test13(mgr, font); } static void event_2(CPT_Event) { @@ -778,13 +835,13 @@ static void event_3(CPT_Event) { } */ -// for test 11 +// for test 11, 13 static void event_3(CPT_Event) { lb1->scroll_up(); cout << *lb1; } -// for test11 +// for test11, 13 static void event_4(CPT_Event) { lb1->scroll_down(); cout << *lb1; @@ -799,9 +856,9 @@ void gui_keys(EventHandler&) { have_dlight = true; event_handler.add_hook("2", event_2); - // for tests 7-11 + // for tests 7-11, 13 event_handler.add_hook("3", event_3); - // for test 11 + // for test 11, 13 event_handler.add_hook("4", event_4); event_handler.add_hook("demo-event-thing", event_demo); }