22 if (font ==
nullptr) {
38 invalidate_with_measure();
49 invalidate_with_measure();
67 get_max_rows()
const {
80 return (_flags & F_has_overflow) != 0;
86 INLINE
void TextNode::
87 set_frame_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
88 set_frame_color(LColor(r, g, b, a));
94 INLINE
void TextNode::
95 set_frame_color(
const LColor &frame_color) {
97 if (_frame_color != frame_color) {
98 _frame_color = frame_color;
99 invalidate_no_measure();
106 INLINE LColor TextNode::
107 get_frame_color()
const {
115 INLINE
void TextNode::
116 set_card_border(PN_stdfloat size, PN_stdfloat uv_portion) {
118 if ((_flags & F_has_card_border) == 0 || _card_border_size != size || _card_border_uv_portion != uv_portion) {
119 _flags |= F_has_card_border;
120 _card_border_size = size;
121 _card_border_uv_portion = uv_portion;
122 invalidate_no_measure();
129 INLINE
void TextNode::
130 clear_card_border() {
132 if (_flags & F_has_card_border) {
133 _flags &= ~F_has_card_border;
134 invalidate_no_measure();
141 INLINE PN_stdfloat TextNode::
142 get_card_border_size()
const {
144 return _card_border_size;
150 INLINE PN_stdfloat TextNode::
151 get_card_border_uv_portion()
const {
153 return _card_border_uv_portion;
159 INLINE
bool TextNode::
160 has_card_border()
const {
162 return (_flags & F_has_card_border) != 0;
168 INLINE
void TextNode::
169 set_card_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
170 set_card_color(LColor(r, g, b, a));
176 INLINE
void TextNode::
177 set_card_color(
const LColor &card_color) {
179 if (_card_color != card_color) {
180 _card_color = card_color;
181 invalidate_no_measure();
188 INLINE LColor TextNode::
189 get_card_color()
const {
197 INLINE
void TextNode::
198 set_card_texture(
Texture *card_texture) {
199 if (card_texture ==
nullptr) {
200 clear_card_texture();
203 if ((_flags & F_has_card_texture) == 0 || _card_texture != card_texture) {
204 _flags |= F_has_card_texture;
205 _card_texture = card_texture;
206 invalidate_no_measure();
214 INLINE
void TextNode::
215 clear_card_texture() {
217 if (_flags & F_has_card_texture) {
218 _flags &= ~F_has_card_texture;
219 _card_texture =
nullptr;
220 invalidate_no_measure();
227 INLINE
bool TextNode::
228 has_card_texture()
const {
230 return (_flags & F_has_card_texture) != 0;
237 get_card_texture()
const {
239 return _card_texture;
251 _flags |= (F_has_frame | F_frame_as_margin);
252 _frame_ul.set(left, top);
253 _frame_lr.set(right, bottom);
254 invalidate_no_measure();
264 set_frame_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
266 _flags |= F_has_frame;
267 _flags &= ~F_frame_as_margin;
268 _frame_ul.set(left, top);
269 _frame_lr.set(right, bottom);
270 invalidate_no_measure();
279 _flags &= ~F_has_frame;
280 invalidate_no_measure();
286 INLINE
bool TextNode::
289 return (_flags & F_has_frame) != 0;
302 nassertr((_flags & F_has_frame) != 0,
false);
303 return (_flags & F_frame_as_margin) != 0;
315 nassertr((_flags & F_has_frame) != 0, LVecBase4(0.0, 0.0, 0.0, 0.0));
316 return LVecBase4(_frame_ul[0], _frame_lr[0], _frame_lr[1], _frame_ul[1]);
331 if (_flags & F_has_frame) {
332 if (_flags & F_frame_as_margin) {
334 return LVecBase4(_text_ul[0] - _frame_ul[0],
335 _text_lr[0] + _frame_lr[0],
336 _text_lr[1] - _frame_lr[1],
337 _text_ul[1] + _frame_ul[1]);
339 return LVecBase4(_frame_ul[0], _frame_lr[0], _frame_lr[1], _frame_ul[1]);
343 return LVecBase4(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]);
353 _frame_width = frame_width;
354 invalidate_no_measure();
360 INLINE PN_stdfloat TextNode::
361 get_frame_line_width()
const {
375 _flags |= F_frame_corners;
377 _flags &= ~F_frame_corners;
379 invalidate_no_measure();
385 INLINE
bool TextNode::
386 get_frame_corners()
const {
388 return (_flags & F_frame_corners) != 0;
400 _flags |= (F_has_card | F_card_as_margin);
401 _card_ul.set(left, top);
402 _card_lr.set(right, bottom);
403 invalidate_no_measure();
413 set_card_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
415 _flags |= F_has_card;
416 _flags &= ~F_card_as_margin;
417 _card_ul.set(left, top);
418 _card_lr.set(right, bottom);
419 invalidate_no_measure();
431 _flags |= F_card_decal;
433 _flags &= ~F_card_decal;
435 invalidate_no_measure();
444 _flags &= ~F_has_card;
445 invalidate_no_measure();
451 INLINE
bool TextNode::
454 return (_flags & F_has_card) != 0;
463 return (_flags & F_card_decal) != 0;
476 nassertr((_flags & F_has_card) != 0,
false);
477 return (_flags & F_card_as_margin) != 0;
489 nassertr((_flags & F_has_card) != 0, LVecBase4(0.0, 0.0, 0.0, 0.0));
490 return LVecBase4(_card_ul[0], _card_lr[0], _card_lr[1], _card_ul[1]);
505 if (_flags & F_has_card) {
506 if (_flags & F_card_as_margin) {
508 return LVecBase4(_text_ul[0] - _card_ul[0],
509 _text_lr[0] + _card_lr[0],
510 _text_lr[1] - _card_lr[1],
511 _text_ul[1] + _card_ul[1]);
513 return LVecBase4(_card_ul[0], _card_lr[0], _card_lr[1], _card_ul[1]);
517 return LVecBase4(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]);
532 LPoint3 ul = LPoint3(card[0], 0.0, card[3]) * _transform;
533 LPoint3 lr = LPoint3(card[1], 0.0, card[2]) * _transform;
535 return LVecBase4(ul[0], lr[0], lr[2], ul[2]);
544 _transform = transform;
545 invalidate_with_measure();
551 INLINE LMatrix4 TextNode::
552 get_transform()
const {
563 _coordinate_system = coordinate_system;
564 invalidate_with_measure();
570 INLINE CoordinateSystem TextNode::
571 get_coordinate_system()
const {
573 return _coordinate_system;
585 _usage_hint = usage_hint;
586 invalidate_no_measure();
593 INLINE Geom::UsageHint TextNode::
594 get_usage_hint()
const {
637 _flatten_flags = flatten_flags;
643 INLINE
int TextNode::
644 get_flatten_flags()
const {
646 return _flatten_flags;
657 invalidate_with_measure();
663 INLINE
void TextNode::
667 invalidate_with_measure();
688 invalidate_with_measure();
694 INLINE
void TextNode::
697 TextProperties::clear_small_caps();
698 invalidate_with_measure();
710 invalidate_with_measure();
716 INLINE
void TextNode::
717 clear_small_caps_scale() {
719 TextProperties::clear_small_caps_scale();
720 invalidate_with_measure();
726 INLINE
void TextNode::
727 set_slant(PN_stdfloat slant) {
730 invalidate_with_measure();
736 INLINE
void TextNode::
739 TextProperties::clear_slant();
740 invalidate_with_measure();
746 INLINE
void TextNode::
747 set_align(TextNode::Alignment align_type) {
750 invalidate_with_measure();
756 INLINE
void TextNode::
760 invalidate_with_measure();
771 invalidate_with_measure();
777 INLINE
void TextNode::
781 invalidate_with_measure();
792 invalidate_with_measure();
799 INLINE
void TextNode::
803 invalidate_with_measure();
809 INLINE
void TextNode::
810 set_text_color(
const LColor &text_color) {
812 TextProperties::set_text_color(text_color);
813 invalidate_no_measure();
819 INLINE
void TextNode::
820 set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
821 set_text_color(LColor(r, g, b, a));
828 INLINE
void TextNode::
832 invalidate_no_measure();
838 INLINE
void TextNode::
839 set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
840 set_shadow_color(LColor(r, g, b, a));
846 INLINE
void TextNode::
847 set_shadow_color(
const LColor &shadow_color) {
849 TextProperties::set_shadow_color(shadow_color);
850 invalidate_no_measure();
856 INLINE
void TextNode::
857 clear_shadow_color() {
860 invalidate_with_measure();
868 set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset) {
880 invalidate_no_measure();
886 INLINE
void TextNode::
890 invalidate_no_measure();
903 set_bin(
const std::string &bin) {
906 invalidate_no_measure();
913 INLINE
void TextNode::
917 invalidate_no_measure();
934 invalidate_no_measure();
941 INLINE
void TextNode::
944 TextProperties::clear_draw_order();
945 invalidate_with_measure();
956 invalidate_with_measure();
962 INLINE
void TextNode::
965 TextProperties::clear_tab_width();
966 invalidate_with_measure();
978 invalidate_with_measure();
984 INLINE
void TextNode::
985 clear_glyph_scale() {
987 TextProperties::clear_glyph_scale();
988 invalidate_with_measure();
1000 invalidate_with_measure();
1006 INLINE
void TextNode::
1007 clear_glyph_shift() {
1009 TextProperties::clear_glyph_shift();
1010 invalidate_with_measure();
1045 return _wordwrapped_wtext;
1099 return _text_ul[1] - _text_lr[1];
1109 return _text_lr[0] - _text_ul[0];
1153 return do_generate();
1176 mark_internal_bounds_stale();
1186 INLINE
void TextNode::
1187 invalidate_no_measure() {
1188 _flags |= F_needs_rebuild;
1197 INLINE
void TextNode::
1198 invalidate_with_measure() {
1199 _flags |= (F_needs_rebuild | F_needs_measure);
1200 mark_internal_bounds_stale();
1207 INLINE
void TextNode::
1208 check_rebuild()
const {
1209 if ((_flags & F_needs_rebuild) != 0) {
1218 INLINE
void TextNode::
1219 check_measure()
const {
1220 if ((_flags & F_needs_measure) != 0) {
set_align
Specifies the alignment of the text within its margins.
set_usage_hint
Specifies the UsageHint that will be applied to generated geometry.
void clear_frame()
Specifies that a border will not be drawn around the text.
A basic node of the scene graph or data graph.
LVecBase4 get_card_as_set() const
Returns the dimensions of the card as set by set_card_as_margin() or set_card_actual().
set_coordinate_system
Specifies the coordinate system in which the text will be generated.
set_small_caps
Sets the small_caps flag.
void clear_max_rows()
Resets the TextNode's default behavior of not limiting the number of rows of text.
LPoint3 get_upper_left_3d() const
Returns the upper-left extent of the text object, after it has been transformed into 3-d space by app...
void set_card_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Similar to set_card_as_margin, except the card is specified in actual coordinate units (relative to t...
LVecBase4 get_frame_as_set() const
Returns the dimensions of the frame as set by set_frame_as_margin() or set_frame_actual().
set_tab_width
Sets the width of each tab stop, in screen units.
PN_stdfloat get_top() const
Returns the topmost extent of the text in local 2-d coordinates, unmodified by the set_transform() ma...
void clear_card()
Specifies that a card will not be drawn behind the text.
set_glyph_scale
Specifies the factor by which to scale each letter of the text as it is placed, in addition to any sc...
bool has_overflow() const
Returns true if the last text set on the text node exceeded the max_rows constraint,...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
PN_stdfloat get_bottom() const
Returns the bottommost extent of the text in local 2-d coordinates, unmodified by the set_transform()...
clear_wordwrap
Removes the wordwrap setting from the text.
set_flatten_flags
Sets the flatten flags.
PN_stdfloat get_left() const
Returns the leftmost extent of the text in local 2-d coordinates, unmodified by the set_transform() m...
set_shadow
Specifies that the text should be drawn with a shadow, by creating a second copy of the text and offs...
A lightweight C++ object whose constructor calls acquire() and whose destructor calls release() on a ...
void set_frame_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Specifies that a border will be drawn around the text when it is next created.
bool has_max_rows() const
Returns true if a limit on the height of the TextNode has been set via set_max_rows(),...
PN_stdfloat get_width() const
Returns the net width of the text in local 2-d coordinates.
set_max_rows
Sets the maximum number of rows that may be formatted by the TextNode.
An encapsulation of a font; i.e.
set_tab_width
Sets the width of each tab stop, in screen units.
set_draw_order
Sets the drawing order of text created by the TextMaker.
set_shadow
Specifies that the text should be drawn with a shadow, by creating a second copy of the text and offs...
bool get_card_decal() const
Returns the card_decal flag.
void set_card_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Specifies that a (possibly opaque or semitransparent) card will be held behind the text when it is ne...
LVecBase4 get_frame_actual() const
Returns the actual dimensions of the frame around the text.
set_transform
Sets an additional transform that is applied to the entire text paragraph.
PT(PandaNode) TextNode
Generates the text, according to the parameters indicated within the TextNode, and returns a Node tha...
set_draw_order
Sets the drawing order of text created by the TextNode.
set_small_caps
Sets the small_caps flag.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
clear_shadow_color
Removes the shadow color specification.
set_wordwrap
Sets the text up to automatically wordwrap when it exceeds the indicated width.
clear_text_color
Removes the text color specification; the text will be colored whatever it was in the source font fil...
bool is_card_as_margin() const
If this is true, the card was set via a call to set_card_as_margin(), and the dimension of the card a...
void update()
Can be called after the TextNode has been fully configured, to force the node to recompute its text i...
set_indent
Specifies the amount of extra space that is inserted before the first character of each line.
set_wordwrap
Sets the text up to automatically wordwrap when it exceeds the indicated width.
clear_shadow
Specifies that a shadow will not be drawn behind the text.
void set_card_decal(bool card_decal)
Sets the card_decal flag.
set_frame_corners
Enables or disables the drawing of corners for the frame.
LVecBase4 get_card_actual() const
Returns the actual dimensions of the card around the text.
set_glyph_scale
Specifies the factor by which to scale each letter of the text as it is placed.
get_line_height
Returns the number of units high each line of text is.
std::string encode_wtext(const std::wstring &wtext) const
Encodes a wide-text string into a single-char string, according to the current encoding.
std::string get_wordwrapped_text() const
Returns a string that represents the contents of the text, as it has been formatted by wordwrap rules...
set_glyph_shift
Specifies a vertical amount to shift each letter of the text as it is placed.
set_slant
Specifies the factor by which the text slants to the right.
std::wstring get_wordwrapped_wtext() const
Returns a wstring that represents the contents of the text, as it has been formatted by wordwrap rule...
set_indent
Specifies the amount of extra space that is inserted before the first character of each line.
set_glyph_shift
Specifies a vertical amount to shift each letter of the text as it is placed.
LPoint3 get_lower_right_3d() const
Returns the lower-right extent of the text object, after it has been transformed into 3-d space by ap...
set_bin
Names the CullBin that the text geometry should be assigned to.
clear_font
Restores the default font to the text.
clear_align
Restores the default alignment of the text.
The primary interface to this module.
set_bin
Names the GeomBin that the TextNode geometry should be assigned to.
PN_stdfloat get_line_height() const
Returns the number of units high each line of text is.
set_small_caps_scale
Sets the scale factor applied to lowercase letters from their uppercase equivalents,...
LVecBase4 get_card_transformed() const
Returns the actual card dimensions, transformed by the matrix set by set_transform().
PN_stdfloat get_right() const
Returns the rightmost extent of the text in local 2-d coordinates, unmodified by the set_transform() ...
int get_num_rows() const
Returns the number of rows of text that were generated.
set_font
Sets the font that will be used when making text.
clear_indent
Removes the indent setting from the text.
void force_update()
Forces the TextNode to recompute itself now, even if it believes nothing has changed.
set_small_caps_scale
Sets the scale factor applied to lowercase letters from their uppercase equivalents,...
std::wstring decode_text(const std::string &text) const
Returns the given wstring decoded to a single-byte string, via the current encoding system.
void set_frame_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Similar to set_frame_as_margin, except the frame is specified in actual coordinate units (relative to...
PN_stdfloat calc_width(wchar_t character) const
Returns the width of a single character of the font, or 0.0 if the character is not known.
set_frame_line_width
Specifies the thickness of the lines that will be used to draw the frame.
PN_stdfloat get_height() const
Returns the net height of the text in local 2-d coordinates.
bool is_frame_as_margin() const
If this is true, the frame was set via a call to set_frame_as_margin(), and the dimension of the fram...
clear_bin
Removes the effect of a previous call to set_bin().
set_font
Sets the font that will be used when making text.