Browse Source

fix some behavior

Cary Sandvig 25 years ago
parent
commit
01c133af76

+ 7 - 7
panda/src/gui/guiFrame.cxx

@@ -181,7 +181,7 @@ void GuiFrame::add_item(GuiItem* item) {
       found = true;
       found = true;
   if (!found) {
   if (!found) {
     _items.push_back(Box(item));
     _items.push_back(Box(item));
-    this->recompute_frame();
+    //    this->recompute_frame();
   }
   }
 }
 }
 
 
@@ -189,6 +189,7 @@ void GuiFrame::remove_item(GuiItem* item) {
   Boxes::iterator i = find_box(item);
   Boxes::iterator i = find_box(item);
   if (i == _items.end())
   if (i == _items.end())
     return;
     return;
+  item->unmanage();
   (*i).erase_all_links();
   (*i).erase_all_links();
   // should NEVER link forward in the items, only backward, so it should be
   // should NEVER link forward in the items, only backward, so it should be
   // safe to start here, and go to the end
   // safe to start here, and go to the end
@@ -207,7 +208,6 @@ void GuiFrame::remove_item(GuiItem* item) {
   // now get rid of the thing itself
   // now get rid of the thing itself
   _items.erase(i);
   _items.erase(i);
   this->recompute();
   this->recompute();
-  item->unmanage();
 }
 }
 
 
 void GuiFrame::pack_item(GuiItem* item, Packing rel, GuiItem* to, float gap) {
 void GuiFrame::pack_item(GuiItem* item, Packing rel, GuiItem* to, float gap) {
@@ -223,19 +223,19 @@ void GuiFrame::pack_item(GuiItem* item, Packing rel, GuiItem* to, float gap) {
     return;
     return;
   }
   }
   (*box).add_link(Connection(rel, to, gap));
   (*box).add_link(Connection(rel, to, gap));
-  this->recompute_frame();
+  //  this->recompute_frame();
 }
 }
 
 
 void GuiFrame::clear_packing(GuiItem* item) {
 void GuiFrame::clear_packing(GuiItem* item) {
   Boxes::iterator box = find_box(item);
   Boxes::iterator box = find_box(item);
   (*box).erase_all_links();
   (*box).erase_all_links();
-  this->recompute_frame();
+  //  this->recompute_frame();
 }
 }
 
 
 void GuiFrame::clear_all_packing(void) {
 void GuiFrame::clear_all_packing(void) {
   for (Boxes::iterator i=_items.begin(); i!=_items.end(); ++i)
   for (Boxes::iterator i=_items.begin(); i!=_items.end(); ++i)
     (*i).erase_all_links();
     (*i).erase_all_links();
-  this->recompute_frame();
+  //  this->recompute_frame();
 }
 }
 
 
 void GuiFrame::manage(GuiManager* mgr, EventHandler& eh) {
 void GuiFrame::manage(GuiManager* mgr, EventHandler& eh) {
@@ -261,14 +261,14 @@ void GuiFrame::set_scale(float f) {
   for (Boxes::iterator i=_items.begin(); i!=_items.end(); ++i)
   for (Boxes::iterator i=_items.begin(); i!=_items.end(); ++i)
     (*i).get_item()->set_scale(f * (*i).get_scale());
     (*i).get_item()->set_scale(f * (*i).get_scale());
   GuiItem::set_scale(f);
   GuiItem::set_scale(f);
-  this->recompute_frame();
+  //  this->recompute_frame();
 }
 }
 
 
 void GuiFrame::set_pos(const LVector3f& p) {
 void GuiFrame::set_pos(const LVector3f& p) {
   for (Boxes::iterator i=_items.begin(); i!=_items.end(); ++i)
   for (Boxes::iterator i=_items.begin(); i!=_items.end(); ++i)
     (*i).get_item()->set_pos(p);
     (*i).get_item()->set_pos(p);
   GuiItem::set_pos(p);
   GuiItem::set_pos(p);
-  this->recompute_frame();
+  //  this->recompute_frame();
 }
 }
 
 
 void GuiFrame::output(ostream& os) const {
 void GuiFrame::output(ostream& os) const {

+ 17 - 9
panda/src/testbed/deadrec_rec.cxx

@@ -4,6 +4,11 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #include "framework.h"
 #include "framework.h"
+#include <renderRelation.h>
+#include <queuedConnectionManager.h>
+#include <queuedConnectionListener.h>
+#include <modelPool.h>
+#include <ipc_thread.h>
 
 
 #include <dconfig.h>
 #include <dconfig.h>
 
 
@@ -28,8 +33,8 @@ Clients clients;
 QueuedConnectionReader* reader;
 QueuedConnectionReader* reader;
 
 
 static void* internal_monitor(void*) {
 static void* internal_monitor(void*) {
-  if (deadrec->is_debug())
-    deadrec->debug() << "internal monitoring thread started" << endl;
+  if (deadrec_cat->is_debug())
+    deadrec_cat->debug() << "internal monitoring thread started" << endl;
   while (!stop_monitoring) {
   while (!stop_monitoring) {
     // check for new clients
     // check for new clients
     while (listener->new_connection_available()) {
     while (listener->new_connection_available()) {
@@ -58,9 +63,12 @@ static void* internal_monitor(void*) {
     while (reader->data_available()) {
     while (reader->data_available()) {
       NetDatagram datagram;
       NetDatagram datagram;
       if (reader->get_data(datagram)) {
       if (reader->get_data(datagram)) {
-	if (deadrec_cat->is_debug())
-	  deadrec_cat->debug() << "Got datagram " << datagram << " from "
-			       << datagram.get_address() << endl;
+	if (deadrec_cat->is_debug()) {
+	  deadrec_cat->debug() << "Got datagram ";
+	  datagram.dump_hex(deadrec_cat->debug(false));
+	  deadrec_cat->debug(false) << " from " << datagram.get_address()
+				    << endl;
+	}
 	// unpack and deal with the datagram now
 	// unpack and deal with the datagram now
 	// DO THIS
 	// DO THIS
 	// part of this includes logic on when to shutdown, I hope
 	// part of this includes logic on when to shutdown, I hope
@@ -69,8 +77,8 @@ static void* internal_monitor(void*) {
     // sleep for about 100 milliseconds
     // sleep for about 100 milliseconds
     ipc_traits::sleep(0, 100000);
     ipc_traits::sleep(0, 100000);
   }
   }
-  if (deadrec->is_debug())
-    deadrec->debug() << "internal monitoring thread exiting" << endl;
+  if (deadrec_cat->is_debug())
+    deadrec_cat->debug() << "internal monitoring thread exiting" << endl;
   return (void*)0L;
   return (void*)0L;
 }
 }
 
 
@@ -86,10 +94,10 @@ static void deadrec_setup(void) {
   PT(Connection) rendezvous = cm.open_TCP_server_rendezvous(hostport, 5);
   PT(Connection) rendezvous = cm.open_TCP_server_rendezvous(hostport, 5);
   if (rendezvous.is_null()) {
   if (rendezvous.is_null()) {
     deadrec_cat->fatal() << "cannot get port " << hostport << endl;
     deadrec_cat->fatal() << "cannot get port " << hostport << endl;
-    exit();
+    exit(0);
   }
   }
   if (deadrec_cat->is_debug())
   if (deadrec_cat->is_debug())
-    deadrec_cat->debug() << "Listening for connections on port " << port
+    deadrec_cat->debug() << "Listening for connections on port " << hostport
 			 << endl;
 			 << endl;
   listener = new QueuedConnectionListener(&cm, 0);
   listener = new QueuedConnectionListener(&cm, 0);
   listener->add_connection(rendezvous);
   listener->add_connection(rendezvous);

+ 10 - 7
panda/src/testbed/deadrec_send.cxx

@@ -4,6 +4,9 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #include "framework.h"
 #include "framework.h"
+#include <renderRelation.h>
+#include <queuedConnectionManager.h>
+#include <modelPool.h>
 
 
 #include <dconfig.h>
 #include <dconfig.h>
 
 
@@ -34,19 +37,19 @@ static void deadrec_setup(void) {
   my_arc = new RenderRelation(render, smiley);
   my_arc = new RenderRelation(render, smiley);
   // open a connection to the receiver
   // open a connection to the receiver
   NetAddress host;
   NetAddress host;
-  if (!host.set_host(hostname, port)) {
+  if (!host.set_host(hostname, hostport)) {
     deadrec_cat->fatal() << "Unknown host: " << hostname << endl;
     deadrec_cat->fatal() << "Unknown host: " << hostname << endl;
-    exit();
+    exit(0);
   }
   }
   conn = cm.open_TCP_client_connection(host, 5000);
   conn = cm.open_TCP_client_connection(host, 5000);
   if (conn.is_null()) {
   if (conn.is_null()) {
     deadrec_cat->fatal() << "no connection." << endl;
     deadrec_cat->fatal() << "no connection." << endl;
-    exit();
+    exit(0);
   }
   }
-  if (deadrec->is_debug())
-    deadrec->debug() << "opened TCP connection to " << hostname << " on port "
-		     << c->get_address().get_port() << " and IP "
-		     << c->get_address() << endl;
+  if (deadrec_cat->is_debug())
+    deadrec_cat->debug() << "opened TCP connection to " << hostname
+			 << " on port " << conn->get_address().get_port()
+			 << " and IP " << conn->get_address() << endl;
   writer = new ConnectionWriter(&cm, 0);
   writer = new ConnectionWriter(&cm, 0);
 }
 }
 
 

+ 291 - 138
panda/src/testbed/gui_demo.cxx

@@ -53,148 +53,158 @@ extern RenderRelation* first_arc;
 
 
 // static PT(GuiFrame) global_frame;
 // static PT(GuiFrame) global_frame;
 
 
-static void setup_gui(void) {
-  GuiManager* mgr = GuiManager::get_ptr(main_win, mak);
-  PT_Node font = ModelPool::load_model("ttf-comic");
-  // test 1
+static void test1(GuiManager* mgr, Node* font) {
   //  mgr->add_region(new GuiRegion("test1", 0., 0.25, 0., 0.25));
   //  mgr->add_region(new GuiRegion("test1", 0., 0.25, 0., 0.25));
   //  mgr->add_label(GuiLabel::make_simple_text_label("test2", font));
   //  mgr->add_label(GuiLabel::make_simple_text_label("test2", font));
-  // test 2
-  //  GuiLabel* l1 = GuiLabel::make_simple_text_label("off", font);
-  //  GuiLabel* l2 = GuiLabel::make_simple_text_label("on", font);
-  //  GuiRollover* r1 = new GuiRollover("test2", l1, l2);
-  //  r1->set_scale(0.1);
-  //  r1->set_pos(LVector3f::rfu(0.25, 0., 0.25));
-  //  r1->manage(mgr, event_handler);
-  // test 3
-  //  GuiLabel* l1 = GuiLabel::make_simple_text_label("up", font);
-  //  GuiLabel* l2 = GuiLabel::make_simple_text_label("upr", 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);
-  //  b1->set_scale(0.1);
-  //  b1->set_pos(LVector3f::rfu(-0.25, 0., 0.25));
-  //  l2->set_foreground_color(1., 1., 0., 1.);
-  //  l4->set_foreground_color(1., 1., 0., 1.);
-  //  l3->set_background_color(1., 1., 1., 0.5);
-  //  l4->set_background_color(1., 1., 1., 0.5);
-  //  b1->manage(mgr, event_handler);
-  // test 4
-  //  GuiRollover* r1 = new GuiRollover("r1",
-  //				    GuiLabel::make_simple_text_label("1",
-  //								     font),
-  //				    GuiLabel::make_simple_text_label("!",
-  //								     font));
-  //  GuiRollover* r2 = new GuiRollover("r2",
-  //				    GuiLabel::make_simple_text_label("2",
-  //								     font),
-  //				    GuiLabel::make_simple_text_label("@",
-  //								     font));
-  //  GuiRollover* r3 = new GuiRollover("r3",
-  //				    GuiLabel::make_simple_text_label("3",
-  //								     font),
-  //				    GuiLabel::make_simple_text_label("#",
-  //								     font));
-  //  GuiRollover* r4 = new GuiRollover("r4",
-  //				    GuiLabel::make_simple_text_label("4",
-  //								     font),
-  //				    GuiLabel::make_simple_text_label("$",
-  //								     font));
-  //  GuiRollover* r5 = new GuiRollover("r5",
-  //				    GuiLabel::make_simple_text_label("5",
-  //								     font),
-  //				    GuiLabel::make_simple_text_label("%",
-  //								     font));
-  //  GuiRollover* r6 = new GuiRollover("r6",
-  //				    GuiLabel::make_simple_text_label("6",
-  //								     font),
-  //				    GuiLabel::make_simple_text_label("^",
-  //								     font));
-  //  GuiRollover* r7 = new GuiRollover("r7",
-  //				    GuiLabel::make_simple_text_label("7",
-  //								     font),
-  //				    GuiLabel::make_simple_text_label("&",
-  //								     font));
-  //  GuiRollover* r8 = new GuiRollover("r8",
-  //				    GuiLabel::make_simple_text_label("8",
-  //								     font),
-  //				    GuiLabel::make_simple_text_label("*",
-  //								     font));
-  //  GuiRollover* r9 = new GuiRollover("r9",
-  //				    GuiLabel::make_simple_text_label("9",
-  //								     font),
-  //				    GuiLabel::make_simple_text_label("(",
-  //								     font));
-  //  GuiRollover* r0 = new GuiRollover("r0",
-  //				    GuiLabel::make_simple_text_label("0",
-  //								     font),
-  //				    GuiLabel::make_simple_text_label(")",
-  //								     font));
-  //  GuiFrame* f1 = new GuiFrame("test4");
-  //  f1->add_item(r1);
-  //  f1->add_item(r2);
-  //  f1->pack_item(r2, GuiFrame::UNDER, r1);
-  //  f1->pack_item(r2, GuiFrame::RIGHT, r1);
-  //  f1->add_item(r3);
-  //  f1->pack_item(r3, GuiFrame::UNDER, r2);
-  //  f1->pack_item(r3, GuiFrame::RIGHT, r2);
-  //  f1->add_item(r4);
-  //  f1->pack_item(r4, GuiFrame::UNDER, r3);
-  //  f1->pack_item(r4, GuiFrame::RIGHT, r2);
-  //  f1->add_item(r5);
-  //  f1->pack_item(r5, GuiFrame::UNDER, r4);
-  //  f1->pack_item(r5, GuiFrame::LEFT, r4);
-  //  f1->add_item(r6);
-  //  f1->pack_item(r6, GuiFrame::UNDER, r5);
-  //  f1->pack_item(r6, GuiFrame::LEFT, r5);
-  //  f1->add_item(r7);
-  //  f1->pack_item(r7, GuiFrame::ABOVE, r6);
-  //  f1->pack_item(r7, GuiFrame::LEFT, r6);
-  //  f1->add_item(r8);
-  //  f1->pack_item(r8, GuiFrame::ABOVE, r7);
-  //  f1->pack_item(r8, GuiFrame::LEFT, r7);
-  //  f1->add_item(r9);
-  //  f1->pack_item(r9, GuiFrame::ABOVE, r8);
-  //  f1->pack_item(r9, GuiFrame::LEFT, r7);
-  //  f1->add_item(r0);
-  //  f1->pack_item(r0, GuiFrame::ABOVE, r9);
-  //  f1->pack_item(r0, GuiFrame::RIGHT, r9);
-  //  f1->set_scale(0.1);
-  //  f1->set_pos(LVector3f::rfu(0., 0., -0.25));
-  //  f1->manage(mgr, event_handler);
+}
+
+static void test2(GuiManager* mgr, Node* font) {
+  GuiLabel* l1 = GuiLabel::make_simple_text_label("off", font);
+  GuiLabel* l2 = GuiLabel::make_simple_text_label("on", font);
+  GuiRollover* r1 = new GuiRollover("test2", l1, l2);
+  r1->set_scale(0.1);
+  r1->set_pos(LVector3f::rfu(0.25, 0., 0.25));
+  r1->manage(mgr, event_handler);
+}
+
+static void test3(GuiManager* mgr, Node* font) {
+  GuiLabel* l1 = GuiLabel::make_simple_text_label("up", font);
+  GuiLabel* l2 = GuiLabel::make_simple_text_label("upr", 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);
+  b1->set_scale(0.1);
+  b1->set_pos(LVector3f::rfu(-0.25, 0., 0.25));
+  l2->set_foreground_color(1., 1., 0., 1.);
+  l4->set_foreground_color(1., 1., 0., 1.);
+  l3->set_background_color(1., 1., 1., 0.5);
+  l4->set_background_color(1., 1., 1., 0.5);
+  b1->manage(mgr, event_handler);
+}
+
+static void test4(GuiManager* mgr, Node* font) {
+  GuiRollover* r1 = new GuiRollover("r1",
+				    GuiLabel::make_simple_text_label("1",
+								     font),
+				    GuiLabel::make_simple_text_label("!",
+								     font));
+  GuiRollover* r2 = new GuiRollover("r2",
+				    GuiLabel::make_simple_text_label("2",
+								     font),
+				    GuiLabel::make_simple_text_label("@",
+								     font));
+  GuiRollover* r3 = new GuiRollover("r3",
+				    GuiLabel::make_simple_text_label("3",
+								     font),
+				    GuiLabel::make_simple_text_label("#",
+								     font));
+  GuiRollover* r4 = new GuiRollover("r4",
+				    GuiLabel::make_simple_text_label("4",
+								     font),
+				    GuiLabel::make_simple_text_label("$",
+								     font));
+  GuiRollover* r5 = new GuiRollover("r5",
+				    GuiLabel::make_simple_text_label("5",
+								     font),
+				    GuiLabel::make_simple_text_label("%",
+								     font));
+  GuiRollover* r6 = new GuiRollover("r6",
+				    GuiLabel::make_simple_text_label("6",
+								     font),
+				    GuiLabel::make_simple_text_label("^",
+								     font));
+  GuiRollover* r7 = new GuiRollover("r7",
+				    GuiLabel::make_simple_text_label("7",
+								     font),
+				    GuiLabel::make_simple_text_label("&",
+								     font));
+  GuiRollover* r8 = new GuiRollover("r8",
+				    GuiLabel::make_simple_text_label("8",
+								     font),
+				    GuiLabel::make_simple_text_label("*",
+								     font));
+  GuiRollover* r9 = new GuiRollover("r9",
+				    GuiLabel::make_simple_text_label("9",
+								     font),
+				    GuiLabel::make_simple_text_label("(",
+								     font));
+  GuiRollover* r0 = new GuiRollover("r0",
+				    GuiLabel::make_simple_text_label("0",
+								     font),
+				    GuiLabel::make_simple_text_label(")",
+								     font));
+  GuiFrame* f1 = new GuiFrame("test4");
+  f1->add_item(r1);
+  f1->add_item(r2);
+  f1->pack_item(r2, GuiFrame::UNDER, r1);
+  f1->pack_item(r2, GuiFrame::RIGHT, r1);
+  f1->add_item(r3);
+  f1->pack_item(r3, GuiFrame::UNDER, r2);
+  f1->pack_item(r3, GuiFrame::RIGHT, r2);
+  f1->add_item(r4);
+  f1->pack_item(r4, GuiFrame::UNDER, r3);
+  f1->pack_item(r4, GuiFrame::RIGHT, r2);
+  f1->add_item(r5);
+  f1->pack_item(r5, GuiFrame::UNDER, r4);
+  f1->pack_item(r5, GuiFrame::LEFT, r4);
+  f1->add_item(r6);
+  f1->pack_item(r6, GuiFrame::UNDER, r5);
+  f1->pack_item(r6, GuiFrame::LEFT, r5);
+  f1->add_item(r7);
+  f1->pack_item(r7, GuiFrame::ABOVE, r6);
+  f1->pack_item(r7, GuiFrame::LEFT, r6);
+  f1->add_item(r8);
+  f1->pack_item(r8, GuiFrame::ABOVE, r7);
+  f1->pack_item(r8, GuiFrame::LEFT, r7);
+  f1->add_item(r9);
+  f1->pack_item(r9, GuiFrame::ABOVE, r8);
+  f1->pack_item(r9, GuiFrame::LEFT, r7);
+  f1->add_item(r0);
+  f1->pack_item(r0, GuiFrame::ABOVE, r9);
+  f1->pack_item(r0, GuiFrame::RIGHT, r9);
+  f1->set_scale(0.1);
+  f1->set_pos(LVector3f::rfu(0., 0., -0.25));
+  f1->manage(mgr, event_handler);
   //  cerr << *f1;
   //  cerr << *f1;
-  // test 5
-  //  GuiLabel* l1 = GuiLabel::make_simple_text_label("on", font);
-  //  GuiLabel* l2 = GuiLabel::make_simple_text_label("off", font);
-  //  GuiLabel* l3 = GuiLabel::make_simple_text_label("over", font);
-  //  GuiLabel* l4 = GuiLabel::make_simple_text_label("easy", font);
-  //  l1->set_background_color(1., 1., 1., 0.3);
-  //  l2->set_background_color(1., 1., 1., 0.3);
-  //  l3->set_background_color(1., 1., 1., 0.3);
-  //  l4->set_background_color(1., 1., 1., 0.3);
-  //  GuiRollover* r1 = new GuiRollover("r1", l1, l2);
-  //  GuiRollover* r2 = new GuiRollover("r2", l3, l4);
-  //  GuiFrame* f1 = new GuiFrame("test5");
-  //  f1->add_item(r1);
-  //  f1->add_item(r2);
-  //  f1->pack_item(r2, GuiFrame::UNDER, r1);
-  //  f1->set_scale(0.1);
-  //  f1->manage(mgr, event_handler);
-  //  float w1, w2, w3, w4, w;
-  //  w1 = l1->get_width();
-  //  w2 = l2->get_width();
-  //  w3 = l3->get_width();
-  //  w4 = l4->get_width();
-  //  w = (w1>w2)?w1:w2;
-  //  w = (w>w3)?w:w3;
-  //  w = (w>w4)?w:w4;
-  //  l1->set_width(w);
-  //  l2->set_width(w);
-  //  l3->set_width(w);
-  //  l4->set_width(w);
+}
+
+// PT(GuiFrame) global_frame;
+
+static void test5(GuiManager* mgr, Node* font) {
+  GuiLabel* l1 = GuiLabel::make_simple_text_label("on", font);
+  GuiLabel* l2 = GuiLabel::make_simple_text_label("off", font);
+  GuiLabel* l3 = GuiLabel::make_simple_text_label("over", font);
+  GuiLabel* l4 = GuiLabel::make_simple_text_label("easy", font);
+  l1->set_background_color(1., 1., 1., 0.3);
+  l2->set_background_color(1., 1., 1., 0.3);
+  l3->set_background_color(1., 1., 1., 0.3);
+  l4->set_background_color(1., 1., 1., 0.3);
+  GuiRollover* r1 = new GuiRollover("r1", l1, l2);
+  GuiRollover* r2 = new GuiRollover("r2", l3, l4);
+  GuiFrame* f1 = new GuiFrame("test5");
+  f1->add_item(r1);
+  f1->add_item(r2);
+  f1->pack_item(r2, GuiFrame::UNDER, r1);
+  f1->set_scale(0.1);
+  f1->manage(mgr, event_handler);
+  float w1, w2, w3, w4, w;
+  w1 = l1->get_width();
+  w2 = l2->get_width();
+  w3 = l3->get_width();
+  w4 = l4->get_width();
+  w = (w1>w2)?w1:w2;
+  w = (w>w3)?w:w3;
+  w = (w>w4)?w:w4;
+  l1->set_width(w);
+  l2->set_width(w);
+  l3->set_width(w);
+  l4->set_width(w);
   //  global_frame = f1;
   //  global_frame = f1;
-  // test 6  (the greg test)
+}
+
+static void test6(GuiManager* mgr, Node* font) {
+  // the greg test
   GuiFrame* f1 = new GuiFrame("canids");
   GuiFrame* f1 = new GuiFrame("canids");
   GuiLabel* b1l1 = GuiLabel::make_simple_text_label("dingo", font);
   GuiLabel* b1l1 = GuiLabel::make_simple_text_label("dingo", font);
   b1l1->set_foreground_color(0., 0., 0., 1.);
   b1l1->set_foreground_color(0., 0., 0., 1.);
@@ -293,6 +303,129 @@ static void setup_gui(void) {
   f1->manage(mgr, event_handler);
   f1->manage(mgr, event_handler);
 }
 }
 
 
+GuiManager* g_mgr;
+PT(GuiButton) b1;
+PT(GuiButton) b4;
+PT(GuiButton) b5;
+PT(GuiFrame) f1;
+static bool frame_state = true;
+
+static void test7(GuiManager* mgr, Node* font) {
+  f1 = new GuiFrame("canids");
+  GuiLabel* b1l1 = GuiLabel::make_simple_text_label("dingo", font);
+  b1l1->set_foreground_color(0., 0., 0., 1.);
+  b1l1->set_background_color(1., 1., 1., 1.);
+  GuiLabel* b1l2 = GuiLabel::make_simple_text_label("dingo", font);
+  b1l2->set_foreground_color(0., 0., 0., 1.);
+  b1l2->set_background_color(1., 1., 0., 1.);
+  GuiLabel* b1l3 = GuiLabel::make_simple_text_label("dingo", font);
+  b1l3->set_foreground_color(1., 1., 1., 1.);
+  b1l3->set_background_color(0., 0., 0., 1.);
+  b1 = new GuiButton("dingo", b1l1, b1l2, b1l3, b1l3, b1l1);
+  b1->set_scale(0.1);
+  f1->add_item(b1);
+  GuiLabel* b2l1 = GuiLabel::make_simple_text_label("jackel", font);
+  b2l1->set_foreground_color(0., 0., 0., 1.);
+  b2l1->set_background_color(1., 1., 1., 1.);
+  GuiLabel* b2l2 = GuiLabel::make_simple_text_label("jackel", font);
+  b2l2->set_foreground_color(0., 0., 0., 1.);
+  b2l2->set_background_color(1., 1., 0., 1.);
+  GuiLabel* b2l3 = GuiLabel::make_simple_text_label("jackel", font);
+  b2l3->set_foreground_color(1., 1., 1., 1.);
+  b2l3->set_background_color(0., 0., 0., 1.);
+  GuiButton* b2 = new GuiButton("jackel", b2l1, b2l2, b2l3, b2l3, b2l1);
+  b2->set_scale(0.1);
+  f1->add_item(b2);
+  GuiLabel* b3l1 = GuiLabel::make_simple_text_label("hyena", font);
+  b3l1->set_foreground_color(0., 0., 0., 1.);
+  b3l1->set_background_color(1., 1., 1., 1.);
+  GuiLabel* b3l2 = GuiLabel::make_simple_text_label("hyena", font);
+  b3l2->set_foreground_color(0., 0., 0., 1.);
+  b3l2->set_background_color(1., 1., 0., 1.);
+  GuiLabel* b3l3 = GuiLabel::make_simple_text_label("hyena", font);
+  b3l3->set_foreground_color(1., 1., 1., 1.);
+  b3l3->set_background_color(0., 0., 0., 1.);
+  GuiButton* b3 = new GuiButton("hyena", b3l1, b3l2, b3l3, b3l3, b3l1);
+  b3->set_scale(0.1);
+  f1->add_item(b3);
+  GuiLabel* b4l1 = GuiLabel::make_simple_text_label("wolf", font);
+  b4l1->set_foreground_color(0., 0., 0., 1.);
+  b4l1->set_background_color(1., 1., 1., 1.);
+  GuiLabel* b4l2 = GuiLabel::make_simple_text_label("wolf", font);
+  b4l2->set_foreground_color(0., 0., 0., 1.);
+  b4l2->set_background_color(1., 1., 0., 1.);
+  GuiLabel* b4l3 = GuiLabel::make_simple_text_label("wolf", font);
+  b4l3->set_foreground_color(1., 1., 1., 1.);
+  b4l3->set_background_color(0., 0., 0., 1.);
+  b4 = new GuiButton("wolf", b4l1, b4l2, b4l3, b4l3, b4l1);
+  b4->set_scale(0.1);
+  f1->add_item(b4);
+  GuiLabel* b5l1 = GuiLabel::make_simple_text_label("fox", font);
+  b5l1->set_foreground_color(0., 0., 0., 1.);
+  b5l1->set_background_color(1., 1., 1., 1.);
+  GuiLabel* b5l2 = GuiLabel::make_simple_text_label("fox", font);
+  b5l2->set_foreground_color(0., 0., 0., 1.);
+  b5l2->set_background_color(1., 1., 0., 1.);
+  GuiLabel* b5l3 = GuiLabel::make_simple_text_label("fox", font);
+  b5l3->set_foreground_color(1., 1., 1., 1.);
+  b5l3->set_background_color(0., 0., 0., 1.);
+  b5 = new GuiButton("fox", b5l1, b5l2, b5l3, b5l3, b5l1);
+  b5->set_scale(0.1);
+  f1->pack_item(b2, GuiFrame::UNDER, b1);
+  f1->pack_item(b2, GuiFrame::LEFT, b1);
+  f1->pack_item(b3, GuiFrame::UNDER, b1);
+  f1->pack_item(b3, GuiFrame::RIGHT, b1);
+  f1->pack_item(b4, GuiFrame::UNDER, b1);
+  f1->pack_item(b4, GuiFrame::ALIGN_LEFT, b1);
+  float w, w1, w2;
+  w1 = b1l1->get_width();
+  w2 = b2l1->get_width();
+  w = (w1>w2)?w1:w2;
+  w2 = b3l1->get_width();
+  w = (w>w2)?w:w2;
+  w2 = b4l1->get_width();
+  w = (w>w2)?w:w2;
+  w2 = b5l1->get_width();
+  w = (w>w2)?w:w2;
+  b1l1->set_width(w);
+  b1l2->set_width(w);
+  b1l3->set_width(w);
+  b2l1->set_width(w);
+  b2l2->set_width(w);
+  b2l3->set_width(w);
+  b3l1->set_width(w);
+  b3l2->set_width(w);
+  b3l3->set_width(w);
+  b4l1->set_width(w);
+  b4l2->set_width(w);
+  b4l3->set_width(w);
+  b5l1->set_width(w);
+  b5l2->set_width(w);
+  b5l3->set_width(w);
+  f1->recompute();
+  f1->manage(mgr, event_handler);
+}
+
+static void setup_gui(void) {
+  GuiManager* mgr = GuiManager::get_ptr(main_win, mak);
+  PT_Node font = ModelPool::load_model("ttf-comic");
+  // test 1
+  //  test1(mgr, font);
+  // test 2
+  //  test2(mgr, font);
+  // test 3
+  //  test3(mgr, font);
+  // test 4
+  //  test4(mgr, font);
+  // test 5
+  //  test5(mgr, font);
+  // test 6
+  //  test6(mgr, font);
+  // test 7
+  test7(mgr, font);
+  g_mgr = mgr;
+}
+
 static void event_2(CPT_Event) {
 static void event_2(CPT_Event) {
   static bool is_setup = false;
   static bool is_setup = false;
   if (!is_setup) {
   if (!is_setup) {
@@ -301,11 +434,31 @@ static void event_2(CPT_Event) {
   }
   }
 }
 }
 
 
+// for test 7
+static void event_3(CPT_Event) {
+  if (frame_state) {
+    f1->remove_item(b4);
+    f1->add_item(b5);
+    f1->pack_item(b5, GuiFrame::UNDER, b1);
+    f1->pack_item(b5, GuiFrame::ALIGN_LEFT, b1);
+    b5->manage(g_mgr, event_handler);
+  } else {
+    f1->remove_item(b5);
+    f1->add_item(b4);
+    f1->pack_item(b4, GuiFrame::UNDER, b1);
+    f1->pack_item(b4, GuiFrame::ALIGN_LEFT, b1);
+    b4->manage(g_mgr, event_handler);
+  }
+  f1->recompute();
+  frame_state = !frame_state;
+}
+
 void gui_keys(EventHandler&) {
 void gui_keys(EventHandler&) {
   new RenderRelation( lights, dlight );
   new RenderRelation( lights, dlight );
   have_dlight = true;
   have_dlight = true;
 
 
   event_handler.add_hook("2", event_2);
   event_handler.add_hook("2", event_2);
+  event_handler.add_hook("3", event_3);
 }
 }
 
 
 int main(int argc, char *argv[]) {
 int main(int argc, char *argv[]) {