48class EXPCL_PANDA_TEXT TextNode :
public PandaNode,
public TextEncoder,
public TextProperties {
50 explicit TextNode(
const std::string &name);
51 explicit TextNode(
const std::string &name,
const TextProperties ©);
53 TextNode(
const TextNode ©);
64 FF_dynamic_merge = 0x0008,
75 INLINE
void set_frame_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a);
76 INLINE
void set_frame_color(
const LColor &frame_color);
77 INLINE LColor get_frame_color()
const;
79 INLINE
void set_card_border(PN_stdfloat size, PN_stdfloat uv_portion);
80 INLINE
void clear_card_border();
81 INLINE PN_stdfloat get_card_border_size()
const;
82 INLINE PN_stdfloat get_card_border_uv_portion()
const;
83 INLINE
bool has_card_border()
const;
85 INLINE
void set_card_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a);
86 INLINE
void set_card_color(
const LColor &card_color);
87 INLINE LColor get_card_color()
const;
89 INLINE
void set_card_texture(
Texture *card_texture);
90 INLINE
void clear_card_texture();
91 INLINE
bool has_card_texture()
const;
92 INLINE
Texture *get_card_texture()
const;
95 PN_stdfloat bottom, PN_stdfloat top);
97 PN_stdfloat bottom, PN_stdfloat top);
99 INLINE
bool has_frame()
const;
107 INLINE
bool get_frame_corners()
const;
110 PN_stdfloat bottom, PN_stdfloat top);
112 PN_stdfloat bottom, PN_stdfloat top);
115 INLINE
bool has_card()
const;
123 INLINE LMatrix4 get_transform()
const;
126 INLINE CoordinateSystem get_coordinate_system()
const;
141 INLINE
void clear_small_caps();
144 INLINE
void clear_small_caps_scale();
146 INLINE
void set_slant(PN_stdfloat slant);
147 INLINE
void clear_slant();
149 INLINE
void set_align(Alignment align_type);
158 INLINE
void set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a);
162 INLINE
void set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a);
163 INLINE
void set_shadow_color(
const LColor &shadow_color);
166 INLINE
void set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset);
167 INLINE
void set_shadow(
const LVecBase2 &shadow_offset);
170 INLINE
void set_bin(
const std::string &bin);
174 INLINE
void clear_draw_order();
177 INLINE
void clear_tab_width();
180 INLINE
void clear_glyph_scale();
183 INLINE
void clear_glyph_shift();
191 PN_stdfloat
calc_width(
wchar_t character)
const;
192 INLINE PN_stdfloat
calc_width(
const std::string &line)
const;
199 PN_stdfloat
calc_width(
const std::wstring &line)
const;
201 virtual void output(std::ostream &out)
const;
202 virtual void write(std::ostream &out,
int indent_level = 0)
const;
206 INLINE PN_stdfloat
get_left()
const;
209 INLINE PN_stdfloat
get_top()
const;
218 INLINE PT(PandaNode) generate();
222 PT(PandaNode) get_internal_geom()
const;
226 MAKE_PROPERTY(frame_color, get_frame_color, set_frame_color);
227 MAKE_PROPERTY(card_color, get_card_color, set_card_color);
228 MAKE_PROPERTY(card_texture, get_card_texture, set_card_texture);
237 MAKE_PROPERTY2(small_caps, has_small_caps, get_small_caps,
239 MAKE_PROPERTY2(small_caps_scale, has_small_caps_scale, get_small_caps_scale,
241 MAKE_PROPERTY2(slant, has_slant, get_slant, set_slant, clear_slant);
242 MAKE_PROPERTY2(underscore, has_underscore, get_underscore,
243 set_underscore, clear_underscore);
244 MAKE_PROPERTY2(underscore_height, has_underscore_height, get_underscore_height,
245 set_underscore_height, clear_underscore_height);
246 MAKE_PROPERTY2(align, has_align, get_align, set_align, clear_align);
249 MAKE_PROPERTY2(preserve_trailing_whitespace,
250 has_preserve_trailing_whitespace, get_preserve_trailing_whitespace,
251 set_preserve_trailing_whitespace, clear_preserve_trailing_whitespace);
252 MAKE_PROPERTY2(text_color, has_text_color, get_text_color,
254 MAKE_PROPERTY2(shadow_color, has_shadow_color, get_shadow_color,
255 set_shadow_color, clear_shadow_color);
258 MAKE_PROPERTY2(draw_order, has_draw_order, get_draw_order,
260 MAKE_PROPERTY2(tab_width, has_tab_width, get_tab_width,
262 MAKE_PROPERTY2(glyph_scale, has_glyph_scale, get_glyph_scale,
264 MAKE_PROPERTY2(glyph_shift, has_glyph_shift, get_glyph_shift,
266 MAKE_PROPERTY2(text_scale, has_text_scale, get_text_scale,
267 set_text_scale, clear_text_scale);
282 Thread *current_thread) const;
288 int &internal_vertices,
290 Thread *current_thread) const;
298 INLINE
void invalidate_no_measure();
299 INLINE
void invalidate_with_measure();
300 INLINE
void check_rebuild() const;
301 INLINE
void check_measure() const;
306 PT(PandaNode) do_generate();
307 PT(PandaNode) do_get_internal_geom() const;
309 PT(PandaNode) make_frame();
310 PT(PandaNode) make_card();
311 PT(PandaNode) make_card_with_border();
313 static
int count_geoms(PandaNode *node);
316 PT(PandaNode) _internal_geom;
323 F_has_frame = 0x0001,
324 F_frame_as_margin = 0x0002,
326 F_card_as_margin = 0x0008,
327 F_has_card_texture = 0x0010,
328 F_frame_corners = 0x0020,
329 F_card_transp = 0x0040,
330 F_has_card_border = 0x0080,
331 F_needs_rebuild = 0x0100,
332 F_needs_measure = 0x0200,
333 F_has_overflow = 0x0400,
334 F_card_decal = 0x0800,
339 GeomEnums::UsageHint _usage_hint;
341 PN_stdfloat _frame_width;
342 PN_stdfloat _card_border_size;
343 PN_stdfloat _card_border_uv_portion;
345 LVector2 _frame_ul, _frame_lr;
346 LVector2 _card_ul, _card_lr;
349 CoordinateSystem _coordinate_system;
351 LPoint3 _ul3d, _lr3d;
354 LVector2 _text_ul, _text_lr;
356 std::wstring _wordwrapped_wtext;
364 static void init_type() {
365 PandaNode::init_type();
366 TextProperties::init_type();
368 PandaNode::get_class_type(),
369 TextProperties::get_class_type());
371 virtual TypeHandle get_type()
const {
372 return get_class_type();
374 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
377 static TypeHandle _type_handle;
This class is used by the SceneGraphReducer to maintain and accumulate the set of attributes we have ...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A standard mutex, or mutual exclusion lock.
A lightweight class that represents a single element that may be timed and/or counted via stats.
set_transform
Sets the transform that will be applied to this node and below.
virtual ConstPointerTo< TransformState > calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread=Thread::get_current_thread()) const
This is used to support NodePath::calc_tight_bounds().
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
An encapsulation of a font; i.e.
set_glyph_scale
Specifies the factor by which to scale each letter of the text as it is placed.
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.
void clear_card()
Specifies that a card will not be drawn behind the text.
clear_wordwrap
Removes the wordwrap setting from the TextNode.
LVecBase4 get_frame_actual() const
Returns the actual dimensions of the frame around the text.
LVecBase4 get_frame_as_set() const
Returns the dimensions of the frame as set by set_frame_as_margin() or set_frame_actual().
set_text_color
Sets the color of the text.
PN_stdfloat get_bottom() const
Returns the bottommost extent of the text in local 2-d coordinates, unmodified by the set_transform()...
PN_stdfloat get_left() const
Returns the leftmost extent of the text in local 2-d coordinates, unmodified by the set_transform() m...
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...
bool has_exact_character(wchar_t character) const
Returns true if the named character exists in the font exactly as named, false otherwise.
virtual void r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, GeomTransformer &transformer, Thread *current_thread)
The recursive implementation of prepare_scene().
virtual void text_changed() final
Given that we have just read an ampersand from the StringDecoder, and that we have expand_amp in effe...
virtual int get_unsafe_to_apply_attribs() const
Returns the union of all attributes from SceneGraphReducer::AttribTypes that may not safely be applie...
get_usage_hint
Returns the UsageHint that will be applied to generated geometry.
LVecBase4 get_card_as_set() const
Returns the dimensions of the card as set by set_card_as_margin() or set_card_actual().
PN_stdfloat get_line_height() const
Returns the number of units high each line of text is.
set_max_rows
Sets the maximum number of rows that may be formatted by the TextNode.
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_indent
Specifies the amount of extra space that is inserted before the first character of each line.
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.
clear_text_color
Removes the text color specification; the text will be colored whatever it was in the source font fil...
int get_num_rows() const
Returns the number of rows of text that were generated.
set_frame_corners
Enables or disables the drawing of corners for the frame.
set_shadow
Specifies that the text should be drawn with a shadow, by creating a second copy of the text and offs...
set_wordwrap
Sets the text up to automatically wordwrap when it exceeds the indicated width.
void clear_max_rows()
Resets the TextNode's default behavior of not limiting the number of rows of text.
clear_font
Resets the font to the default font.
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...
set_tab_width
Sets the width of each tab stop, in screen units.
get_frame_line_width
Returns the thickness of the lines that will be used to draw the frame.
void update()
Can be called after the TextNode has been fully configured, to force the node to recompute its text i...
PN_stdfloat get_top() const
Returns the topmost extent of the text in local 2-d coordinates, unmodified by the set_transform() ma...
get_max_rows
Returns the limit on the height of the TextNode specified by set_max_rows().
set_usage_hint
Specifies the UsageHint that will be applied to generated geometry.
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
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.
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...
LVecBase4 get_card_transformed() const
Returns the actual card dimensions, transformed by the matrix set by set_transform().
bool has_max_rows() const
Returns true if a limit on the height of the TextNode has been set via set_max_rows(),...
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...
set_draw_order
Sets the drawing order of text created by the TextMaker.
set_small_caps_scale
Sets the scale factor applied to lowercase letters from their uppercase equivalents,...
virtual void apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer)
Applies whatever attributes are specified in the AccumulatedAttribs object (and by the attrib_types b...
get_flatten_flags
Returns the flatten flags.
virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, int pipeline_stage, Thread *current_thread) const
Called when needed to recompute the node's _internal_bound object.
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...
LVecBase4 get_card_actual() const
Returns the actual dimensions of the card around the text.
PN_stdfloat get_height() const
Returns the net height of the text in local 2-d coordinates.
bool is_whitespace(wchar_t character) const
Returns true if the indicated character represents whitespace in the font, or false if anything visib...
bool has_overflow() const
Returns true if the last text set on the text node exceeded the max_rows constraint,...
set_frame_line_width
Specifies the thickness of the lines that will be used to draw the frame.
PN_stdfloat get_width() const
Returns the net width of the text in local 2-d coordinates.
bool has_character(wchar_t character) const
Returns true if the named character exists in the font or can be synthesized by Panda,...
set_flatten_flags
Sets the flatten flags.
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
set_coordinate_system
Specifies the coordinate system in which the text will be generated.
void force_update()
Forces the TextNode to recompute itself now, even if it believes nothing has changed.
set_small_caps
Sets the small_caps flag.
PN_stdfloat get_right() const
Returns the rightmost extent of the text in local 2-d coordinates, unmodified by the set_transform() ...
void clear_frame()
Specifies that a border will not be drawn around the text.
set_bin
Names the GeomBin that the TextNode geometry should be assigned to.
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...
set_transform
Sets an additional transform that is applied to the entire text paragraph.
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...
clear_bin
Removes the effect of a previous call to set_bin().
set_glyph_shift
Specifies a vertical amount to shift each letter of the text as it is placed.
std::wstring get_wordwrapped_wtext() const
Returns a wstring that represents the contents of the text, as it has been formatted by wordwrap rule...
bool get_card_decal() const
Returns the card_decal flag.
set_font
Sets the font that will be used when making text.
set_glyph_shift
Specifies a vertical amount to shift each letter of the text as it is placed.
set_shadow
Specifies that the text should be drawn with a shadow, by creating a second copy of the text and offs...
set_align
Specifies the alignment of the text within its margins.
clear_bin
Removes the effect of a previous call to set_bin().
clear_font
Restores the default font to the text.
clear_shadow
Specifies that a shadow will not be drawn behind the text.
set_draw_order
Sets the drawing order of text created by the TextNode.
set_wordwrap
Sets the text up to automatically wordwrap when it exceeds the indicated width.
clear_indent
Removes the indent setting from the text.
clear_shadow_color
Removes the shadow color specification.
set_font
Sets the font that will be used when making text.
set_small_caps_scale
Sets the scale factor applied to lowercase letters from their uppercase equivalents,...
set_tab_width
Sets the width of each tab stop, in screen units.
clear_text_color
Removes the text color specification; the text will be colored whatever it was in the source font fil...
set_glyph_scale
Specifies the factor by which to scale each letter of the text as it is placed, in addition to any sc...
clear_wordwrap
Removes the wordwrap setting from the text.
set_indent
Specifies the amount of extra space that is inserted before the first character of each line.
clear_align
Restores the default alignment of the text.
set_text_color
Sets the color of the text.
set_small_caps
Sets the small_caps flag.
set_slant
Specifies the factor by which the text slants to the right.
set_bin
Names the CullBin that the text geometry should be assigned to.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
A thread; that is, a lightweight process.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.