forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextNode.I
More file actions
1223 lines (1118 loc) · 30.5 KB
/
textNode.I
File metadata and controls
1223 lines (1118 loc) · 30.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file textNode.I
* @author drose
* @date 2002-03-13
*/
/**
* Returns the number of units high each line of text is. This is based on
* the font. Note that it is possible for the text to include nested font
* change commands, in which case the value of this method is questionable.
*/
INLINE PN_stdfloat TextNode::
get_line_height() const {
TextFont *font = get_font();
if (font == nullptr) {
return 0.0f;
}
return font->get_line_height();
}
/**
* Sets the maximum number of rows that may be formatted by the TextNode. If
* more text than this is attempted, it will be truncated and has_overflow()
* will return true.
*/
INLINE void TextNode::
set_max_rows(int max_rows) {
MutexHolder holder(_lock);
_max_rows = max_rows;
invalidate_with_measure();
}
/**
* Resets the TextNode's default behavior of not limiting the number of rows
* of text.
*/
INLINE void TextNode::
clear_max_rows() {
MutexHolder holder(_lock);
_max_rows = 0;
invalidate_with_measure();
}
/**
* Returns true if a limit on the height of the TextNode has been set via
* set_max_rows(), false otherwise.
*/
INLINE bool TextNode::
has_max_rows() const {
MutexHolder holder(_lock);
return _max_rows > 0;
}
/**
* Returns the limit on the height of the TextNode specified by
* set_max_rows().
*/
INLINE int TextNode::
get_max_rows() const {
MutexHolder holder(_lock);
return _max_rows;
}
/**
* Returns true if the last text set on the text node exceeded the max_rows
* constraint, or false if it all fit.
*/
INLINE bool TextNode::
has_overflow() const {
MutexHolder holder(_lock);
check_measure();
return (_flags & F_has_overflow) != 0;
}
/**
*
*/
INLINE void TextNode::
set_frame_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
set_frame_color(LColor(r, g, b, a));
}
/**
*
*/
INLINE void TextNode::
set_frame_color(const LColor &frame_color) {
MutexHolder holder(_lock);
if (_frame_color != frame_color) {
_frame_color = frame_color;
invalidate_no_measure();
}
}
/**
*
*/
INLINE LColor TextNode::
get_frame_color() const {
MutexHolder holder(_lock);
return _frame_color;
}
/**
*
*/
INLINE void TextNode::
set_card_border(PN_stdfloat size, PN_stdfloat uv_portion) {
MutexHolder holder(_lock);
if ((_flags & F_has_card_border) == 0 || _card_border_size != size || _card_border_uv_portion != uv_portion) {
_flags |= F_has_card_border;
_card_border_size = size;
_card_border_uv_portion = uv_portion;
invalidate_no_measure();
}
}
/**
*
*/
INLINE void TextNode::
clear_card_border() {
MutexHolder holder(_lock);
if (_flags & F_has_card_border) {
_flags &= ~F_has_card_border;
invalidate_no_measure();
}
}
/**
*
*/
INLINE PN_stdfloat TextNode::
get_card_border_size() const {
MutexHolder holder(_lock);
return _card_border_size;
}
/**
*
*/
INLINE PN_stdfloat TextNode::
get_card_border_uv_portion() const {
MutexHolder holder(_lock);
return _card_border_uv_portion;
}
/**
*
*/
INLINE bool TextNode::
has_card_border() const {
MutexHolder holder(_lock);
return (_flags & F_has_card_border) != 0;
}
/**
*
*/
INLINE void TextNode::
set_card_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
set_card_color(LColor(r, g, b, a));
}
/**
*
*/
INLINE void TextNode::
set_card_color(const LColor &card_color) {
MutexHolder holder(_lock);
if (_card_color != card_color) {
_card_color = card_color;
invalidate_no_measure();
}
}
/**
*
*/
INLINE LColor TextNode::
get_card_color() const {
MutexHolder holder(_lock);
return _card_color;
}
/**
*
*/
INLINE void TextNode::
set_card_texture(Texture *card_texture) {
if (card_texture == nullptr) {
clear_card_texture();
} else {
MutexHolder holder(_lock);
if ((_flags & F_has_card_texture) == 0 || _card_texture != card_texture) {
_flags |= F_has_card_texture;
_card_texture = card_texture;
invalidate_no_measure();
}
}
}
/**
*
*/
INLINE void TextNode::
clear_card_texture() {
MutexHolder holder(_lock);
if (_flags & F_has_card_texture) {
_flags &= ~F_has_card_texture;
_card_texture = nullptr;
invalidate_no_measure();
}
}
/**
*
*/
INLINE bool TextNode::
has_card_texture() const {
MutexHolder holder(_lock);
return (_flags & F_has_card_texture) != 0;
}
/**
*
*/
INLINE Texture *TextNode::
get_card_texture() const {
MutexHolder holder(_lock);
return _card_texture;
}
/**
* Specifies that a border will be drawn around the text when it is next
* created. The parameters are the amount of additional padding to insert
* between the frame and the text in each dimension, and all should generally
* be positive.
*/
INLINE void TextNode::
set_frame_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
MutexHolder holder(_lock);
_flags |= (F_has_frame | F_frame_as_margin);
_frame_ul.set(left, top);
_frame_lr.set(right, bottom);
invalidate_no_measure();
}
/**
* Similar to set_frame_as_margin, except the frame is specified in actual
* coordinate units (relative to the text's origin), irrespective of the size
* of the text. The left and bottom coordinates should generally be negative,
* while the right and top coordinates should generally be positive.
*/
INLINE void TextNode::
set_frame_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
MutexHolder holder(_lock);
_flags |= F_has_frame;
_flags &= ~F_frame_as_margin;
_frame_ul.set(left, top);
_frame_lr.set(right, bottom);
invalidate_no_measure();
}
/**
* Specifies that a border will not be drawn around the text.
*/
INLINE void TextNode::
clear_frame() {
MutexHolder holder(_lock);
_flags &= ~F_has_frame;
invalidate_no_measure();
}
/**
*
*/
INLINE bool TextNode::
has_frame() const {
MutexHolder holder(_lock);
return (_flags & F_has_frame) != 0;
}
/**
* If this is true, the frame was set via a call to set_frame_as_margin(), and
* the dimension of the frame as returned by get_frame_as_set() represent a
* margin all around the text. If false, then the frame was set via a call to
* set_frame_actual(), and the dimensions of the frame as returned by
* get_frame_as_set() are relative to the text's origin.
*/
INLINE bool TextNode::
is_frame_as_margin() const {
MutexHolder holder(_lock);
nassertr((_flags & F_has_frame) != 0, false);
return (_flags & F_frame_as_margin) != 0;
}
/**
* Returns the dimensions of the frame as set by set_frame_as_margin() or
* set_frame_actual(). Use is_frame_actual() to determine how to interpret
* the values returned by this function. It is an error to call this if
* has_frame() is false.
*/
INLINE LVecBase4 TextNode::
get_frame_as_set() const {
MutexHolder holder(_lock);
nassertr((_flags & F_has_frame) != 0, LVecBase4(0.0, 0.0, 0.0, 0.0));
return LVecBase4(_frame_ul[0], _frame_lr[0], _frame_lr[1], _frame_ul[1]);
}
/**
* Returns the actual dimensions of the frame around the text. If the frame
* was set via set_frame_as_margin(), the result returned by this function
* reflects the size of the current text; if the frame was set via
* set_frame_actual(), this returns the values actually set.
*
* If the text has no frame at all, this returns the dimensions of the text
* itself, as if the frame were set with a margin of 0, 0, 0, 0.
*/
INLINE LVecBase4 TextNode::
get_frame_actual() const {
MutexHolder holder(_lock);
if (_flags & F_has_frame) {
if (_flags & F_frame_as_margin) {
check_measure();
return LVecBase4(_text_ul[0] - _frame_ul[0],
_text_lr[0] + _frame_lr[0],
_text_lr[1] - _frame_lr[1],
_text_ul[1] + _frame_ul[1]);
} else {
return LVecBase4(_frame_ul[0], _frame_lr[0], _frame_lr[1], _frame_ul[1]);
}
} else {
check_measure();
return LVecBase4(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]);
}
}
/**
* Specifies the thickness of the lines that will be used to draw the frame.
*/
INLINE void TextNode::
set_frame_line_width(PN_stdfloat frame_width) {
MutexHolder holder(_lock);
_frame_width = frame_width;
invalidate_no_measure();
}
/**
* Returns the thickness of the lines that will be used to draw the frame.
*/
INLINE PN_stdfloat TextNode::
get_frame_line_width() const {
MutexHolder holder(_lock);
return _frame_width;
}
/**
* Enables or disables the drawing of corners for the frame. These are extra
* points drawn at each of the four corners, to soften the ugly edges
* generated when the line width is greater than one.
*/
INLINE void TextNode::
set_frame_corners(bool corners) {
MutexHolder holder(_lock);
if (corners) {
_flags |= F_frame_corners;
} else {
_flags &= ~F_frame_corners;
}
invalidate_no_measure();
}
/**
*
*/
INLINE bool TextNode::
get_frame_corners() const {
MutexHolder holder(_lock);
return (_flags & F_frame_corners) != 0;
}
/**
* Specifies that a (possibly opaque or semitransparent) card will be held
* behind the text when it is next created. Like set_frame_as_margin, the
* parameters are the amount of additional padding to insert around the text
* in each dimension, and all should generally be positive.
*/
INLINE void TextNode::
set_card_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
MutexHolder holder(_lock);
_flags |= (F_has_card | F_card_as_margin);
_card_ul.set(left, top);
_card_lr.set(right, bottom);
invalidate_no_measure();
}
/**
* Similar to set_card_as_margin, except the card is specified in actual
* coordinate units (relative to the text's origin), irrespective of the size
* of the text. The left and bottom coordinates should generally be negative,
* while the right and top coordinates should generally be positive.
*/
INLINE void TextNode::
set_card_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
MutexHolder holder(_lock);
_flags |= F_has_card;
_flags &= ~F_card_as_margin;
_card_ul.set(left, top);
_card_lr.set(right, bottom);
invalidate_no_measure();
}
/**
* Sets the card_decal flag. When this is true, the text is decalled onto the
* card, which is necessary if the TextNode is to be rendered in the 3-d world
* without putting it in a bin.
*/
INLINE void TextNode::
set_card_decal(bool card_decal) {
MutexHolder holder(_lock);
if (card_decal) {
_flags |= F_card_decal;
} else {
_flags &= ~F_card_decal;
}
invalidate_no_measure();
}
/**
* Specifies that a card will not be drawn behind the text.
*/
INLINE void TextNode::
clear_card() {
MutexHolder holder(_lock);
_flags &= ~F_has_card;
invalidate_no_measure();
}
/**
*
*/
INLINE bool TextNode::
has_card() const {
MutexHolder holder(_lock);
return (_flags & F_has_card) != 0;
}
/**
* Returns the card_decal flag. See set_card_decal().
*/
INLINE bool TextNode::
get_card_decal() const {
MutexHolder holder(_lock);
return (_flags & F_card_decal) != 0;
}
/**
* If this is true, the card was set via a call to set_card_as_margin(), and
* the dimension of the card as returned by get_card_as_set() represent a
* margin all around the text. If false, then the card was set via a call to
* set_card_actual(), and the dimensions of the card as returned by
* get_card_as_set() are relative to the text's origin.
*/
INLINE bool TextNode::
is_card_as_margin() const {
MutexHolder holder(_lock);
nassertr((_flags & F_has_card) != 0, false);
return (_flags & F_card_as_margin) != 0;
}
/**
* Returns the dimensions of the card as set by set_card_as_margin() or
* set_card_actual(). Use is_card_actual() to determine how to interpret the
* values returned by this function. It is an error to call this if
* has_card() is false.
*/
INLINE LVecBase4 TextNode::
get_card_as_set() const {
MutexHolder holder(_lock);
nassertr((_flags & F_has_card) != 0, LVecBase4(0.0, 0.0, 0.0, 0.0));
return LVecBase4(_card_ul[0], _card_lr[0], _card_lr[1], _card_ul[1]);
}
/**
* Returns the actual dimensions of the card around the text. If the card was
* set via set_card_as_margin(), the result returned by this function reflects
* the size of the current text; if the card was set via set_card_actual(),
* this returns the values actually set.
*
* If the text has no card at all, this returns the dimensions of the text
* itself, as if the card were set with a margin of 0, 0, 0, 0.
*/
INLINE LVecBase4 TextNode::
get_card_actual() const {
MutexHolder holder(_lock);
if (_flags & F_has_card) {
if (_flags & F_card_as_margin) {
check_measure();
return LVecBase4(_text_ul[0] - _card_ul[0],
_text_lr[0] + _card_lr[0],
_text_lr[1] - _card_lr[1],
_text_ul[1] + _card_ul[1]);
} else {
return LVecBase4(_card_ul[0], _card_lr[0], _card_lr[1], _card_ul[1]);
}
} else {
check_measure();
return LVecBase4(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]);
}
}
/**
* Returns the actual card dimensions, transformed by the matrix set by
* set_transform(). This returns the card dimensions in actual coordinates as
* seen by the rest of the world. Also see get_upper_left_3d() and
* get_lower_right_3d().
*/
INLINE LVecBase4 TextNode::
get_card_transformed() const {
LVecBase4 card = get_card_actual();
MutexHolder holder(_lock);
LPoint3 ul = LPoint3(card[0], 0.0, card[3]) * _transform;
LPoint3 lr = LPoint3(card[1], 0.0, card[2]) * _transform;
return LVecBase4(ul[0], lr[0], lr[2], ul[2]);
}
/**
* Sets an additional transform that is applied to the entire text paragraph.
*/
INLINE void TextNode::
set_transform(const LMatrix4 &transform) {
MutexHolder holder(_lock);
_transform = transform;
invalidate_with_measure();
}
/**
*
*/
INLINE LMatrix4 TextNode::
get_transform() const {
MutexHolder holder(_lock);
return _transform;
}
/**
* Specifies the coordinate system in which the text will be generated.
*/
INLINE void TextNode::
set_coordinate_system(CoordinateSystem coordinate_system) {
MutexHolder holder(_lock);
_coordinate_system = coordinate_system;
invalidate_with_measure();
}
/**
*
*/
INLINE CoordinateSystem TextNode::
get_coordinate_system() const {
MutexHolder holder(_lock);
return _coordinate_system;
}
/**
* Specifies the UsageHint that will be applied to generated geometry. The
* default is UH_static, which is probably the right setting, but if you know
* the TextNode's geometry will have a short lifespan, it may be better to set
* it to UH_stream. See geomEnums.h.
*/
INLINE void TextNode::
set_usage_hint(Geom::UsageHint usage_hint) {
MutexHolder holder(_lock);
_usage_hint = usage_hint;
invalidate_no_measure();
}
/**
* Returns the UsageHint that will be applied to generated geometry. See
* set_usage_hint().
*/
INLINE Geom::UsageHint TextNode::
get_usage_hint() const {
MutexHolder holder(_lock);
return _usage_hint;
}
/**
* Sets the flatten flags. This should be a union of the
* TextNode::FlattenFlags options. This controls the degree of flattening
* performed on the TextNode's internal geometry (i.e. the scene graph
* returned by generate()) each time the text is changed. In general, more
* flattening means a more optimal result, but it will take more time to
* generate.
*
* The choice may be any of these three:
*
* FF_none - No flatten operation is called. The letters are left as
* independent Geoms.
*
* FF_light - A flatten_light() operation is called. The attributes are
* applied to the vertices, but no nodes are removed.
*
* FF_medium - A flatten_medium() operation is called. The attributes are
* applied to the vertices, and a few trivial nodes are removed.
*
* FF_strong - A flatten_strong() operation is called. The attributes are
* applied to the vertices, and the resulting nodes are aggressively combined
* into as few nodes as possible.
*
* In addition to the above choices, you may optionally include the following
* flag:
*
* FF_dynamic_merge - Copy the geoms into a single GeomVertexData as we go,
* instead of relying on the flatten operation at the end. This pre-flattens
* the text considerably, and may obviate the need for flatten altogether; it
* also tends to improve performance considerably even if you do call flatten.
* However, it is not as fast as not calling flatten at all.
*
* The default is taken from the text-flatten and text-dynamic-merge config
* variables.
*/
INLINE void TextNode::
set_flatten_flags(int flatten_flags) {
MutexHolder holder(_lock);
_flatten_flags = flatten_flags;
}
/**
* Returns the flatten flags. See set_flatten_flags().
*/
INLINE int TextNode::
get_flatten_flags() const {
MutexHolder holder(_lock);
return _flatten_flags;
}
/**
* Sets the font that will be used when making text. If this is set to NULL,
* the default font will be used, which can be set via set_default_font().
*/
INLINE void TextNode::
set_font(TextFont *font) {
MutexHolder holder(_lock);
TextProperties::set_font(font);
invalidate_with_measure();
}
/**
* Resets the font to the default font.
*/
INLINE void TextNode::
clear_font() {
MutexHolder holder(_lock);
TextProperties::clear_font();
invalidate_with_measure();
}
/**
* Sets the small_caps flag. When this is set, lowercase letters are
* generated as scaled-down versions of their uppercase equivalents. This is
* particularly useful to set for fonts that do not have lowercase letters.
*
* It is also a good idea to set this for a (dynamic) font that has already
* implemented lowercase letters as scaled-down versions of their uppercase
* equivalents, since without this flag the texture memory may needlessly
* duplicate equivalent glyphs for upper and lowercase letters. Setting this
* flag causes the texture memory to share the mixed-case letters.
*
* The amount by which the lowercase letters are scaled is specified by
* set_small_caps_scale().
*/
INLINE void TextNode::
set_small_caps(bool small_caps) {
MutexHolder holder(_lock);
TextProperties::set_small_caps(small_caps);
invalidate_with_measure();
}
/**
*
*/
INLINE void TextNode::
clear_small_caps() {
MutexHolder holder(_lock);
TextProperties::clear_small_caps();
invalidate_with_measure();
}
/**
* Sets the scale factor applied to lowercase letters from their uppercase
* equivalents, when the small_caps flag is in effect. See set_small_caps().
* Normally, this will be a number less than one.
*/
INLINE void TextNode::
set_small_caps_scale(PN_stdfloat small_caps_scale) {
MutexHolder holder(_lock);
TextProperties::set_small_caps_scale(small_caps_scale);
invalidate_with_measure();
}
/**
*
*/
INLINE void TextNode::
clear_small_caps_scale() {
MutexHolder holder(_lock);
TextProperties::clear_small_caps_scale();
invalidate_with_measure();
}
/**
*
*/
INLINE void TextNode::
set_slant(PN_stdfloat slant) {
MutexHolder holder(_lock);
TextProperties::set_slant(slant);
invalidate_with_measure();
}
/**
*
*/
INLINE void TextNode::
clear_slant() {
MutexHolder holder(_lock);
TextProperties::clear_slant();
invalidate_with_measure();
}
/**
*
*/
INLINE void TextNode::
set_align(TextNode::Alignment align_type) {
MutexHolder holder(_lock);
TextProperties::set_align(align_type);
invalidate_with_measure();
}
/**
*
*/
INLINE void TextNode::
clear_align() {
MutexHolder holder(_lock);
TextProperties::clear_align();
invalidate_with_measure();
}
/**
* Specifies the amount of extra space that is inserted before the first
* character of each line. This can be thought of as a left margin.
*/
INLINE void TextNode::
set_indent(PN_stdfloat indent) {
MutexHolder holder(_lock);
TextProperties::set_indent(indent);
invalidate_with_measure();
}
/**
*
*/
INLINE void TextNode::
clear_indent() {
MutexHolder holder(_lock);
TextProperties::clear_indent();
invalidate_with_measure();
}
/**
* Sets the text up to automatically wordwrap when it exceeds the indicated
* width. This can be thought of as a right margin or margin width.
*/
INLINE void TextNode::
set_wordwrap(PN_stdfloat wordwrap) {
MutexHolder holder(_lock);
TextProperties::set_wordwrap(wordwrap);
invalidate_with_measure();
}
/**
* Removes the wordwrap setting from the TextNode. Text will be as wide as it
* is.
*/
INLINE void TextNode::
clear_wordwrap() {
MutexHolder holder(_lock);
TextProperties::clear_wordwrap();
invalidate_with_measure();
}
/**
*
*/
INLINE void TextNode::
set_text_color(const LColor &text_color) {
MutexHolder holder(_lock);
TextProperties::set_text_color(text_color);
invalidate_no_measure();
}
/**
*
*/
INLINE void TextNode::
set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
set_text_color(LColor(r, g, b, a));
}
/**
* Removes the text color specification; the text will be colored whatever it
* was in the source font file.
*/
INLINE void TextNode::
clear_text_color() {
MutexHolder holder(_lock);
TextProperties::clear_text_color();
invalidate_no_measure();
}
/**
*
*/
INLINE void TextNode::
set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
set_shadow_color(LColor(r, g, b, a));
}
/**
*
*/
INLINE void TextNode::
set_shadow_color(const LColor &shadow_color) {
MutexHolder holder(_lock);
TextProperties::set_shadow_color(shadow_color);
invalidate_no_measure();
}
/**
*
*/
INLINE void TextNode::
clear_shadow_color() {
MutexHolder holder(_lock);
TextProperties::clear_shadow_color();
invalidate_with_measure();
}
/**
* Specifies that the text should be drawn with a shadow, by creating a second
* copy of the text and offsetting it slightly behind the first.
*/
INLINE void TextNode::
set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset) {
set_shadow(LVecBase2(xoffset, yoffset));
}
/**
* Specifies that the text should be drawn with a shadow, by creating a second
* copy of the text and offsetting it slightly behind the first.
*/
INLINE void TextNode::
set_shadow(const LVecBase2 &shadow_offset) {
MutexHolder holder(_lock);
TextProperties::set_shadow(shadow_offset);
invalidate_no_measure();
}
/**
* Specifies that a shadow will not be drawn behind the text.
*/
INLINE void TextNode::
clear_shadow() {
MutexHolder holder(_lock);
TextProperties::clear_shadow();
invalidate_no_measure();
}
/**
* Names the GeomBin that the TextNode geometry should be assigned to. If
* this is set, then a GeomBinTransition will be created to explicitly place
* each component in the named bin.
*
* The draw_order value will also be passed to each GeomBinTransition as
* appropriate; this is particularly useful if this names a GeomBinFixed, e.g.
* "fixed".
*/
INLINE void TextNode::
set_bin(const std::string &bin) {
MutexHolder holder(_lock);
TextProperties::set_bin(bin);
invalidate_no_measure();
}
/**
* Removes the effect of a previous call to set_bin(). Text will be drawn in
* whatever bin it would like to be drawn in, with no explicit ordering.
*/
INLINE void TextNode::
clear_bin() {
MutexHolder holder(_lock);
TextProperties::clear_bin();
invalidate_no_measure();
}
/**
* Sets the drawing order of text created by the TextMaker. This is actually
* the draw order of the card and frame. The shadow is drawn at
* _draw_order+1, and the text at _draw_order+2.
*
* This affects the sorting order assigned to the arcs as they are created,
* and also is passed to whatever bin may be assigned via set_bin().
*
* The return value is the first unused draw_order number, e.g. _draw_order +
* 3.
*/
INLINE int TextNode::
set_draw_order(int draw_order) {
MutexHolder holder(_lock);
invalidate_no_measure();
return TextProperties::set_draw_order(draw_order);
}
/**
*
*/
INLINE void TextNode::
clear_draw_order() {
MutexHolder holder(_lock);
TextProperties::clear_draw_order();
invalidate_with_measure();
}
/**
* Sets the width of each tab stop, in screen units. A tab character embedded
* in the text will advance the horizontal position to the next tab stop.
*/
INLINE void TextNode::
set_tab_width(PN_stdfloat tab_width) {
MutexHolder holder(_lock);
TextProperties::set_tab_width(tab_width);
invalidate_with_measure();
}
/**
*
*/
INLINE void TextNode::
clear_tab_width() {
MutexHolder holder(_lock);
TextProperties::clear_tab_width();
invalidate_with_measure();
}
/**
* Specifies the factor by which to scale each letter of the text as it is
* placed. This can be used (possibly in conjunction with set_glyph_shift())
* to implement superscripting or subscripting.
*/
INLINE void TextNode::
set_glyph_scale(PN_stdfloat glyph_scale) {
MutexHolder holder(_lock);
TextProperties::set_glyph_scale(glyph_scale);
invalidate_with_measure();
}
/**
*
*/
INLINE void TextNode::
clear_glyph_scale() {
MutexHolder holder(_lock);
TextProperties::clear_glyph_scale();
invalidate_with_measure();
}
/**
* Specifies a vertical amount to shift each letter of the text as it is
* placed. This can be used (possibly in conjunction with set_glyph_scale())
* to implement superscripting or subscripting.
*/
INLINE void TextNode::
set_glyph_shift(PN_stdfloat glyph_shift) {
MutexHolder holder(_lock);
TextProperties::set_glyph_shift(glyph_shift);
invalidate_with_measure();