Debian Codegraph @

scene/resources/text_line.h

raw symbols SCIP
1 /**************************************************************************/
2 /* text_line.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "scene/resources/font.h"
34 #include "servers/text/text_server.h"
35
36 /*************************************************************************/
37
38 class TextLine : public RefCounted {
39 GDCLASS(TextLine, RefCounted);
40
41 private:
42 RID rid;
43
44 mutable bool dirty = true;
45
46 float width = -1.0;
47 BitField<TextServer::JustificationFlag> flags = TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA;
48 HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT;
49 String el_char = U"…";
50 TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_TRIM_ELLIPSIS;
51
52 Vector<float> tab_stops;
53
54 protected:
55 #ifndef DISABLE_DEPRECATED
56 void _draw_bind_compat_104872(RID p_canvas, const Vector2 &p_pos, const Color &p_color = Color(1, 1, 1)) const;
57 void _draw_outline_bind_compat_104872(RID p_canvas, const Vector2 &p_pos, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const;
58 static void _bind_compatibility_methods();
59 #endif
60
61 static void _bind_methods();
62
63 void _shape() const;
64
65 public:
66 RID get_rid() const;
67
68 void clear();
69 Ref<TextLine> duplicate() const;
70
71 void set_direction(TextServer::Direction p_direction);
72 TextServer::Direction get_direction() const;
73 TextServer::Direction get_inferred_direction() const;
74
75 void set_bidi_override(const Array &p_override);
76
77 void set_orientation(TextServer::Orientation p_orientation);
78 TextServer::Orientation get_orientation() const;
79
80 void set_preserve_invalid(bool p_enabled);
81 bool get_preserve_invalid() const;
82
83 void set_preserve_control(bool p_enabled);
84 bool get_preserve_control() const;
85
86 bool add_string(const String &p_text, const Ref<Font> &p_font, int p_font_size, const String &p_language = "", const Variant &p_meta = Variant());
87 bool add_object(Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int p_length = 1, float p_baseline = 0.0);
88 bool resize_object(Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, float p_baseline = 0.0);
89 bool has_object(Variant p_key) const;
90
91 void set_horizontal_alignment(HorizontalAlignment p_alignment);
92 HorizontalAlignment get_horizontal_alignment() const;
93
94 void tab_align(const Vector<float> &p_tab_stops);
95
96 void set_flags(BitField<TextServer::JustificationFlag> p_flags);
97 BitField<TextServer::JustificationFlag> get_flags() const;
98
99 void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior);
100 TextServer::OverrunBehavior get_text_overrun_behavior() const;
101
102 void set_ellipsis_char(const String &p_char);
103 String get_ellipsis_char() const;
104
105 void set_width(float p_width);
106 float get_width() const;
107
108 Array get_objects() const;
109 Rect2 get_object_rect(Variant p_key) const;
110
111 Size2 get_size() const;
112
113 float get_line_ascent() const;
114 float get_line_descent() const;
115 float get_line_width() const;
116 float get_line_underline_position() const;
117 float get_line_underline_thickness() const;
118
119 void draw(RID p_canvas, const Vector2 &p_pos, const Color &p_color = Color(1, 1, 1), float p_oversampling = 0.0) const;
120 void draw_outline(RID p_canvas, const Vector2 &p_pos, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1), float p_oversampling = 0.0) const;
121
122 int hit_test(float p_coords) const;
123
124 TextLine(const String &p_text, const Ref<Font> &p_font, int p_font_size, const String &p_language = "", TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL);
125 TextLine();
126 ~TextLine();
127 };