From c74e33d802c198c44b2a7ed84000bae1eae44892 Mon Sep 17 00:00:00 2001 From: Cary Sandvig Date: Wed, 21 Feb 2001 02:25:10 +0000 Subject: [PATCH] adjust --- panda/src/gui/guiBackground.I | 12 +++++ panda/src/gui/guiBackground.cxx | 8 ++- panda/src/gui/guiBackground.h | 4 ++ panda/src/testbed/gui_demo.cxx | 86 +++++++++++++++++++++++++++++++-- 4 files changed, 104 insertions(+), 6 deletions(-) diff --git a/panda/src/gui/guiBackground.I b/panda/src/gui/guiBackground.I index 1fe21270a3..e853b513b3 100644 --- a/panda/src/gui/guiBackground.I +++ b/panda/src/gui/guiBackground.I @@ -5,3 +5,15 @@ INLINE GuiBackground::GuiBackground(void) { } + +INLINE void GuiBackground::set_color(float r, float g, float b, float a) { + _bg->set_foreground_color(r, g, b, a); +} + +INLINE void GuiBackground::set_color(const Colorf& c) { + _bg->set_foreground_color(c); +} + +INLINE Colorf GuiBackground::get_color(void) const { + return _bg->get_foreground_color(); +} diff --git a/panda/src/gui/guiBackground.cxx b/panda/src/gui/guiBackground.cxx index 8467b4695d..21c9b75c0b 100644 --- a/panda/src/gui/guiBackground.cxx +++ b/panda/src/gui/guiBackground.cxx @@ -38,7 +38,11 @@ void GuiBackground::manage(GuiManager* mgr, EventHandler& eh) { if (!_added_hooks) _added_hooks = true; if (_mgr == (GuiManager*)0L) { - _mgr->add_label(_bg); + _bg->freeze(); + _bg->set_width(_item->get_width()); + _bg->set_height(_item->get_height()); + _bf->thaw(); + mgr->add_label(_bg); _item->manage(mgr, eh); GuiItem::manage(mgr, eh); } else @@ -55,10 +59,12 @@ void GuiBackground::unmanage(void) { } int GuiBackground::freeze(void) { + _bg->freeze(); return _item->freeze(); } int GuiBackground::thaw(void) { + _bg->thaw(); return _item->thaw(); } diff --git a/panda/src/gui/guiBackground.h b/panda/src/gui/guiBackground.h index 980cb97fc7..3e2a37a294 100644 --- a/panda/src/gui/guiBackground.h +++ b/panda/src/gui/guiBackground.h @@ -32,6 +32,10 @@ PUBLISHED: virtual void set_priority(GuiLabel*, const Priority); virtual void set_priority(GuiItem*, const Priority); + INLINE void set_color(float, float, float, float); + INLINE void set_color(const Colorf&); + INLINE Colorf get_color(void) const; + virtual void output(ostream&) const; public: diff --git a/panda/src/testbed/gui_demo.cxx b/panda/src/testbed/gui_demo.cxx index 0920433ddf..69b90e0fb7 100644 --- a/panda/src/testbed/gui_demo.cxx +++ b/panda/src/testbed/gui_demo.cxx @@ -49,6 +49,7 @@ #include #include #include +#include //From framework extern PT(GeomNode) geomnode; @@ -882,6 +883,79 @@ static void test15(GuiManager* mgr, Node* font) { ch1->start_behavior(); } +static void test16(GuiManager* mgr, Node* font) { + GuiLabel* nl1 = GuiLabel::make_simple_text_label("next", font); + GuiLabel* nl2 = GuiLabel::make_simple_text_label("next", font); + GuiLabel* nl3 = GuiLabel::make_simple_text_label("next", font); + GuiButton* nb = new GuiButton("next_button", nl1, nl2, nl3); + nb->set_scale(0.1); + nb->set_pos(LVector3f::rfu(0.25, 0., -0.25)); + GuiLabel* pl1 = GuiLabel::make_simple_text_label("prev", font); + GuiLabel* pl2 = GuiLabel::make_simple_text_label("prev", font); + GuiLabel* pl3 = GuiLabel::make_simple_text_label("prev", font); + GuiButton* pb = new GuiButton("prev_button", pl1, pl2, pl3); + pb->set_scale(0.1); + pb->set_pos(LVector3f::rfu(-0.25, 0., -0.25)); + nb->set_behavior_event("demo-event-thing"); + pb->set_behavior_event("demo-event-thing"); + ch1 = new GuiChooser("chooser", pb, nb); + 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); + nl1->set_background_color(0., 0., 0., 1.); + nl2->set_background_color(0., 0., 0., 1.); + nl3->set_background_color(0., 0., 0., 1.); + nl2->set_foreground_color(1., 0., 0., 1.); + nl3->set_foreground_color(1., 1., 1., 0.5); + pl1->set_background_color(0., 0., 0., 1.); + pl2->set_background_color(0., 0., 0., 1.); + pl3->set_background_color(0., 0., 0., 1.); + pl2->set_foreground_color(1., 0., 0., 1.); + pl3->set_foreground_color(1., 1., 1., 0.5); + 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.); + ch1->add_item(s1); + ch1->add_item(s2); + ch1->add_item(s3); + ch1->add_item(s4); + ch1->add_item(s5); + GuiBackground *bg = new GuiBackground("bg", ch1); + bg->set_color(1., 0., 1., 1.); + bg->thaw(); + bg->manage(mgr, event_handler); + ch1->start_behavior(); +} + static void setup_gui(void) { GuiManager* mgr = GuiManager::get_ptr(main_win, mak, (Node*)0L); PT_Node font = ModelPool::load_model("ttf-comic"); @@ -917,7 +991,9 @@ static void setup_gui(void) { // test 14 // test14(mgr, font); // test 15 - test15(mgr, font); + // test15(mgr, font); + // test 16 + test16(mgr, font); } static void event_2(CPT_Event) { @@ -1005,7 +1081,7 @@ static void event_3(CPT_Event) { } */ -// for test 14-15 +// for test 14-16 static void event_3(CPT_Event) { ch1->move_prev(); } @@ -1018,7 +1094,7 @@ static void event_4(CPT_Event) { } */ -// for test 14-15 +// for test 14-16 static void event_4(CPT_Event) { ch1->move_next(); } @@ -1032,9 +1108,9 @@ void gui_keys(EventHandler&) { have_dlight = true; event_handler.add_hook("2", event_2); - // for tests 7-11, 13-15 + // for tests 7-11, 13-16 event_handler.add_hook("3", event_3); - // for test 11, 13-15 + // for test 11, 13-16 event_handler.add_hook("4", event_4); event_handler.add_hook("demo-event-thing", event_demo); }