فهرست منبع

added 'highest' priority

Cary Sandvig 25 سال پیش
والد
کامیت
16949a031d

+ 4 - 1
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);
 }
 

+ 19 - 8
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);
 }
 

+ 1 - 1
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;

+ 6 - 2
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;
 }

+ 2 - 0
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()) {

+ 2 - 1
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<GuiLabel*, PriorityType> 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*);

+ 7 - 2
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);
 }
 

+ 4 - 1
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);
 }
 

+ 2 - 2
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) {