| 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 |
#pragma once |
| 32 |
|
| 33 |
#include "core/templates/local_vector.h" |
| 34 |
#include "scene/resources/font.h" |
| 35 |
#include "servers/text/text_server.h" |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
class TextParagraph : public RefCounted { |
| 40 |
GDCLASS(TextParagraph, RefCounted); |
| 41 |
_THREAD_SAFE_CLASS_ |
| 42 |
|
| 43 |
private: |
| 44 |
mutable RID dropcap_rid; |
| 45 |
mutable int dropcap_lines = 0; |
| 46 |
Rect2 dropcap_margins; |
| 47 |
|
| 48 |
RID rid; |
| 49 |
mutable LocalVector<RID> lines_rid; |
| 50 |
|
| 51 |
mutable bool lines_dirty = true; |
| 52 |
|
| 53 |
float line_spacing = 0.0; |
| 54 |
float width = -1.0; |
| 55 |
int max_lines_visible = -1; |
| 56 |
|
| 57 |
BitField<TextServer::LineBreakFlag> brk_flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND; |
| 58 |
BitField<TextServer::JustificationFlag> jst_flags = TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_SKIP_LAST_LINE | TextServer::JUSTIFICATION_DO_NOT_SKIP_SINGLE_LINE; |
| 59 |
String el_char = U"…"; |
| 60 |
TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_NO_TRIMMING; |
| 61 |
|
| 62 |
HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT; |
| 63 |
|
| 64 |
Vector<float> tab_stops; |
| 65 |
|
| 66 |
protected: |
| 67 |
#ifndef DISABLE_DEPRECATED |
| 68 |
void _draw_bind_compat_104872(RID p_canvas, const Vector2 &p_pos, const Color &p_color = Color(1, 1, 1), const Color &p_dc_color = Color(1, 1, 1)) const; |
| 69 |
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 Color &p_dc_color = Color(1, 1, 1)) const; |
| 70 |
void _draw_line_bind_compat_104872(RID p_canvas, const Vector2 &p_pos, int p_line, const Color &p_color = Color(1, 1, 1)) const; |
| 71 |
void _draw_line_outline_bind_compat_104872(RID p_canvas, const Vector2 &p_pos, int p_line, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const; |
| 72 |
void _draw_dropcap_bind_compat_104872(RID p_canvas, const Vector2 &p_pos, const Color &p_color = Color(1, 1, 1)) const; |
| 73 |
void _draw_dropcap_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; |
| 74 |
|
| 75 |
static void _bind_compatibility_methods(); |
| 76 |
#endif |
| 77 |
static void _bind_methods(); |
| 78 |
|
| 79 |
void _shape_lines() const; |
| 80 |
|
| 81 |
public: |
| 82 |
RID get_rid() const; |
| 83 |
RID get_line_rid(int p_line) const; |
| 84 |
RID get_dropcap_rid() const; |
| 85 |
|
| 86 |
void clear(); |
| 87 |
|
| 88 |
Ref<TextParagraph> duplicate() const; |
| 89 |
|
| 90 |
void set_direction(TextServer::Direction p_direction); |
| 91 |
TextServer::Direction get_direction() const; |
| 92 |
TextServer::Direction get_inferred_direction() const; |
| 93 |
|
| 94 |
void set_orientation(TextServer::Orientation p_orientation); |
| 95 |
TextServer::Orientation get_orientation() const; |
| 96 |
|
| 97 |
void set_preserve_invalid(bool p_enabled); |
| 98 |
bool get_preserve_invalid() const; |
| 99 |
|
| 100 |
void set_preserve_control(bool p_enabled); |
| 101 |
bool get_preserve_control() const; |
| 102 |
|
| 103 |
void set_bidi_override(const Array &p_override); |
| 104 |
|
| 105 |
void set_custom_punctuation(const String &p_punct); |
| 106 |
String get_custom_punctuation() const; |
| 107 |
|
| 108 |
bool set_dropcap(const String &p_text, const Ref<Font> &p_font, int p_font_size, const Rect2 &p_dropcap_margins = Rect2(), const String &p_language = ""); |
| 109 |
void clear_dropcap(); |
| 110 |
|
| 111 |
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()); |
| 112 |
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); |
| 113 |
bool resize_object(Variant p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, float p_baseline = 0.0); |
| 114 |
bool has_object(Variant p_key) const; |
| 115 |
|
| 116 |
void set_alignment(HorizontalAlignment p_alignment); |
| 117 |
HorizontalAlignment get_alignment() const; |
| 118 |
|
| 119 |
void tab_align(const Vector<float> &p_tab_stops); |
| 120 |
|
| 121 |
void set_justification_flags(BitField<TextServer::JustificationFlag> p_flags); |
| 122 |
BitField<TextServer::JustificationFlag> get_justification_flags() const; |
| 123 |
|
| 124 |
void set_break_flags(BitField<TextServer::LineBreakFlag> p_flags); |
| 125 |
BitField<TextServer::LineBreakFlag> get_break_flags() const; |
| 126 |
|
| 127 |
void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior); |
| 128 |
TextServer::OverrunBehavior get_text_overrun_behavior() const; |
| 129 |
|
| 130 |
void set_ellipsis_char(const String &p_char); |
| 131 |
String get_ellipsis_char() const; |
| 132 |
|
| 133 |
void set_width(float p_width); |
| 134 |
float get_width() const; |
| 135 |
|
| 136 |
void set_max_lines_visible(int p_lines); |
| 137 |
int get_max_lines_visible() const; |
| 138 |
|
| 139 |
void set_line_spacing(float p_spacing); |
| 140 |
float get_line_spacing() const; |
| 141 |
|
| 142 |
Size2 get_non_wrapped_size() const; |
| 143 |
|
| 144 |
Size2 get_size() const; |
| 145 |
|
| 146 |
Vector2i get_range() const; |
| 147 |
|
| 148 |
int get_line_count() const; |
| 149 |
|
| 150 |
Array get_line_objects(int p_line) const; |
| 151 |
Rect2 get_line_object_rect(int p_line, Variant p_key) const; |
| 152 |
Size2 get_line_size(int p_line) const; |
| 153 |
float get_line_ascent(int p_line) const; |
| 154 |
float get_line_descent(int p_line) const; |
| 155 |
float get_line_width(int p_line) const; |
| 156 |
Vector2i get_line_range(int p_line) const; |
| 157 |
float get_line_underline_position(int p_line) const; |
| 158 |
float get_line_underline_thickness(int p_line) const; |
| 159 |
|
| 160 |
Size2 get_dropcap_size() const; |
| 161 |
int get_dropcap_lines() const; |
| 162 |
|
| 163 |
void draw(RID p_canvas, const Vector2 &p_pos, const Color &p_color = Color(1, 1, 1), const Color &p_dc_color = Color(1, 1, 1), float p_oversampling = 0.0) const; |
| 164 |
void draw_outline(RID p_canvas, const Vector2 &p_pos, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1), const Color &p_dc_color = Color(1, 1, 1), float p_oversampling = 0.0) const; |
| 165 |
|
| 166 |
void draw_line(RID p_canvas, const Vector2 &p_pos, int p_line, const Color &p_color = Color(1, 1, 1), float p_oversampling = 0.0) const; |
| 167 |
void draw_line_outline(RID p_canvas, const Vector2 &p_pos, int p_line, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1), float p_oversampling = 0.0) const; |
| 168 |
|
| 169 |
void draw_dropcap(RID p_canvas, const Vector2 &p_pos, const Color &p_color = Color(1, 1, 1), float p_oversampling = 0.0) const; |
| 170 |
void draw_dropcap_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; |
| 171 |
|
| 172 |
int hit_test(const Point2 &p_coords) const; |
| 173 |
|
| 174 |
bool is_dirty(); |
| 175 |
|
| 176 |
Mutex &get_mutex() const { return _thread_safe_; } |
| 177 |
|
| 178 |
TextParagraph(const String &p_text, const Ref<Font> &p_font, int p_font_size, const String &p_language = "", float p_width = -1.f, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL); |
| 179 |
TextParagraph(); |
| 180 |
~TextParagraph(); |
| 181 |
}; |