This commit is contained in:
Cary Sandvig 2001-02-21 02:25:10 +00:00
parent af5377631a
commit c74e33d802
4 changed files with 104 additions and 6 deletions

View File

@ -5,3 +5,15 @@
INLINE GuiBackground::GuiBackground(void) { 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();
}

View File

@ -38,7 +38,11 @@ void GuiBackground::manage(GuiManager* mgr, EventHandler& eh) {
if (!_added_hooks) if (!_added_hooks)
_added_hooks = true; _added_hooks = true;
if (_mgr == (GuiManager*)0L) { 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); _item->manage(mgr, eh);
GuiItem::manage(mgr, eh); GuiItem::manage(mgr, eh);
} else } else
@ -55,10 +59,12 @@ void GuiBackground::unmanage(void) {
} }
int GuiBackground::freeze(void) { int GuiBackground::freeze(void) {
_bg->freeze();
return _item->freeze(); return _item->freeze();
} }
int GuiBackground::thaw(void) { int GuiBackground::thaw(void) {
_bg->thaw();
return _item->thaw(); return _item->thaw();
} }

View File

@ -32,6 +32,10 @@ PUBLISHED:
virtual void set_priority(GuiLabel*, const Priority); virtual void set_priority(GuiLabel*, const Priority);
virtual void set_priority(GuiItem*, 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; virtual void output(ostream&) const;
public: public:

View File

@ -49,6 +49,7 @@
#include <guiSign.h> #include <guiSign.h>
#include <guiListBox.h> #include <guiListBox.h>
#include <guiChooser.h> #include <guiChooser.h>
#include <guiBackground.h>
//From framework //From framework
extern PT(GeomNode) geomnode; extern PT(GeomNode) geomnode;
@ -882,6 +883,79 @@ static void test15(GuiManager* mgr, Node* font) {
ch1->start_behavior(); 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) { 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");
@ -917,7 +991,9 @@ static void setup_gui(void) {
// test 14 // test 14
// test14(mgr, font); // test14(mgr, font);
// test 15 // test 15
test15(mgr, font); // test15(mgr, font);
// test 16
test16(mgr, font);
} }
static void event_2(CPT_Event) { 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) { static void event_3(CPT_Event) {
ch1->move_prev(); 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) { static void event_4(CPT_Event) {
ch1->move_next(); ch1->move_next();
} }
@ -1032,9 +1108,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, 13-15 // for tests 7-11, 13-16
event_handler.add_hook("3", event_3); 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("4", event_4);
event_handler.add_hook("demo-event-thing", event_demo); event_handler.add_hook("demo-event-thing", event_demo);
} }