guiLabel.I 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. // Filename: guiLabel.I
  2. // Created by: cary (26Oct00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. INLINE GuiLabel::GuiLabel(void) : _type(GuiLabel::NONE),
  19. _arc((RenderRelation*)0L),
  20. _tex((Texture*)0L),
  21. _internal((RenderRelation*)0L),
  22. _gset((Geom*)0L), _model_width(1.),
  23. _model_height(1.), _scale(1.),
  24. _scale_x(1.), _scale_y(1.), _scale_z(1.),
  25. _pos(0., 0., 0.),
  26. _model_pos(0., 0., 0.),
  27. _have_foreground(false),
  28. _foreground(1., 1., 1., 1.),
  29. _have_background(false),
  30. _background(0., 0., 0., 0.),
  31. _have_width(false), _width(0.),
  32. _have_height(false), _height(0.),
  33. _mirror_x(false), _mirror_y(false),
  34. _hard_pri(0), _highest_pri(false),
  35. _lowest_pri(false), _has_hard_pri(false) {
  36. }
  37. INLINE Node* GuiLabel::get_geometry(void) const {
  38. return _geom;
  39. }
  40. INLINE void GuiLabel::set_arc(RenderRelation* r) {
  41. _arc = r;
  42. }
  43. INLINE RenderRelation* GuiLabel::get_arc(void) const {
  44. return _arc;
  45. }
  46. INLINE void GuiLabel::set_width(float f) {
  47. if (f <= 0.) {
  48. _have_width = false;
  49. _width = 0.;
  50. } else {
  51. if (_type == MODEL)
  52. _width = f / this->_model_width;
  53. else
  54. _width = f;
  55. _have_width = true;
  56. }
  57. this->set_properties();
  58. }
  59. INLINE void GuiLabel::set_height(float f) {
  60. if (f <= 0.) {
  61. _have_height = false;
  62. _height = 0.;
  63. } else {
  64. if (_type == MODEL)
  65. _height = f / this->_model_height;
  66. else
  67. _height = f;
  68. _have_height = true;
  69. }
  70. this->set_properties();
  71. }
  72. INLINE void GuiLabel::set_scale(float f) {
  73. _scale = f;
  74. recompute_transform();
  75. }
  76. INLINE void GuiLabel::set_scale(float x, float y, float z) {
  77. _scale_x = x;
  78. _scale_y = y;
  79. _scale_z = z;
  80. recompute_transform();
  81. }
  82. INLINE void GuiLabel::set_mirror_x(bool b) {
  83. _mirror_x = b;
  84. }
  85. INLINE void GuiLabel::set_mirror_y(bool b) {
  86. _mirror_y = b;
  87. }
  88. INLINE void GuiLabel::set_pos(float x, float y, float z) {
  89. this->set_pos(LVector3f(x, y, z));
  90. }
  91. INLINE void GuiLabel::set_pos(const LVector3f& p) {
  92. _pos = p;
  93. recompute_transform();
  94. }
  95. INLINE float GuiLabel::get_scale(void) const {
  96. return _scale;
  97. }
  98. INLINE bool GuiLabel::get_mirror_x(void) const {
  99. return _mirror_x;
  100. }
  101. INLINE bool GuiLabel::get_mirror_y(void) const {
  102. return _mirror_y;
  103. }
  104. INLINE LVector3f GuiLabel::get_pos(void) const {
  105. return _pos;
  106. }
  107. INLINE void GuiLabel::set_foreground_color(float r, float g, float b,
  108. float a) {
  109. this->_have_foreground = true;
  110. this->set_foreground_color(Colorf(r, g, b, a));
  111. }
  112. INLINE void GuiLabel::set_background_color(float r, float g, float b,
  113. float a) {
  114. this->set_background_color(Colorf(r, g, b, a));
  115. }
  116. INLINE Colorf GuiLabel::get_foreground_color(void) const {
  117. return _foreground;
  118. }
  119. INLINE Colorf GuiLabel::get_background_color(void) const {
  120. return _background;
  121. }
  122. INLINE void GuiLabel::set_shadow_color(float r, float g, float b, float a) {
  123. this->set_shadow_color(Colorf(r, g, b, a));
  124. }
  125. INLINE void GuiLabel::recompute(void) {
  126. this->recompute_transform();
  127. }
  128. INLINE void GuiLabel::set_priority(GuiLabel* l, const PriorityType t) {
  129. if (t == P_HIGHEST)
  130. _highest_pri = true;
  131. else if (t == P_LOWEST)
  132. _lowest_pri = true;
  133. else
  134. this->_priorities[l] = t;
  135. }
  136. INLINE bool GuiLabel::has_hard_draw_order(void) const {
  137. return _has_hard_pri;
  138. }
  139. INLINE int GuiLabel::get_draw_order(void) const {
  140. return _hard_pri;
  141. }