2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* rich_text_label.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2021-01-01 19:13:46 +00:00
|
|
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef RICH_TEXT_LABEL_H
|
|
|
|
#define RICH_TEXT_LABEL_H
|
|
|
|
|
2018-11-10 02:44:58 +00:00
|
|
|
#include "rich_text_effect.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "scene/gui/scroll_bar.h"
|
2020-10-02 12:02:02 +00:00
|
|
|
#include "scene/resources/text_paragraph.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class RichTextLabel : public Control {
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(RichTextLabel, Control);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2014-02-10 01:10:30 +00:00
|
|
|
enum Align {
|
|
|
|
ALIGN_LEFT,
|
|
|
|
ALIGN_CENTER,
|
|
|
|
ALIGN_RIGHT,
|
|
|
|
ALIGN_FILL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ListType {
|
|
|
|
LIST_NUMBERS,
|
|
|
|
LIST_LETTERS,
|
2020-10-02 12:02:02 +00:00
|
|
|
LIST_ROMAN,
|
2014-02-10 01:10:30 +00:00
|
|
|
LIST_DOTS
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ItemType {
|
2015-12-26 13:25:17 +00:00
|
|
|
ITEM_FRAME,
|
2014-02-10 01:10:30 +00:00
|
|
|
ITEM_TEXT,
|
|
|
|
ITEM_IMAGE,
|
|
|
|
ITEM_NEWLINE,
|
|
|
|
ITEM_FONT,
|
2020-10-02 12:02:02 +00:00
|
|
|
ITEM_FONT_SIZE,
|
|
|
|
ITEM_FONT_FEATURES,
|
2014-02-10 01:10:30 +00:00
|
|
|
ITEM_COLOR,
|
2020-10-02 12:02:02 +00:00
|
|
|
ITEM_OUTLINE_SIZE,
|
|
|
|
ITEM_OUTLINE_COLOR,
|
2014-02-10 01:10:30 +00:00
|
|
|
ITEM_UNDERLINE,
|
2018-09-22 21:41:13 +00:00
|
|
|
ITEM_STRIKETHROUGH,
|
2020-10-02 12:02:02 +00:00
|
|
|
ITEM_PARAGRAPH,
|
2014-02-10 01:10:30 +00:00
|
|
|
ITEM_INDENT,
|
|
|
|
ITEM_LIST,
|
2015-12-26 13:25:17 +00:00
|
|
|
ITEM_TABLE,
|
2018-11-10 02:44:58 +00:00
|
|
|
ITEM_FADE,
|
|
|
|
ITEM_SHAKE,
|
|
|
|
ITEM_WAVE,
|
|
|
|
ITEM_TORNADO,
|
|
|
|
ITEM_RAINBOW,
|
|
|
|
ITEM_META,
|
2020-11-19 14:45:23 +00:00
|
|
|
ITEM_DROPCAP,
|
2018-11-10 02:44:58 +00:00
|
|
|
ITEM_CUSTOMFX
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
private:
|
2019-09-25 20:05:42 +00:00
|
|
|
struct Item;
|
2015-12-26 13:25:17 +00:00
|
|
|
|
|
|
|
struct Line {
|
2020-10-02 12:02:02 +00:00
|
|
|
Item *from = nullptr;
|
|
|
|
|
|
|
|
Ref<TextParagraph> text_buf;
|
2020-11-19 14:45:23 +00:00
|
|
|
Color dc_color;
|
|
|
|
int dc_ol_size = 0;
|
|
|
|
Color dc_ol_color;
|
2020-10-02 12:02:02 +00:00
|
|
|
|
|
|
|
Vector2 offset;
|
|
|
|
int char_offset = 0;
|
|
|
|
int char_count = 0;
|
|
|
|
|
|
|
|
Line() { text_buf.instance(); }
|
2015-12-26 13:25:17 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct Item {
|
2020-10-02 12:02:02 +00:00
|
|
|
int index = 0;
|
|
|
|
int char_ofs = 0;
|
|
|
|
Item *parent = nullptr;
|
|
|
|
ItemType type = ITEM_FRAME;
|
2017-03-05 15:44:50 +00:00
|
|
|
List<Item *> subitems;
|
2020-10-02 12:02:02 +00:00
|
|
|
List<Item *>::Element *E = nullptr;
|
|
|
|
int line = 0;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void _clear_children() {
|
|
|
|
while (subitems.size()) {
|
|
|
|
memdelete(subitems.front()->get());
|
|
|
|
subitems.pop_front();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~Item() { _clear_children(); }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemFrame : public Item {
|
2020-10-02 12:02:02 +00:00
|
|
|
bool cell = false;
|
|
|
|
|
2015-12-26 13:25:17 +00:00
|
|
|
Vector<Line> lines;
|
2020-10-02 12:02:02 +00:00
|
|
|
int first_invalid_line = 0;
|
|
|
|
int first_resized_line = 0;
|
|
|
|
|
|
|
|
ItemFrame *parent_frame = nullptr;
|
|
|
|
|
|
|
|
Color odd_row_bg = Color(0, 0, 0, 0);
|
|
|
|
Color even_row_bg = Color(0, 0, 0, 0);
|
|
|
|
Color border = Color(0, 0, 0, 0);
|
|
|
|
Size2 min_size_over = Size2(-1, -1);
|
|
|
|
Size2 max_size_over = Size2(-1, -1);
|
|
|
|
Rect2 padding;
|
|
|
|
|
|
|
|
ItemFrame() { type = ITEM_FRAME; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemText : public Item {
|
2014-02-10 01:10:30 +00:00
|
|
|
String text;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemText() { type = ITEM_TEXT; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2020-11-19 14:45:23 +00:00
|
|
|
struct ItemDropcap : public Item {
|
|
|
|
String text;
|
|
|
|
Ref<Font> font;
|
2021-02-09 17:24:36 +00:00
|
|
|
int font_size = 0;
|
2020-11-19 14:45:23 +00:00
|
|
|
Color color;
|
2021-02-09 17:24:36 +00:00
|
|
|
int ol_size = 0;
|
2020-11-19 14:45:23 +00:00
|
|
|
Color ol_color;
|
|
|
|
Rect2 dropcap_margins;
|
|
|
|
ItemDropcap() { type = ITEM_DROPCAP; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemImage : public Item {
|
2019-06-11 18:43:37 +00:00
|
|
|
Ref<Texture2D> image;
|
2020-10-02 12:02:02 +00:00
|
|
|
VAlign inline_align = VALIGN_TOP;
|
2019-10-16 10:00:15 +00:00
|
|
|
Size2 size;
|
2020-05-28 06:17:17 +00:00
|
|
|
Color color;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemImage() { type = ITEM_IMAGE; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemFont : public Item {
|
2014-02-10 01:10:30 +00:00
|
|
|
Ref<Font> font;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemFont() { type = ITEM_FONT; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2020-10-02 12:02:02 +00:00
|
|
|
struct ItemFontSize : public Item {
|
|
|
|
int font_size = 16;
|
|
|
|
ItemFontSize() { type = ITEM_FONT_SIZE; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ItemFontFeatures : public Item {
|
|
|
|
Dictionary opentype_features;
|
|
|
|
ItemFontFeatures() { type = ITEM_FONT_FEATURES; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemColor : public Item {
|
2014-02-10 01:10:30 +00:00
|
|
|
Color color;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemColor() { type = ITEM_COLOR; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2020-10-02 12:02:02 +00:00
|
|
|
struct ItemOutlineSize : public Item {
|
|
|
|
int outline_size = 0;
|
|
|
|
ItemOutlineSize() { type = ITEM_OUTLINE_SIZE; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ItemOutlineColor : public Item {
|
|
|
|
Color color;
|
|
|
|
ItemOutlineColor() { type = ITEM_OUTLINE_COLOR; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemUnderline : public Item {
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemUnderline() { type = ITEM_UNDERLINE; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemStrikethrough : public Item {
|
2018-09-22 21:41:13 +00:00
|
|
|
ItemStrikethrough() { type = ITEM_STRIKETHROUGH; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemMeta : public Item {
|
2014-02-10 01:10:30 +00:00
|
|
|
Variant meta;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemMeta() { type = ITEM_META; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2020-10-02 12:02:02 +00:00
|
|
|
struct ItemParagraph : public Item {
|
|
|
|
Align align = ALIGN_LEFT;
|
|
|
|
String language;
|
|
|
|
Control::TextDirection direction = Control::TEXT_DIRECTION_AUTO;
|
|
|
|
Control::StructuredTextParser st_parser = STRUCTURED_TEXT_DEFAULT;
|
|
|
|
ItemParagraph() { type = ITEM_PARAGRAPH; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemIndent : public Item {
|
2020-10-02 12:02:02 +00:00
|
|
|
int level = 0;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemIndent() { type = ITEM_INDENT; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemList : public Item {
|
2020-10-02 12:02:02 +00:00
|
|
|
ListType list_type = LIST_DOTS;
|
|
|
|
bool capitalize = false;
|
|
|
|
int level = 0;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemList() { type = ITEM_LIST; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemNewline : public Item {
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemNewline() { type = ITEM_NEWLINE; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemTable : public Item {
|
2015-12-26 13:25:17 +00:00
|
|
|
struct Column {
|
2021-02-09 17:24:36 +00:00
|
|
|
bool expand = false;
|
|
|
|
int expand_ratio = 0;
|
|
|
|
int min_width = 0;
|
|
|
|
int max_width = 0;
|
|
|
|
int width = 0;
|
2015-12-26 13:25:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Vector<Column> columns;
|
2020-10-02 12:02:02 +00:00
|
|
|
Vector<float> rows;
|
|
|
|
|
|
|
|
int total_width = 0;
|
|
|
|
int total_height = 0;
|
|
|
|
VAlign inline_align = VALIGN_TOP;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemTable() { type = ITEM_TABLE; }
|
2015-12-26 13:25:17 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemFade : public Item {
|
2020-10-02 12:02:02 +00:00
|
|
|
int starting_index = 0;
|
|
|
|
int length = 0;
|
2018-11-10 02:44:58 +00:00
|
|
|
|
|
|
|
ItemFade() { type = ITEM_FADE; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemFX : public Item {
|
2020-10-02 12:02:02 +00:00
|
|
|
float elapsed_time = 0.f;
|
2018-11-10 02:44:58 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemShake : public ItemFX {
|
2020-10-02 12:02:02 +00:00
|
|
|
int strength = 0;
|
|
|
|
float rate = 0.0f;
|
|
|
|
uint64_t _current_rng = 0;
|
|
|
|
uint64_t _previous_rng = 0;
|
|
|
|
|
|
|
|
ItemShake() { type = ITEM_SHAKE; }
|
2018-11-10 02:44:58 +00:00
|
|
|
|
|
|
|
void reroll_random() {
|
|
|
|
_previous_rng = _current_rng;
|
|
|
|
_current_rng = Math::rand();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t offset_random(int index) {
|
|
|
|
return (_current_rng >> (index % 64)) |
|
|
|
|
(_current_rng << (64 - (index % 64)));
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t offset_previous_random(int index) {
|
|
|
|
return (_previous_rng >> (index % 64)) |
|
|
|
|
(_previous_rng << (64 - (index % 64)));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemWave : public ItemFX {
|
2020-10-02 12:02:02 +00:00
|
|
|
float frequency = 1.0f;
|
|
|
|
float amplitude = 1.0f;
|
2018-11-10 02:44:58 +00:00
|
|
|
|
2020-10-02 12:02:02 +00:00
|
|
|
ItemWave() { type = ITEM_WAVE; }
|
2018-11-10 02:44:58 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemTornado : public ItemFX {
|
2020-10-02 12:02:02 +00:00
|
|
|
float radius = 1.0f;
|
|
|
|
float frequency = 1.0f;
|
2018-11-10 02:44:58 +00:00
|
|
|
|
2020-10-02 12:02:02 +00:00
|
|
|
ItemTornado() { type = ITEM_TORNADO; }
|
2018-11-10 02:44:58 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemRainbow : public ItemFX {
|
2020-10-02 12:02:02 +00:00
|
|
|
float saturation = 0.8f;
|
|
|
|
float value = 0.8f;
|
|
|
|
float frequency = 1.0f;
|
|
|
|
|
|
|
|
ItemRainbow() { type = ITEM_RAINBOW; }
|
2018-11-10 02:44:58 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 20:05:42 +00:00
|
|
|
struct ItemCustomFX : public ItemFX {
|
|
|
|
Ref<CharFXTransform> char_fx_transform;
|
|
|
|
Ref<RichTextEffect> custom_effect;
|
2018-11-10 02:44:58 +00:00
|
|
|
|
|
|
|
ItemCustomFX() {
|
|
|
|
type = ITEM_CUSTOMFX;
|
2019-09-25 20:05:42 +00:00
|
|
|
char_fx_transform.instance();
|
2018-11-10 02:44:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~ItemCustomFX() {
|
|
|
|
_clear_children();
|
2019-09-25 20:05:42 +00:00
|
|
|
|
|
|
|
char_fx_transform.unref();
|
|
|
|
custom_effect.unref();
|
2018-11-10 02:44:58 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
ItemFrame *main = nullptr;
|
|
|
|
Item *current = nullptr;
|
|
|
|
ItemFrame *current_frame = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
VScrollBar *vscroll = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
bool scroll_visible = false;
|
|
|
|
bool scroll_follow = false;
|
|
|
|
bool scroll_following = false;
|
|
|
|
bool scroll_active = true;
|
|
|
|
int scroll_w = 0;
|
|
|
|
bool scroll_updated = false;
|
|
|
|
bool updating_scroll = false;
|
2020-10-02 12:02:02 +00:00
|
|
|
int current_idx = 1;
|
|
|
|
int current_char_ofs = 0;
|
2021-02-09 17:24:36 +00:00
|
|
|
int visible_paragraph_count = 0;
|
|
|
|
int visible_line_count = 0;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
int tab_size = 4;
|
|
|
|
bool underline_meta = true;
|
|
|
|
bool override_selected_font_color = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
Align default_align = ALIGN_LEFT;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
ItemMeta *meta_hovering = nullptr;
|
2017-11-17 05:49:39 +00:00
|
|
|
Variant current_meta;
|
|
|
|
|
2020-03-17 06:33:00 +00:00
|
|
|
Vector<Ref<RichTextEffect>> custom_effects;
|
2018-11-10 02:44:58 +00:00
|
|
|
|
2015-12-26 13:25:17 +00:00
|
|
|
void _invalidate_current_line(ItemFrame *p_frame);
|
|
|
|
void _validate_line_caches(ItemFrame *p_frame);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void _add_item(Item *p_item, bool p_enter = false, bool p_ensure_newline = false);
|
2017-01-31 21:57:46 +00:00
|
|
|
void _remove_item(Item *p_item, const int p_line, const int p_subitem_line);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-10-02 12:02:02 +00:00
|
|
|
String language;
|
|
|
|
TextDirection text_direction = TEXT_DIRECTION_AUTO;
|
|
|
|
Control::StructuredTextParser st_parser = STRUCTURED_TEXT_DEFAULT;
|
|
|
|
Array st_args;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
struct Selection {
|
2021-02-09 17:24:36 +00:00
|
|
|
ItemFrame *click_frame = nullptr;
|
|
|
|
int click_line = 0;
|
|
|
|
Item *click_item = nullptr;
|
|
|
|
int click_char = 0;
|
|
|
|
|
|
|
|
ItemFrame *from_frame = nullptr;
|
|
|
|
int from_line = 0;
|
|
|
|
Item *from_item = nullptr;
|
|
|
|
int from_char = 0;
|
|
|
|
|
|
|
|
ItemFrame *to_frame = nullptr;
|
|
|
|
int to_line = 0;
|
|
|
|
Item *to_item = nullptr;
|
|
|
|
int to_char = 0;
|
|
|
|
|
|
|
|
bool active = false; // anything selected? i.e. from, to, etc. valid?
|
|
|
|
bool enabled = false; // allow selections?
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Selection selection;
|
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
int visible_characters = -1;
|
|
|
|
float percent_visible = 1.0;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-10-02 12:02:02 +00:00
|
|
|
void _find_click(ItemFrame *p_frame, const Point2i &p_click, ItemFrame **r_click_frame = nullptr, int *r_click_line = nullptr, Item **r_click_item = nullptr, int *r_click_char = nullptr, bool *r_outside = nullptr);
|
|
|
|
|
2021-02-11 16:33:45 +00:00
|
|
|
String _get_line_text(ItemFrame *p_frame, int p_line, Selection p_sel) const;
|
2020-10-02 12:02:02 +00:00
|
|
|
bool _search_line(ItemFrame *p_frame, int p_line, const String &p_string, Item *p_from, Item *p_to);
|
|
|
|
|
|
|
|
void _shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width, int *r_char_offset);
|
|
|
|
void _resize_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width);
|
2020-12-08 13:11:45 +00:00
|
|
|
int _draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_shadow_color, bool p_shadow_as_outline, const Point2 &shadow_ofs);
|
2020-10-02 12:02:02 +00:00
|
|
|
float _find_click_in_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Point2i &p_click, ItemFrame **r_click_frame = nullptr, int *r_click_line = nullptr, Item **r_click_item = nullptr, int *r_click_char = nullptr);
|
|
|
|
|
|
|
|
String _roman(int p_num, bool p_capitalize) const;
|
|
|
|
String _letters(int p_num, bool p_capitalize) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-10-02 12:02:02 +00:00
|
|
|
Item *_get_item_at_pos(Item *p_item_from, Item *p_item_to, int p_position);
|
|
|
|
void _find_frame(Item *p_item, ItemFrame **r_frame, int *r_line);
|
2014-02-10 01:10:30 +00:00
|
|
|
Ref<Font> _find_font(Item *p_item);
|
2020-10-02 12:02:02 +00:00
|
|
|
int _find_font_size(Item *p_item);
|
|
|
|
Dictionary _find_font_features(Item *p_item);
|
2020-12-25 21:45:28 +00:00
|
|
|
int _find_outline_size(Item *p_item, int p_default);
|
2020-10-02 12:02:02 +00:00
|
|
|
ItemList *_find_list_item(Item *p_item);
|
2020-11-19 14:45:23 +00:00
|
|
|
ItemDropcap *_find_dc_item(Item *p_item);
|
2020-10-02 12:02:02 +00:00
|
|
|
int _find_list(Item *p_item, Vector<int> &r_index, Vector<ItemList *> &r_list);
|
|
|
|
int _find_margin(Item *p_item, const Ref<Font> &p_base_font, int p_base_font_size);
|
2014-02-10 01:10:30 +00:00
|
|
|
Align _find_align(Item *p_item);
|
2020-10-02 12:02:02 +00:00
|
|
|
TextServer::Direction _find_direction(Item *p_item);
|
|
|
|
Control::StructuredTextParser _find_stt(Item *p_item);
|
|
|
|
String _find_language(Item *p_item);
|
2017-03-05 15:44:50 +00:00
|
|
|
Color _find_color(Item *p_item, const Color &p_default_color);
|
2020-10-02 12:02:02 +00:00
|
|
|
Color _find_outline_color(Item *p_item, const Color &p_default_color);
|
2014-02-10 01:10:30 +00:00
|
|
|
bool _find_underline(Item *p_item);
|
2018-09-22 21:41:13 +00:00
|
|
|
bool _find_strikethrough(Item *p_item);
|
2020-04-01 23:20:12 +00:00
|
|
|
bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = nullptr);
|
2019-06-20 10:42:25 +00:00
|
|
|
bool _find_layout_subitem(Item *from, Item *to);
|
2019-09-25 20:05:42 +00:00
|
|
|
void _fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void _update_scroll();
|
2018-11-10 02:44:58 +00:00
|
|
|
void _update_fx(ItemFrame *p_frame, float p_delta_time);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _scroll_changed(double);
|
|
|
|
|
2017-05-20 15:38:03 +00:00
|
|
|
void _gui_input(Ref<InputEvent> p_event);
|
2021-02-11 16:33:45 +00:00
|
|
|
Item *_get_next_item(Item *p_item, bool p_free = false) const;
|
|
|
|
Item *_get_prev_item(Item *p_item, bool p_free = false) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-09-02 16:20:04 +00:00
|
|
|
Rect2 _get_text_rect();
|
2018-11-10 02:44:58 +00:00
|
|
|
Ref<RichTextEffect> _get_custom_effect_by_code(String p_bbcode_identifier);
|
|
|
|
virtual Dictionary parse_expressions_for_values(Vector<String> p_expressions);
|
2017-09-02 16:20:04 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
bool use_bbcode = false;
|
2015-04-21 19:01:58 +00:00
|
|
|
String bbcode;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
int fixed_width = -1;
|
2018-07-20 21:14:33 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
bool fit_content_height = false;
|
2019-11-01 14:17:40 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
|
|
|
public:
|
2016-06-29 15:43:51 +00:00
|
|
|
String get_text();
|
2017-03-05 15:44:50 +00:00
|
|
|
void add_text(const String &p_text);
|
2020-10-02 12:02:02 +00:00
|
|
|
void add_image(const Ref<Texture2D> &p_image, const int p_width = 0, const int p_height = 0, const Color &p_color = Color(1.0, 1.0, 1.0), VAlign p_align = VALIGN_TOP);
|
2014-02-10 01:10:30 +00:00
|
|
|
void add_newline();
|
2017-01-31 21:57:46 +00:00
|
|
|
bool remove_line(const int p_line);
|
2020-11-19 14:45:23 +00:00
|
|
|
void push_dropcap(const String &p_string, const Ref<Font> &p_font, int p_size, const Rect2 &p_dropcap_margins = Rect2(), const Color &p_color = Color(1, 1, 1), int p_ol_size = 0, const Color &p_ol_color = Color(0, 0, 0, 0));
|
2017-03-05 15:44:50 +00:00
|
|
|
void push_font(const Ref<Font> &p_font);
|
2020-10-02 12:02:02 +00:00
|
|
|
void push_font_size(int p_font_size);
|
|
|
|
void push_font_features(const Dictionary &p_features);
|
|
|
|
void push_outline_size(int p_font_size);
|
2019-10-16 13:22:56 +00:00
|
|
|
void push_normal();
|
|
|
|
void push_bold();
|
|
|
|
void push_bold_italics();
|
|
|
|
void push_italics();
|
|
|
|
void push_mono();
|
2017-03-05 15:44:50 +00:00
|
|
|
void push_color(const Color &p_color);
|
2020-10-02 12:02:02 +00:00
|
|
|
void push_outline_color(const Color &p_color);
|
2014-02-10 01:10:30 +00:00
|
|
|
void push_underline();
|
2018-09-22 21:41:13 +00:00
|
|
|
void push_strikethrough();
|
2020-10-02 12:02:02 +00:00
|
|
|
void push_paragraph(Align p_align, Control::TextDirection p_direction = Control::TEXT_DIRECTION_INHERITED, const String &p_language = "", Control::StructuredTextParser p_st_parser = STRUCTURED_TEXT_DEFAULT);
|
2014-02-10 01:10:30 +00:00
|
|
|
void push_indent(int p_level);
|
2020-10-02 12:02:02 +00:00
|
|
|
void push_list(int p_level, ListType p_list, bool p_capitalize);
|
2017-08-11 19:10:05 +00:00
|
|
|
void push_meta(const Variant &p_meta);
|
2020-10-02 12:02:02 +00:00
|
|
|
void push_table(int p_columns, VAlign p_align = VALIGN_TOP);
|
2018-11-10 02:44:58 +00:00
|
|
|
void push_fade(int p_start_index, int p_length);
|
2019-09-22 16:45:08 +00:00
|
|
|
void push_shake(int p_strength, float p_rate);
|
2018-11-10 02:44:58 +00:00
|
|
|
void push_wave(float p_frequency, float p_amplitude);
|
|
|
|
void push_tornado(float p_frequency, float p_radius);
|
|
|
|
void push_rainbow(float p_saturation, float p_value, float p_frequency);
|
2019-09-25 20:05:42 +00:00
|
|
|
void push_customfx(Ref<RichTextEffect> p_custom_effect, Dictionary p_environment);
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_table_column_expand(int p_column, bool p_expand, int p_ratio = 1);
|
2020-10-02 12:02:02 +00:00
|
|
|
void set_cell_row_background_color(const Color &p_odd_row_bg, const Color &p_even_row_bg);
|
|
|
|
void set_cell_border_color(const Color &p_color);
|
|
|
|
void set_cell_size_override(const Size2 &p_min_size, const Size2 &p_max_size);
|
|
|
|
void set_cell_padding(const Rect2 &p_padding);
|
2015-12-26 13:25:17 +00:00
|
|
|
int get_current_table_column() const;
|
|
|
|
void push_cell();
|
2014-02-10 01:10:30 +00:00
|
|
|
void pop();
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
void set_offset(int p_pixel);
|
|
|
|
|
|
|
|
void set_meta_underline(bool p_underline);
|
|
|
|
bool is_meta_underlined() const;
|
|
|
|
|
2017-09-27 17:24:05 +00:00
|
|
|
void set_override_selected_font_color(bool p_override_selected_font_color);
|
|
|
|
bool is_overriding_selected_font_color() const;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_scroll_active(bool p_active);
|
|
|
|
bool is_scroll_active() const;
|
|
|
|
|
|
|
|
void set_scroll_follow(bool p_follow);
|
|
|
|
bool is_scroll_following() const;
|
|
|
|
|
|
|
|
void set_tab_size(int p_spaces);
|
|
|
|
int get_tab_size() const;
|
|
|
|
|
2019-11-01 14:17:40 +00:00
|
|
|
void set_fit_content_height(bool p_enabled);
|
|
|
|
bool is_fit_content_height_enabled() const;
|
|
|
|
|
2017-12-22 18:09:31 +00:00
|
|
|
bool search(const String &p_string, bool p_from_selection = false, bool p_search_previous = false);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-01-12 12:03:10 +00:00
|
|
|
void scroll_to_paragraph(int p_paragraph);
|
|
|
|
int get_paragraph_count() const;
|
|
|
|
int get_visible_paragraph_count() const;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void scroll_to_line(int p_line);
|
|
|
|
int get_line_count() const;
|
2016-10-17 19:03:47 +00:00
|
|
|
int get_visible_line_count() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-11-01 14:17:40 +00:00
|
|
|
int get_content_height() const;
|
2018-04-11 13:53:13 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
VScrollBar *get_v_scroll() { return vscroll; }
|
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void set_selection_enabled(bool p_enabled);
|
|
|
|
bool is_selection_enabled() const;
|
2021-02-11 16:33:45 +00:00
|
|
|
int get_selection_from() const;
|
|
|
|
int get_selection_to() const;
|
|
|
|
String get_selected_text() const;
|
2014-02-16 00:16:33 +00:00
|
|
|
void selection_copy();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Error parse_bbcode(const String &p_bbcode);
|
|
|
|
Error append_bbcode(const String &p_bbcode);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-04-21 19:01:58 +00:00
|
|
|
void set_use_bbcode(bool p_enable);
|
|
|
|
bool is_using_bbcode() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_bbcode(const String &p_bbcode);
|
2015-04-21 19:01:58 +00:00
|
|
|
String get_bbcode() const;
|
|
|
|
|
2017-07-03 19:59:58 +00:00
|
|
|
void set_text(const String &p_string);
|
|
|
|
|
2020-10-02 12:02:02 +00:00
|
|
|
void set_text_direction(TextDirection p_text_direction);
|
|
|
|
TextDirection get_text_direction() const;
|
|
|
|
|
|
|
|
void set_language(const String &p_language);
|
|
|
|
String get_language() const;
|
|
|
|
|
|
|
|
void set_structured_text_bidi_override(Control::StructuredTextParser p_parser);
|
|
|
|
Control::StructuredTextParser get_structured_text_bidi_override() const;
|
|
|
|
|
|
|
|
void set_structured_text_bidi_override_options(Array p_args);
|
|
|
|
Array get_structured_text_bidi_override_options() const;
|
|
|
|
|
2015-06-01 22:42:34 +00:00
|
|
|
void set_visible_characters(int p_visible);
|
|
|
|
int get_visible_characters() const;
|
|
|
|
int get_total_character_count() const;
|
|
|
|
|
2017-07-03 19:59:58 +00:00
|
|
|
void set_percent_visible(float p_percent);
|
|
|
|
float get_percent_visible() const;
|
|
|
|
|
2018-11-10 02:44:58 +00:00
|
|
|
void set_effects(const Vector<Variant> &effects);
|
|
|
|
Vector<Variant> get_effects();
|
|
|
|
|
|
|
|
void install_effect(const Variant effect);
|
|
|
|
|
2018-07-20 21:14:33 +00:00
|
|
|
void set_fixed_size_to_width(int p_width);
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual Size2 get_minimum_size() const override;
|
2018-07-20 21:14:33 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
RichTextLabel();
|
|
|
|
~RichTextLabel();
|
|
|
|
};
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
VARIANT_ENUM_CAST(RichTextLabel::Align);
|
|
|
|
VARIANT_ENUM_CAST(RichTextLabel::ListType);
|
|
|
|
VARIANT_ENUM_CAST(RichTextLabel::ItemType);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
#endif // RICH_TEXT_LABEL_H
|