Panda3D
 All Classes Functions Variables Enumerations
dynamicTextGlyph.I
1 // Filename: dynamicTextGlyph.I
2 // Created by: drose (09Feb02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: DynamicTextGlyph::Constructor
19 // Access: Public
20 // Description:
21 ////////////////////////////////////////////////////////////////////
22 INLINE DynamicTextGlyph::
23 DynamicTextGlyph(int character, DynamicTextPage *page, int x, int y,
24  int x_size, int y_size, int margin) :
25  TextGlyph(character),
26  _page(page),
27  _x(x), _y(y),
28  _x_size(x_size), _y_size(y_size),
29  _margin(margin),
30  _top(0), _left(0), _bottom(0), _right(0),
31  _uv_top(0), _uv_left(0), _uv_bottom(0), _uv_right(0)
32 {
33  _geom_count = 0;
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: DynamicTextGlyph::Constructor
38 // Access: Public
39 // Description: This constructor makes an empty glyph, whose only
40 // purpose is to remember its width. It has no bitmap
41 // and no Geom.
42 ////////////////////////////////////////////////////////////////////
43 INLINE DynamicTextGlyph::
44 DynamicTextGlyph(int character, PN_stdfloat advance) :
45  TextGlyph(character),
46  _page((DynamicTextPage *)NULL),
47  _x(0), _y(0),
48  _x_size(0), _y_size(0),
49  _margin(0)
50 {
51  _advance = advance;
52  _geom_count = 1;
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function: DynamicTextGlyph::Copy Constructor
57 // Access: Private
58 // Description: Copying DynamicTextGlyph objects is not allowed.
59 ////////////////////////////////////////////////////////////////////
60 INLINE DynamicTextGlyph::
61 DynamicTextGlyph(const DynamicTextGlyph &) :
62  TextGlyph(0)
63 {
64  nassertv(false);
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: DynamicTextGlyph::Copy Assignment Operator
69 // Access: Private
70 // Description: Copying DynamicTextGlyph objects is not allowed.
71 ////////////////////////////////////////////////////////////////////
72 INLINE void DynamicTextGlyph::
73 operator = (const DynamicTextGlyph &) {
74  nassertv(false);
75 }
76 
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: DynamicTextGlyph::get_page
80 // Access: Published
81 // Description: Returns the DynamicTextPage that this glyph is on.
82 ////////////////////////////////////////////////////////////////////
83 INLINE DynamicTextPage *DynamicTextGlyph::
84 get_page() const {
85  return _page;
86 }
87 
88 ////////////////////////////////////////////////////////////////////
89 // Function: DynamicTextGlyph::intersects
90 // Access: Published
91 // Description: Returns true if the particular position this glyph
92 // has been assigned to overlaps the rectangle whose
93 // top left corner is at x, y and whose size is given by
94 // x_size, y_size, or false otherwise.
95 ////////////////////////////////////////////////////////////////////
96 INLINE bool DynamicTextGlyph::
97 intersects(int x, int y, int x_size, int y_size) const {
98  int hright = x + x_size;
99  int hbot = y + y_size;
100 
101  int mright = _x + _x_size;
102  int mbot = _y + _y_size;
103 
104  return !(x >= mright || hright <= _x ||
105  y >= mbot || hbot <= _y);
106 }
107 
108 ////////////////////////////////////////////////////////////////////
109 // Function: DynamicTextGlyph::get_top
110 // Access: Published
111 // Description: Returns the vertex coordinates that can be used when
112 // creating a custom text renderer.
113 ////////////////////////////////////////////////////////////////////
114 INLINE PN_stdfloat DynamicTextGlyph::
115 get_top() const {
116  return _top;
117 }
118 
119 ////////////////////////////////////////////////////////////////////
120 // Function: DynamicTextGlyph::get_left
121 // Access: Published
122 // Description: Returns the vertex coordinates that can be used when
123 // creating a custom text renderer.
124 ////////////////////////////////////////////////////////////////////
125 INLINE PN_stdfloat DynamicTextGlyph::
126 get_left() const {
127  return _left;
128 }
129 
130 ////////////////////////////////////////////////////////////////////
131 // Function: DynamicTextGlyph::get_bottom
132 // Access: Published
133 // Description: Returns the vertex coordinates that can be used when
134 // creating a custom text renderer.
135 ////////////////////////////////////////////////////////////////////
136 INLINE PN_stdfloat DynamicTextGlyph::
137 get_bottom() const {
138  return _bottom;
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: DynamicTextGlyph::get_right
143 // Access: Published
144 // Description: Returns the vertex coordinates that can be used when
145 // creating a custom text renderer.
146 ////////////////////////////////////////////////////////////////////
147 INLINE PN_stdfloat DynamicTextGlyph::
148 get_right() const {
149  return _right;
150 }
151 
152 ////////////////////////////////////////////////////////////////////
153 // Function: DynamicTextGlyph::get_uv_top
154 // Access: Published
155 // Description: Returns the UV coordinates that can be used when
156 // creating a custom text renderer.
157 ////////////////////////////////////////////////////////////////////
158 INLINE PN_stdfloat DynamicTextGlyph::
159 get_uv_top() const {
160  return _uv_top;
161 }
162 
163 ////////////////////////////////////////////////////////////////////
164 // Function: DynamicTextGlyph::get_uv_left
165 // Access: Published
166 // Description: Returns the UV coordinates that can be used when
167 // creating a custom text renderer.
168 ////////////////////////////////////////////////////////////////////
169 INLINE PN_stdfloat DynamicTextGlyph::
170 get_uv_left() const {
171  return _uv_left;
172 }
173 
174 ////////////////////////////////////////////////////////////////////
175 // Function: DynamicTextGlyph::get_uv_bottom
176 // Access: Published
177 // Description: Returns the UV coordinates that can be used when
178 // creating a custom text renderer.
179 ////////////////////////////////////////////////////////////////////
180 INLINE PN_stdfloat DynamicTextGlyph::
181 get_uv_bottom() const {
182  return _uv_bottom;
183 }
184 
185 ////////////////////////////////////////////////////////////////////
186 // Function: DynamicTextGlyph::get_uv_right
187 // Access: Published
188 // Description: Returns the UV coordinates that can be used when
189 // creating a custom text renderer.
190 ////////////////////////////////////////////////////////////////////
191 INLINE PN_stdfloat DynamicTextGlyph::
192 get_uv_right() const {
193  return _uv_right;
194 }
A representation of a single glyph (character) from a font.
Definition: textGlyph.h:31