From 5ad35d82e737113cafd9f4db7762429bc29152d9 Mon Sep 17 00:00:00 2001 From: Cary Sandvig Date: Fri, 9 Mar 2001 06:04:40 +0000 Subject: [PATCH] rapture --- panda/src/gui/guiBackground.cxx | 1 + panda/src/gui/guiButton.cxx | 19 +--------------- panda/src/gui/guiChooser.cxx | 1 + panda/src/gui/guiCollection.cxx | 1 + panda/src/gui/guiFrame.cxx | 1 + panda/src/gui/guiItem.cxx | 18 +++++++++++++++ panda/src/gui/guiLabel.I | 3 +++ panda/src/gui/guiLabel.cxx | 39 +++++++++++++++++++++++++++------ panda/src/gui/guiLabel.h | 3 +++ panda/src/gui/guiListBox.cxx | 1 + panda/src/gui/guiRollover.cxx | 19 +--------------- panda/src/gui/guiSign.cxx | 1 + 12 files changed, 64 insertions(+), 43 deletions(-) diff --git a/panda/src/gui/guiBackground.cxx b/panda/src/gui/guiBackground.cxx index 307e17ee3b..f41d37ec94 100644 --- a/panda/src/gui/guiBackground.cxx +++ b/panda/src/gui/guiBackground.cxx @@ -16,6 +16,7 @@ void GuiBackground::recompute_frame(void) { (_item->get_bottom() + _item->get_top())*0.5)); _bg->recompute(); GuiItem::recompute_frame(); + this->adjust_region(); } void GuiBackground::set_priority(GuiLabel* l, const GuiItem::Priority p) { diff --git a/panda/src/gui/guiButton.cxx b/panda/src/gui/guiButton.cxx index e8aa37932b..271350c9cb 100644 --- a/panda/src/gui/guiButton.cxx +++ b/panda/src/gui/guiButton.cxx @@ -283,24 +283,7 @@ void GuiButton::recompute_frame(void) { void GuiButton::adjust_region(void) { GetExtents(_up, _down, _up_rollover, _down_rollover, _inactive, _left, _right, _bottom, _top); - gui_cat->debug() << "in adjust_region, base values (" << _left << ", " - << _right << ", " << _bottom << ", " << _top << ")" << endl; - if (!(_alt_root.is_null())) { - // adjust for graph transform - LMatrix4f m; - this->get_graph_mat(m); - LPoint3f ul = LVector3f::rfu(_left, 0., _top); - LPoint3f lr = LVector3f::rfu(_right, 0., _bottom); - ul = m * ul; - lr = m * lr; - _left = ul.dot(LVector3f::rfu(1., 0., 0.)); - _top = ul.dot(LVector3f::rfu(0., 0., 1.)); - _right = lr.dot(LVector3f::rfu(1., 0., 0.)); - _bottom = lr.dot(LVector3f::rfu(0., 0., 1.)); - gui_cat->debug() << "childed to non-default node, current values (" - << _left << ", " << _right << ", " << _bottom << ", " - << _top << ")" << endl; - } + GuiBehavior::adjust_region(); _rgn->set_region(_left, _right, _bottom, _top); } diff --git a/panda/src/gui/guiChooser.cxx b/panda/src/gui/guiChooser.cxx index 3a182a5ee4..d565af5453 100644 --- a/panda/src/gui/guiChooser.cxx +++ b/panda/src/gui/guiChooser.cxx @@ -60,6 +60,7 @@ void GuiChooser::recompute_frame(void) { _top = t; GuiBehavior::recompute_frame(); + this->adjust_region(); } void GuiChooser::set_priority(GuiLabel* l, GuiItem::Priority p) { diff --git a/panda/src/gui/guiCollection.cxx b/panda/src/gui/guiCollection.cxx index 79198b0516..bc761f2006 100644 --- a/panda/src/gui/guiCollection.cxx +++ b/panda/src/gui/guiCollection.cxx @@ -15,6 +15,7 @@ void GuiCollection::recompute_frame(void) { for (Items::iterator i=_items.begin(); i!=_items.end(); ++i) (*i)->recompute(); + this->adjust_region(); thaw(); } diff --git a/panda/src/gui/guiFrame.cxx b/panda/src/gui/guiFrame.cxx index 177916b6dc..79fdefd73c 100644 --- a/panda/src/gui/guiFrame.cxx +++ b/panda/src/gui/guiFrame.cxx @@ -207,6 +207,7 @@ void GuiFrame::recompute_frame(void) { _top = (_topadjust_region(); thaw(); } diff --git a/panda/src/gui/guiItem.cxx b/panda/src/gui/guiItem.cxx index 78d66439a8..bebeb18981 100644 --- a/panda/src/gui/guiItem.cxx +++ b/panda/src/gui/guiItem.cxx @@ -13,6 +13,24 @@ void GuiItem::recompute_frame(void) { void GuiItem::adjust_region(void) { test_ref_count_integrity(); + gui_cat->debug() << "in adjust_region, base values (" << _left << ", " + << _right << ", " << _bottom << ", " << _top << ")" << endl; + if (!(_alt_root.is_null())) { + // adjust for graph transform + LMatrix4f m; + this->get_graph_mat(m); + LPoint3f ul = LVector3f::rfu(_left, 0., _top); + LPoint3f lr = LVector3f::rfu(_right, 0., _bottom); + ul = m * ul; + lr = m * lr; + _left = ul.dot(LVector3f::rfu(1., 0., 0.)); + _top = ul.dot(LVector3f::rfu(0., 0., 1.)); + _right = lr.dot(LVector3f::rfu(1., 0., 0.)); + _bottom = lr.dot(LVector3f::rfu(0., 0., 1.)); + gui_cat->debug() << "childed to non-default node, current values (" + << _left << ", " << _right << ", " << _bottom << ", " + << _top << ")" << endl; + } } void GuiItem::set_priority(GuiLabel*, const GuiItem::Priority) { diff --git a/panda/src/gui/guiLabel.I b/panda/src/gui/guiLabel.I index 0f2237cfc1..66c4cf7211 100644 --- a/panda/src/gui/guiLabel.I +++ b/panda/src/gui/guiLabel.I @@ -11,6 +11,8 @@ INLINE GuiLabel::GuiLabel(void) : _type(GuiLabel::NONE), _model_height(1.), _scale(1.), _scale_x(1.), _scale_y(1.), _scale_z(1.), _pos(0., 0., 0.), + _model_pos(0., 0., 0.), + _have_foreground(false), _foreground(1., 1., 1., 1.), _have_background(false), _background(0., 0., 0., 0.), @@ -108,6 +110,7 @@ INLINE LVector3f GuiLabel::get_pos(void) const { INLINE void GuiLabel::set_foreground_color(float r, float g, float b, float a) { + this->_have_foreground = true; this->set_foreground_color(Colorf(r, g, b, a)); } diff --git a/panda/src/gui/guiLabel.cxx b/panda/src/gui/guiLabel.cxx index 8ddb78e707..32cb448f8e 100644 --- a/panda/src/gui/guiLabel.cxx +++ b/panda/src/gui/guiLabel.cxx @@ -47,7 +47,7 @@ void GuiLabel::recompute_transform(void) { LMatrix4f::scale_mat(LVector3f::rfu(w, 1., h)) * LMatrix4f::scale_mat(LVector3f::rfu((_mirror_x?-1.:1.), 1., (_mirror_y?-1.:1.))) * - LMatrix4f::translate_mat(_pos); + LMatrix4f::translate_mat(_pos + _model_pos); _internal->set_transition(new TransformTransition(mat)); } break; @@ -63,7 +63,8 @@ void GuiLabel::set_properties(void) { case SIMPLE_TEXT: { TextNode* n = DCAST(TextNode, _geom); - n->set_text_color(_foreground); + if (_have_foreground) + n->set_text_color(_foreground); n->clear_card(); if ((_have_background) || (_tex == (Texture*)0L)) { if (_have_background) @@ -108,10 +109,19 @@ void GuiLabel::set_properties(void) { case SIMPLE_TEXTURE: case MODEL: case L_NULL: - _internal->set_transition(new ColorTransition(_foreground)); + if (_have_foreground) + _internal->set_transition(new ColorTransition(_foreground)); break; case SIMPLE_CARD: - _internal->set_transition(new ColorTransition(_foreground)); + if (_have_foreground) { + _internal->set_transition(new ColorTransition(_foreground)); + TransparencyProperty::Mode mode; + if (_foreground[3] != 1.) + mode = TransparencyProperty::M_alpha; + else + mode = TransparencyProperty::M_none; + _internal->set_transition(new TransparencyTransition(mode)); + } { float w, h; w = _have_width?(_width * 0.5):0.5; @@ -258,8 +268,23 @@ GuiLabel* GuiLabel::make_model_label(Node* geom, float w, float h) { ret->_model_width = w; ret->_model_height = h; ret->_internal = new RenderRelation(ret->_geom, geom); - ret->_internal->set_transition( - new ColorTransition(Colorf(ret->_foreground))); + gui_cat->debug() << "created model label 0x" << (void*)ret + << " from node 0x" << (void*)geom + << ", set _type(" << (int)(ret->_type) << ") to MODEL(" + << (int)MODEL << ")" << endl; + return ret; +} + +GuiLabel* GuiLabel::make_model_label(Node* geom, float left, float right, + float bottom, float top) { + GuiLabel* ret = new GuiLabel(); + ret->_type = MODEL; + ret->_geom = new NamedNode("GUI label"); + ret->_model_pos = LVector3f::rfu((left - right) * 0.5, 0., + (bottom - top) * 0.5); + ret->_model_width = right - left; + ret->_model_height = top - bottom; + ret->_internal = new RenderRelation(ret->_geom, geom); gui_cat->debug() << "created model label 0x" << (void*)ret << " from node 0x" << (void*)geom << ", set _type(" << (int)(ret->_type) << ") to MODEL(" @@ -640,7 +665,7 @@ int GuiLabel::set_draw_order(int order) { case SIMPLE_CARD: case L_NULL: case MODEL: - _arc->set_transition(new GeomBinTransition("fixed", order)); + _internal->set_transition(new GeomBinTransition("fixed", order)); break; default: gui_cat->warning() << "trying to set draw order on an unknown label type (" diff --git a/panda/src/gui/guiLabel.h b/panda/src/gui/guiLabel.h index bc4b760bc6..9f7eff8c32 100644 --- a/panda/src/gui/guiLabel.h +++ b/panda/src/gui/guiLabel.h @@ -38,6 +38,8 @@ private: float _scale; float _scale_x, _scale_y, _scale_z; LVector3f _pos; + LVector3f _model_pos; + bool _have_foreground; Colorf _foreground; bool _have_background; Colorf _background; @@ -73,6 +75,7 @@ PUBLISHED: static GuiLabel* make_simple_card_label(void); static GuiLabel* make_null_label(void); static GuiLabel* make_model_label(Node*, float, float); + static GuiLabel* make_model_label(Node*, float, float, float, float); int freeze(); int thaw(); diff --git a/panda/src/gui/guiListBox.cxx b/panda/src/gui/guiListBox.cxx index b9c75a4f4e..f916844f5a 100644 --- a/panda/src/gui/guiListBox.cxx +++ b/panda/src/gui/guiListBox.cxx @@ -58,6 +58,7 @@ void GuiListBox::recompute_frame(void) { _right = rgt; _top = tp; _bottom = btm; + this->adjust_region(); this->thaw(); } diff --git a/panda/src/gui/guiRollover.cxx b/panda/src/gui/guiRollover.cxx index b70c7d0b2d..75b5c17ac2 100644 --- a/panda/src/gui/guiRollover.cxx +++ b/panda/src/gui/guiRollover.cxx @@ -68,24 +68,7 @@ void GuiRollover::recompute_frame(void) { void GuiRollover::adjust_region(void) { GetExtents(_off, _on, _left, _right, _bottom, _top); - gui_cat->debug() << "in adjust_region, base values (" << _left << ", " - << _right << ", " << _bottom << ", " << _top << ")" << endl; - if (!(_alt_root.is_null())) { - // adjust for graph transform - LMatrix4f m; - this->get_graph_mat(m); - LPoint3f ul = LVector3f::rfu(_left, 0., _top); - LPoint3f lr = LVector3f::rfu(_right, 0., _bottom); - ul = m * ul; - lr = m * lr; - _left = ul.dot(LVector3f::rfu(1., 0., 0.)); - _top = ul.dot(LVector3f::rfu(0., 0., 1.)); - _right = lr.dot(LVector3f::rfu(1., 0., 0.)); - _bottom = lr.dot(LVector3f::rfu(0., 0., 1.)); - gui_cat->debug() << "childed to non-default node, current values (" - << _left << ", " << _right << ", " << _bottom << ", " - << _top << ")" << endl; - } + GuiItem::adjust_region(); _rgn->set_region(_left, _right, _bottom, _top); } diff --git a/panda/src/gui/guiSign.cxx b/panda/src/gui/guiSign.cxx index 7e4e7430b9..2b36f99c95 100644 --- a/panda/src/gui/guiSign.cxx +++ b/panda/src/gui/guiSign.cxx @@ -12,6 +12,7 @@ void GuiSign::recompute_frame(void) { GuiItem::recompute_frame(); _sign->recompute(); _sign->get_extents(_left, _right, _bottom, _top); + this->adjust_region(); } void GuiSign::set_priority(GuiLabel* l, const GuiItem::Priority p) {