pgFrameStyle.I 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file pgFrameStyle.I
  10. * @author drose
  11. * @date 2001-07-03
  12. */
  13. /**
  14. *
  15. */
  16. INLINE PGFrameStyle::
  17. PGFrameStyle() {
  18. _type = T_none;
  19. _color.set(1.0f, 1.0f, 1.0f, 1.0f);
  20. _width.set(0.1f, 0.1f);
  21. _uv_width.set(0.1f, 0.1f);
  22. _visible_scale.set(1.0f, 1.0f);
  23. }
  24. /**
  25. *
  26. */
  27. INLINE PGFrameStyle::
  28. PGFrameStyle(const PGFrameStyle &copy) :
  29. _type(copy._type),
  30. _color(copy._color),
  31. _texture(copy._texture),
  32. _width(copy._width),
  33. _uv_width(copy._uv_width),
  34. _visible_scale(copy._visible_scale)
  35. {
  36. }
  37. /**
  38. *
  39. */
  40. INLINE void PGFrameStyle::
  41. operator = (const PGFrameStyle &copy) {
  42. _type = copy._type;
  43. _color = copy._color;
  44. _texture = copy._texture;
  45. _width = copy._width;
  46. _uv_width = copy._uv_width;
  47. _visible_scale = copy._visible_scale;
  48. }
  49. /**
  50. *
  51. */
  52. INLINE PGFrameStyle::
  53. ~PGFrameStyle() {
  54. }
  55. /**
  56. * Sets the basic type of frame.
  57. */
  58. INLINE void PGFrameStyle::
  59. set_type(PGFrameStyle::Type type) {
  60. _type = type;
  61. }
  62. /**
  63. * Returns the basic type of frame.
  64. */
  65. INLINE PGFrameStyle::Type PGFrameStyle::
  66. get_type() const {
  67. return _type;
  68. }
  69. /**
  70. * Sets the dominant color of the frame.
  71. */
  72. INLINE void PGFrameStyle::
  73. set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
  74. set_color(LColor(r, g, b, a));
  75. }
  76. /**
  77. * Sets the dominant color of the frame.
  78. */
  79. INLINE void PGFrameStyle::
  80. set_color(const LColor &color) {
  81. _color = color;
  82. }
  83. /**
  84. * Returns the dominant color of the frame.
  85. */
  86. INLINE LColor PGFrameStyle::
  87. get_color() const {
  88. return _color;
  89. }
  90. /**
  91. * Specifies a texture that should be applied to the frame.
  92. */
  93. INLINE void PGFrameStyle::
  94. set_texture(Texture *texture) {
  95. _texture = texture;
  96. }
  97. /**
  98. * Returns true if a texture has been applied to the frame.
  99. */
  100. INLINE bool PGFrameStyle::
  101. has_texture() const {
  102. return !_texture.is_null();
  103. }
  104. /**
  105. * Returns the texture that has been applied to the frame, or NULL if no
  106. * texture has been applied.
  107. */
  108. INLINE Texture *PGFrameStyle::
  109. get_texture() const {
  110. return _texture;
  111. }
  112. /**
  113. * Removes the texture from the frame.
  114. */
  115. INLINE void PGFrameStyle::
  116. clear_texture() {
  117. _texture.clear();
  118. }
  119. /**
  120. * Sets the width parameter, which has meaning only for certain frame types.
  121. * For instance, this is the width of the bevel for T_bevel_in or T_bevel_out.
  122. * The units are in screen units.
  123. */
  124. INLINE void PGFrameStyle::
  125. set_width(PN_stdfloat x, PN_stdfloat y) {
  126. set_width(LVecBase2(x, y));
  127. }
  128. /**
  129. * Sets the width parameter, which has meaning only for certain frame types.
  130. * For instance, this is the width of the bevel for T_bevel_in or T_bevel_out.
  131. * The units are in screen units.
  132. */
  133. INLINE void PGFrameStyle::
  134. set_width(const LVecBase2 &width) {
  135. _width = width;
  136. }
  137. /**
  138. * Returns the width parameter, which has meaning only for certain frame
  139. * types. For instance, this is the width of the bevel for T_bevel_in or
  140. * T_bevel_out. The units are in screen units.
  141. */
  142. INLINE const LVecBase2 &PGFrameStyle::
  143. get_width() const {
  144. return _width;
  145. }
  146. /**
  147. * Sets the uv_width parameter, which indicates the amount of the texture that
  148. * is consumed by the inner bevel--the width in texture space of the amount
  149. * indicated by set_width.
  150. */
  151. INLINE void PGFrameStyle::
  152. set_uv_width(PN_stdfloat u, PN_stdfloat v) {
  153. set_uv_width(LVecBase2(u, v));
  154. }
  155. /**
  156. * Sets the uv_width parameter, which indicates the amount of the texture that
  157. * is consumed by the inner bevel--the width in texture space of the amount
  158. * indicated by set_width.
  159. */
  160. INLINE void PGFrameStyle::
  161. set_uv_width(const LVecBase2 &uv_width) {
  162. _uv_width = uv_width;
  163. }
  164. /**
  165. * See set_uv_width().
  166. */
  167. INLINE const LVecBase2 &PGFrameStyle::
  168. get_uv_width() const {
  169. return _uv_width;
  170. }
  171. /**
  172. * Sets a scale factor on the visible representation of the frame, in the X
  173. * and Y directions. If this scale factor is other than 1, it will affect the
  174. * size of the visible frame representation within the actual frame border.
  175. */
  176. INLINE void PGFrameStyle::
  177. set_visible_scale(PN_stdfloat x, PN_stdfloat y) {
  178. set_visible_scale(LVecBase2(x, y));
  179. }
  180. /**
  181. * Sets a scale factor on the visible representation of the frame, in the X
  182. * and Y directions. If this scale factor is other than 1, it will affect the
  183. * size of the visible frame representation within the actual frame border.
  184. */
  185. INLINE void PGFrameStyle::
  186. set_visible_scale(const LVecBase2 &visible_scale) {
  187. _visible_scale = visible_scale;
  188. }
  189. /**
  190. * Returns the scale factor on the visible representation of the frame, in the
  191. * X and Y directions. If this scale factor is other than 1, it will affect
  192. * the size of the visible frame representation within the actual frame
  193. * border.
  194. */
  195. INLINE const LVecBase2 &PGFrameStyle::
  196. get_visible_scale() const {
  197. return _visible_scale;
  198. }
  199. /**
  200. *
  201. */
  202. INLINE std::ostream &
  203. operator << (std::ostream &out, const PGFrameStyle &pfs) {
  204. pfs.output(out);
  205. return out;
  206. }