Various text layout improvements (TextLine, TextParagraph, Label, TextServer)

This commit is contained in:
Hendrik Brucker 2021-08-11 00:09:48 +02:00
parent 33fd41472c
commit 403f4902d0
15 changed files with 736 additions and 391 deletions

View file

@ -39,19 +39,33 @@
class TextParagraph : public RefCounted {
GDCLASS(TextParagraph, RefCounted);
public:
enum OverrunBehavior {
OVERRUN_NO_TRIMMING,
OVERRUN_TRIM_CHAR,
OVERRUN_TRIM_WORD,
OVERRUN_TRIM_ELLIPSIS,
OVERRUN_TRIM_WORD_ELLIPSIS,
};
private:
RID dropcap_rid;
int dropcap_lines = 0;
Rect2 dropcap_margins;
RID rid;
Vector<RID> lines;
Vector<RID> lines_rid;
int spacing_top = 0;
int spacing_bottom = 0;
bool dirty_lines = true;
bool lines_dirty = true;
float width = -1.0;
int max_lines_visible = -1;
uint8_t flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA;
OverrunBehavior overrun_behavior = OVERRUN_NO_TRIMMING;
HAlign align = HALIGN_LEFT;
Vector<float> tab_stops;
@ -97,9 +111,15 @@ public:
void set_flags(uint8_t p_flags);
uint8_t get_flags() const;
void set_text_overrun_behavior(OverrunBehavior p_behavior);
OverrunBehavior get_text_overrun_behavior() const;
void set_width(float p_width);
float get_width() const;
void set_max_lines_visible(int p_lines);
int get_max_lines_visible() const;
Size2 get_non_wraped_size() const;
Size2 get_size() const;
@ -140,4 +160,6 @@ public:
~TextParagraph();
};
VARIANT_ENUM_CAST(TextParagraph::OverrunBehavior);
#endif // TEXT_PARAGRAPH_H