| 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 "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 |
}; |