Răsfoiți Sursa

layering priority in GUI

Cary Sandvig 25 ani în urmă
părinte
comite
df6ecb17bf

+ 22 - 1
panda/src/gui/guiItem.I

@@ -4,7 +4,24 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 INLINE GuiItem::GuiItem(void) : Namable("fubar"), _left(-1.), _right(1.),
 INLINE GuiItem::GuiItem(void) : Namable("fubar"), _left(-1.), _right(1.),
-				_bottom(-1.), _top(1.) {}
+				_bottom(-1.), _top(1.), _pri(P_Normal) {}
+
+INLINE void GuiItem::set_priority(const GuiItem::Priority p) {
+  _pri = p;
+  float r = _pos.dot(LVector3f::rfu(1., 0., 0.));
+  float u = _pos.dot(LVector3f::rfu(0., 0., 1.));
+  switch (_pri) {
+  case P_Low:
+    this->set_pos(LVector3f::rfu(r, 0.5, u));
+    break;
+  case P_Normal:
+    this->set_pos(LVector3f::rfu(r, 0., u));
+    break;
+  case P_High:
+    this->set_pos(LVector3f::rfu(r, -0.5, u));
+    break;
+  }
+}
 
 
 INLINE float GuiItem::get_scale(void) const {
 INLINE float GuiItem::get_scale(void) const {
   return _scale;
   return _scale;
@@ -34,6 +51,10 @@ INLINE LVector4f GuiItem::get_frame(void) const {
   return LVector4f(_left, _right, _bottom, _top);
   return LVector4f(_left, _right, _bottom, _top);
 }
 }
 
 
+INLINE GuiItem::Priority GuiItem::get_priority(void) const {
+  return _pri;
+}
+
 INLINE void GuiItem::recompute(void) {
 INLINE void GuiItem::recompute(void) {
   this->recompute_frame();
   this->recompute_frame();
 }
 }

+ 1 - 1
panda/src/gui/guiItem.cxx

@@ -15,7 +15,7 @@ GuiItem::GuiItem(const string& name) : Namable(name), _added_hooks(false),
 				       _scale(1.), _left(-1.), _right(1.),
 				       _scale(1.), _left(-1.), _right(1.),
 				       _bottom(-1.), _top(1.),
 				       _bottom(-1.), _top(1.),
 				       _pos(0., 0., 0.),
 				       _pos(0., 0., 0.),
-				       _mgr((GuiManager*)0L) {
+				       _mgr((GuiManager*)0L), _pri(P_Normal) {
 }
 }
 
 
 GuiItem::~GuiItem(void) {
 GuiItem::~GuiItem(void) {

+ 6 - 0
panda/src/gui/guiItem.h

@@ -11,11 +11,15 @@
 #include <eventHandler.h>
 #include <eventHandler.h>
 
 
 class EXPCL_PANDA GuiItem : public TypedReferenceCount, public Namable {
 class EXPCL_PANDA GuiItem : public TypedReferenceCount, public Namable {
+PUBLISHED:
+  enum Priority { P_Low, P_Normal, P_High };
+
 protected:
 protected:
   bool _added_hooks;
   bool _added_hooks;
   float _scale, _left, _right, _bottom, _top;
   float _scale, _left, _right, _bottom, _top;
   LVector3f _pos;
   LVector3f _pos;
   GuiManager* _mgr;
   GuiManager* _mgr;
+  Priority _pri;
 
 
   INLINE GuiItem(void);
   INLINE GuiItem(void);
   virtual void recompute_frame(void) = 0;
   virtual void recompute_frame(void) = 0;
@@ -29,6 +33,7 @@ PUBLISHED:
 
 
   virtual void set_scale(float) = 0;
   virtual void set_scale(float) = 0;
   virtual void set_pos(const LVector3f&) = 0;
   virtual void set_pos(const LVector3f&) = 0;
+  INLINE void set_priority(const Priority);
 
 
   INLINE float get_scale(void) const;
   INLINE float get_scale(void) const;
   INLINE LVector3f get_pos(void) const;
   INLINE LVector3f get_pos(void) const;
@@ -37,6 +42,7 @@ PUBLISHED:
   INLINE float get_bottom(void) const;
   INLINE float get_bottom(void) const;
   INLINE float get_top(void) const;
   INLINE float get_top(void) const;
   INLINE LVector4f get_frame(void) const;
   INLINE LVector4f get_frame(void) const;
+  INLINE Priority get_priority(void) const;
 
 
   INLINE void recompute(void);
   INLINE void recompute(void);
 
 

+ 2 - 2
panda/src/testbed/deadrec_rec.cxx

@@ -443,14 +443,14 @@ inline static void predict_linear(void) {
 	B_time = telemetry_time;
 	B_time = telemetry_time;
 	V = B - A;
 	V = B - A;
 	V *= 1. / (B_time - A_time);
 	V *= 1. / (B_time - A_time);
-	//	time = 0.;
+	time = 0.;
       } else {
       } else {
 	// is between our two samples
 	// is between our two samples
 	A = telemetry_pos;
 	A = telemetry_pos;
 	A_time = telemetry_time;
 	A_time = telemetry_time;
 	V = B - A;
 	V = B - A;
 	V *= 1. / (B_time - A_time);
 	V *= 1. / (B_time - A_time);
-	//	time = 0.;
+	time = 0.;
       }
       }
     }
     }
     if (time <= 0.) {
     if (time <= 0.) {