Browse Source

can anyone have this much fun?

Cary Sandvig 25 years ago
parent
commit
fcd294217f

+ 1 - 0
panda/src/gui/guiItem.cxx

@@ -29,6 +29,7 @@ int GuiItem::freeze() {
 }
 }
 
 
 int GuiItem::thaw() {
 int GuiItem::thaw() {
+  gui_cat->debug() << "GuiItem::thaw" << endl;
   return 0;
   return 0;
 }
 }
 
 

+ 4 - 0
panda/src/gui/guiLabel.cxx

@@ -220,6 +220,8 @@ int GuiLabel::freeze() {
   switch (_type) {
   switch (_type) {
   case SIMPLE_TEXT:
   case SIMPLE_TEXT:
     {
     {
+      gui_cat->debug() << "GuiLabel:: freezing text node (0x" << (void*)this
+		       << ")" << endl;
       TextNode* n = DCAST(TextNode, _geom);
       TextNode* n = DCAST(TextNode, _geom);
       return n->freeze();
       return n->freeze();
     }
     }
@@ -233,6 +235,8 @@ int GuiLabel::thaw() {
   switch (_type) {
   switch (_type) {
   case SIMPLE_TEXT:
   case SIMPLE_TEXT:
     {
     {
+      gui_cat->debug() << "GuiLabel:: thawing text node (0x" << (void*)this
+		       << ")" << endl;
       TextNode* n = DCAST(TextNode, _geom);
       TextNode* n = DCAST(TextNode, _geom);
       return n->thaw();
       return n->thaw();
     }
     }

+ 33 - 2
panda/src/gui/guiListBox.cxx

@@ -43,6 +43,9 @@ void GuiListBox::recompute_frame(void) {
       btm = frm[2];
       btm = frm[2];
     if (frm[3] > tp)
     if (frm[3] > tp)
       tp = frm[3];
       tp = frm[3];
+    (*i)->freeze();
+    gui_cat->debug() << "in recompute: freeze lvl (" << (*i)->get_name()
+		     << ") = " << (*i)->thaw() << endl;
   }
   }
   _left = lft;
   _left = lft;
   _right = rgt;
   _right = rgt;
@@ -65,7 +68,8 @@ void GuiListBox::visible_patching(void) {
       _arrow_top = false;
       _arrow_top = false;
       _visible[0]->unmanage();
       _visible[0]->unmanage();
       _visible[0] = *(_top_stack.begin());
       _visible[0] = *(_top_stack.begin());
-      _visible[0]->manage(_mgr, *_eh);
+      if (_mgr != (GuiManager*)0L)
+	_visible[0]->manage(_mgr, *_eh);
       _top_stack.pop_back();
       _top_stack.pop_back();
     }
     }
   } else {
   } else {
@@ -76,7 +80,8 @@ void GuiListBox::visible_patching(void) {
       _visible[0]->unmanage();
       _visible[0]->unmanage();
       _top_stack.push_back(_visible[0]);
       _top_stack.push_back(_visible[0]);
       _visible[0] = _up_arrow;
       _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;
   ItemVector::iterator i;
   ItemDeque::iterator j;
   ItemDeque::iterator j;
 
 
+  gui_cat->debug() << "GuiListBox::freeze()" << endl;
   for (i=_top_stack.begin(); i!=_top_stack.end(); ++i) {
   for (i=_top_stack.begin(); i!=_top_stack.end(); ++i) {
+    if (*i == _up_arrow)
+      continue;
+    if (*i == _down_arrow)
+      continue;
     int count = (*i)->freeze();
     int count = (*i)->freeze();
     result = max(result, count);
     result = max(result, count);
   }
   }
   for (i=_visible.begin(); i!=_visible.end(); ++i) {
   for (i=_visible.begin(); i!=_visible.end(); ++i) {
+    if (*i == _up_arrow)
+      continue;
+    if (*i == _down_arrow)
+      continue;
     int count = (*i)->freeze();
     int count = (*i)->freeze();
     result = max(result, count);
     result = max(result, count);
   }
   }
   for (j=_bottom_stack.begin(); j!=_bottom_stack.end(); ++j) {
   for (j=_bottom_stack.begin(); j!=_bottom_stack.end(); ++j) {
+    if (*j == _up_arrow)
+      continue;
+    if (*j == _down_arrow)
+      continue;
     int count = (*j)->freeze();
     int count = (*j)->freeze();
     result = max(result, count);
     result = max(result, count);
   }
   }
@@ -220,15 +238,28 @@ int GuiListBox::thaw(void) {
   ItemVector::iterator i;
   ItemVector::iterator i;
   ItemDeque::iterator j;
   ItemDeque::iterator j;
 
 
+  gui_cat->debug() << "GuiListBox::thaw()" << endl;
   for (i=_top_stack.begin(); i!=_top_stack.end(); ++i) {
   for (i=_top_stack.begin(); i!=_top_stack.end(); ++i) {
+    if (*i == _up_arrow)
+      continue;
+    if (*i == _down_arrow)
+      continue;
     int count = (*i)->thaw();
     int count = (*i)->thaw();
     result = max(result, count);
     result = max(result, count);
   }
   }
   for (i=_visible.begin(); i!=_visible.end(); ++i) {
   for (i=_visible.begin(); i!=_visible.end(); ++i) {
+    if (*i == _up_arrow)
+      continue;
+    if (*i == _down_arrow)
+      continue;
     int count = (*i)->thaw();
     int count = (*i)->thaw();
     result = max(result, count);
     result = max(result, count);
   }
   }
   for (j=_bottom_stack.begin(); j!=_bottom_stack.end(); ++j) {
   for (j=_bottom_stack.begin(); j!=_bottom_stack.end(); ++j) {
+    if (*j == _up_arrow)
+      continue;
+    if (*j == _down_arrow)
+      continue;
     int count = (*j)->thaw();
     int count = (*j)->thaw();
     result = max(result, count);
     result = max(result, count);
   }
   }

+ 2 - 0
panda/src/gui/guiSign.cxx

@@ -41,10 +41,12 @@ void GuiSign::unmanage(void) {
 }
 }
 
 
 int GuiSign::freeze() {
 int GuiSign::freeze() {
+  gui_cat->debug() << "GuiSign::freeze (" << this->get_name() << ")" << endl;
   return _sign->freeze();
   return _sign->freeze();
 }
 }
 
 
 int GuiSign::thaw() {
 int GuiSign::thaw() {
+  gui_cat->debug() << "GuiSign::thaw (" << this->get_name() << ")" << endl;
   return _sign->thaw();
   return _sign->thaw();
 }
 }
 
 

+ 63 - 6
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* l3 = GuiLabel::make_simple_text_label("down", font);
   GuiLabel* l4 = GuiLabel::make_simple_text_label("downr", font);
   GuiLabel* l4 = GuiLabel::make_simple_text_label("downr", font);
   GuiLabel* l5 = GuiLabel::make_simple_text_label("none", 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_scale(0.1);
   b1->set_pos(LVector3f::rfu(-0.25, 0., 0.25));
   b1->set_pos(LVector3f::rfu(-0.25, 0., 0.25));
   l2->set_foreground_color(1., 1., 0., 1.);
   l2->set_foreground_color(1., 1., 0., 1.);
@@ -669,6 +669,61 @@ static void test12(GuiManager* mgr, Node* font) {
   b1->start_behavior();
   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) {
 static void setup_gui(void) {
   GuiManager* mgr = GuiManager::get_ptr(main_win, mak, (Node*)0L);
   GuiManager* mgr = GuiManager::get_ptr(main_win, mak, (Node*)0L);
   PT_Node font = ModelPool::load_model("ttf-comic");
   PT_Node font = ModelPool::load_model("ttf-comic");
@@ -696,9 +751,11 @@ 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);
+  // test 13
+  test13(mgr, font);
 }
 }
 
 
 static void event_2(CPT_Event) {
 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) {
 static void event_3(CPT_Event) {
   lb1->scroll_up();
   lb1->scroll_up();
   cout << *lb1;
   cout << *lb1;
 }
 }
 
 
-// for test11
+// for test11, 13
 static void event_4(CPT_Event) {
 static void event_4(CPT_Event) {
   lb1->scroll_down();
   lb1->scroll_down();
   cout << *lb1;
   cout << *lb1;
@@ -799,9 +856,9 @@ 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, 13
   event_handler.add_hook("3", event_3);
   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("4", event_4);
   event_handler.add_hook("demo-event-thing", event_demo);
   event_handler.add_hook("demo-event-thing", event_demo);
 }
 }