diff --git a/panda/src/gui/guiBackground.cxx b/panda/src/gui/guiBackground.cxx index 30ff0d0954..8467b4695d 100644 --- a/panda/src/gui/guiBackground.cxx +++ b/panda/src/gui/guiBackground.cxx @@ -78,7 +78,10 @@ void GuiBackground::set_pos(const LVector3f& p) { void GuiBackground::set_priority(GuiItem* it, const GuiItem::Priority p) { _item->set_priority(it, p); - it->set_priority(_bg, ((p==P_Low)?P_High:P_Low)); + if (p == P_Highest) + _bg->set_priority(_bg, GuiLabel::P_HIGHEST); + else + it->set_priority(_bg, ((p==P_Low)?P_High:P_Low)); GuiItem::set_priority(it, p); } diff --git a/panda/src/gui/guiButton.cxx b/panda/src/gui/guiButton.cxx index fa114d43a4..9f7eeb1e29 100644 --- a/panda/src/gui/guiButton.cxx +++ b/panda/src/gui/guiButton.cxx @@ -493,14 +493,25 @@ void GuiButton::reset_behavior(void) { } void GuiButton::set_priority(GuiItem* i, const GuiItem::Priority p) { - i->set_priority(_up, ((p==P_Low)?P_High:P_Low)); - i->set_priority(_down, ((p==P_Low)?P_High:P_Low)); - if (_up_rollover != (GuiLabel*)0L) - i->set_priority(_up_rollover, ((p==P_Low)?P_High:P_Low)); - if (_down_rollover != (GuiLabel*)0L) - i->set_priority(_down_rollover, ((p==P_Low)?P_High:P_Low)); - if (_inactive != (GuiLabel*)0L) - i->set_priority(_inactive, ((p==P_Low)?P_High:P_Low)); + if (p == P_Highest) { + _up->set_priority(_up, GuiLabel::P_HIGHEST); + _down->set_priority(_up, GuiLabel::P_HIGHEST); + if (_up_rollover != (GuiLabel*)0L) + _up_rollover->set_priority(_up, GuiLabel::P_HIGHEST); + if (_down_rollover != (GuiLabel*)0L) + _down_rollover->set_priority(_up, GuiLabel::P_HIGHEST); + if (_inactive != (GuiLabel*)0L) + _inactive->set_priority(_up, GuiLabel::P_HIGHEST); + } else { + i->set_priority(_up, ((p==P_Low)?P_High:P_Low)); + i->set_priority(_down, ((p==P_Low)?P_High:P_Low)); + if (_up_rollover != (GuiLabel*)0L) + i->set_priority(_up_rollover, ((p==P_Low)?P_High:P_Low)); + if (_down_rollover != (GuiLabel*)0L) + i->set_priority(_down_rollover, ((p==P_Low)?P_High:P_Low)); + if (_inactive != (GuiLabel*)0L) + i->set_priority(_inactive, ((p==P_Low)?P_High:P_Low)); + } GuiBehavior::set_priority(i, p); } diff --git a/panda/src/gui/guiItem.h b/panda/src/gui/guiItem.h index db6f622f65..45700a5565 100644 --- a/panda/src/gui/guiItem.h +++ b/panda/src/gui/guiItem.h @@ -12,7 +12,7 @@ class EXPCL_PANDA GuiItem : public TypedReferenceCount, public Namable { PUBLISHED: - enum Priority { P_Low, P_Normal, P_High }; + enum Priority { P_Low, P_Normal, P_High, P_Highest }; protected: bool _added_hooks; diff --git a/panda/src/gui/guiLabel.I b/panda/src/gui/guiLabel.I index 1a32038e6f..c54c36d839 100644 --- a/panda/src/gui/guiLabel.I +++ b/panda/src/gui/guiLabel.I @@ -14,7 +14,8 @@ INLINE GuiLabel::GuiLabel(void) : _type(GuiLabel::NONE), _background(0., 0., 0., 0.), _have_width(false), _width(0.), _have_height(false), _height(0.), - _depth(0.), _hard_pri(0) { + _depth(0.), _hard_pri(0), + _highest_pri(false) { } INLINE Node* GuiLabel::get_geometry(void) const { @@ -108,5 +109,8 @@ INLINE void GuiLabel::recompute(void) { } INLINE void GuiLabel::set_priority(GuiLabel* l, const PriorityType t) { - this->_priorities[l] = t; + if (t == P_HIGHEST) + _highest_pri = true; + else + this->_priorities[l] = t; } diff --git a/panda/src/gui/guiLabel.cxx b/panda/src/gui/guiLabel.cxx index 38d3978028..cc001118a0 100644 --- a/panda/src/gui/guiLabel.cxx +++ b/panda/src/gui/guiLabel.cxx @@ -374,6 +374,8 @@ void GuiLabel::set_text(const string& val) { } bool GuiLabel::operator<(const GuiLabel& c) const { + if (_highest_pri) + return false; PriorityMap::const_iterator pi; pi = _priorities.find((GuiLabel*)(&c)); if (pi != _priorities.end()) { diff --git a/panda/src/gui/guiLabel.h b/panda/src/gui/guiLabel.h index d54eceeafb..2065dbdfc8 100644 --- a/panda/src/gui/guiLabel.h +++ b/panda/src/gui/guiLabel.h @@ -22,7 +22,7 @@ class GuiManager; class EXPCL_PANDA GuiLabel : public TypedReferenceCount { PUBLISHED: - enum PriorityType { P_NONE, P_LOWER, P_HIGHER }; + enum PriorityType { P_NONE, P_LOWER, P_HIGHER, P_HIGHEST }; private: typedef map PriorityMap; enum LabelType { NONE, SIMPLE_TEXTURE, SIMPLE_TEXT, SIMPLE_CARD }; @@ -47,6 +47,7 @@ private: PriorityMap _priorities; int _hard_pri; + bool _highest_pri; INLINE Node* get_geometry(void) const; INLINE void set_arc(RenderRelation*); diff --git a/panda/src/gui/guiRollover.cxx b/panda/src/gui/guiRollover.cxx index b5bbd6fcfd..0976b74419 100644 --- a/panda/src/gui/guiRollover.cxx +++ b/panda/src/gui/guiRollover.cxx @@ -145,8 +145,13 @@ void GuiRollover::set_pos(const LVector3f& p) { } void GuiRollover::set_priority(GuiItem* i, const GuiItem::Priority p) { - i->set_priority(_off, ((p==P_Low)?P_High:P_Low)); - i->set_priority(_on, ((p==P_Low)?P_High:P_Low)); + if (p == P_Highest) { + _off->set_priority(_off, GuiLabel::P_HIGHEST); + _on->set_priority(_on, GuiLabel::P_HIGHEST); + } else { + i->set_priority(_off, ((p==P_Low)?P_High:P_Low)); + i->set_priority(_on, ((p==P_Low)?P_High:P_Low)); + } GuiItem::set_priority(i, p); } diff --git a/panda/src/gui/guiSign.cxx b/panda/src/gui/guiSign.cxx index 8d907344ba..6c9c9b966d 100644 --- a/panda/src/gui/guiSign.cxx +++ b/panda/src/gui/guiSign.cxx @@ -68,7 +68,10 @@ void GuiSign::set_pos(const LVector3f& p) { } void GuiSign::set_priority(GuiItem* i, const GuiItem::Priority p) { - i->set_priority(_sign, ((p==P_Low)?P_High:P_Low)); + if (p == P_Highest) + _sign->set_priority(_sign, GuiLabel::P_HIGHEST); + else + i->set_priority(_sign, ((p==P_Low)?P_High:P_Low)); GuiItem::set_priority(i, p); } diff --git a/panda/src/testbed/gui_demo.cxx b/panda/src/testbed/gui_demo.cxx index b295260cb1..0920433ddf 100644 --- a/panda/src/testbed/gui_demo.cxx +++ b/panda/src/testbed/gui_demo.cxx @@ -907,7 +907,7 @@ static void setup_gui(void) { // test9(mgr, font); // g_mgr = mgr; // test 10 - test10(mgr, font); + // test10(mgr, font); // test 11 // test11(mgr, font); // test 12 @@ -917,7 +917,7 @@ static void setup_gui(void) { // test 14 // test14(mgr, font); // test 15 - // test15(mgr, font); + test15(mgr, font); } static void event_2(CPT_Event) {