From d50576e488c2470cf96faebc94f6607dec73f2f4 Mon Sep 17 00:00:00 2001 From: Cary Sandvig Date: Wed, 15 Nov 2000 22:52:15 +0000 Subject: [PATCH] stuff --- panda/src/gui/config_gui.cxx | 9 +++++++++ panda/src/gui/config_gui.h | 5 +++++ panda/src/gui/guiLabel.cxx | 25 ++++++++++++++++++++----- panda/src/testbed/deadrec_send.cxx | 1 - panda/src/testbed/gui_demo.cxx | 4 ++-- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/panda/src/gui/config_gui.cxx b/panda/src/gui/config_gui.cxx index e296173a01..72a2fd9751 100644 --- a/panda/src/gui/config_gui.cxx +++ b/panda/src/gui/config_gui.cxx @@ -26,3 +26,12 @@ ConfigureFn(config_gui) { GuiButton::init_type(); GuiFrame::init_type(); } + +float simple_text_margin_top = + config_gui.GetFloat("simple-text-margin-top", 0.02); +float simple_text_margin_bottom = + config_gui.GetFloat("simple-text-margin-bottom", 0.05); +float simple_text_margin_left = + config_gui.GetFloat("simple-text-margin-left", 0.02); +float simple_text_margin_right = + config_gui.GetFloat("simple-text-margin-right", 0.02); diff --git a/panda/src/gui/config_gui.h b/panda/src/gui/config_gui.h index b3084a9994..84a82d75ad 100644 --- a/panda/src/gui/config_gui.h +++ b/panda/src/gui/config_gui.h @@ -11,4 +11,9 @@ NotifyCategoryDecl(gui, EXPCL_PANDA, EXPTP_PANDA); +extern float simple_text_margin_top; +extern float simple_text_margin_bottom; +extern float simple_text_margin_left; +extern float simple_text_margin_right; + #endif /* __CONFIG_GUI_H__ */ diff --git a/panda/src/gui/guiLabel.cxx b/panda/src/gui/guiLabel.cxx index a374b733a7..27b8f8926e 100644 --- a/panda/src/gui/guiLabel.cxx +++ b/panda/src/gui/guiLabel.cxx @@ -41,11 +41,17 @@ void GuiLabel::set_properties(void) { { TextNode* n = DCAST(TextNode, _geom); n->set_text_color(_foreground); - if (!_have_background) { - n->clear_card(); - } else { - n->set_card_color(_background); + n->clear_card(); + if ((_have_background) || (_tex == (Texture*)0L)) { + if (_have_background) + n->set_card_color(_background); + if (_tex != (Texture*)0L) + n->set_card_texture(_tex); if (_have_width || _have_height) { + n->set_card_as_margin(simple_text_margin_left, + simple_text_margin_right, + simple_text_margin_bottom, + simple_text_margin_top); LVecBase4f v = n->get_card_actual(); float w = v[1] - v[0]; float h = v[3] - v[2]; @@ -54,16 +60,25 @@ void GuiLabel::set_properties(void) { w *= 0.5; v[1] += w; v[0] -= w; + } else { + v[0] -= simple_text_margin_left; + v[1] += simple_text_margin_right; } if (_have_height) { h = _height - h; h *= 0.5; v[3] += h; v[2] -= h; + } else { + v[2] -= simple_text_margin_bottom; + v[3] += simple_text_margin_top; } n->set_card_actual(v[0], v[1], v[2], v[3]); } else - n->set_card_as_margin(0., 0., 0., 0.); + n->set_card_as_margin(simple_text_margin_left, + simple_text_margin_right, + simple_text_margin_bottom, + simple_text_margin_top); } } break; diff --git a/panda/src/testbed/deadrec_send.cxx b/panda/src/testbed/deadrec_send.cxx index a5c7ff8551..76dbe66130 100644 --- a/panda/src/testbed/deadrec_send.cxx +++ b/panda/src/testbed/deadrec_send.cxx @@ -6,7 +6,6 @@ #include "framework.h" void deadrec_keys(EventHandler& eh) { - } int main(int argc, char* argv[]) { diff --git a/panda/src/testbed/gui_demo.cxx b/panda/src/testbed/gui_demo.cxx index 0058855413..d2a57fa5b8 100644 --- a/panda/src/testbed/gui_demo.cxx +++ b/panda/src/testbed/gui_demo.cxx @@ -301,7 +301,7 @@ static void event_2(CPT_Event) { } } -void demo_keys(EventHandler&) { +void gui_keys(EventHandler&) { new RenderRelation( lights, dlight ); have_dlight = true; @@ -309,6 +309,6 @@ void demo_keys(EventHandler&) { } int main(int argc, char *argv[]) { - define_keys = &demo_keys; + define_keys = &gui_keys; return framework_main(argc, argv); }