2014-02-10 02:10:30 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* rich_text_label.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* 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-05 00:50:27 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#ifndef RICH_TEXT_LABEL_H
|
|
|
|
#define RICH_TEXT_LABEL_H
|
|
|
|
|
2023-01-27 21:53:06 +01:00
|
|
|
#include "core/object/worker_thread_pool.h"
|
2024-01-25 16:51:18 +01:00
|
|
|
#include "core/templates/rid_owner.h"
|
2022-04-12 08:58:04 +02:00
|
|
|
#include "scene/gui/popup_menu.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "scene/gui/scroll_bar.h"
|
2020-10-02 14:02:02 +02:00
|
|
|
#include "scene/resources/text_paragraph.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-06-03 16:42:26 +02:00
|
|
|
class CharFXTransform;
|
|
|
|
class RichTextEffect;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
class RichTextLabel : public Control {
|
2017-01-03 03:03:46 +01:00
|
|
|
GDCLASS(RichTextLabel, Control);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2014-02-10 02:10:30 +01:00
|
|
|
enum ListType {
|
|
|
|
LIST_NUMBERS,
|
|
|
|
LIST_LETTERS,
|
2020-10-02 14:02:02 +02:00
|
|
|
LIST_ROMAN,
|
2014-02-10 02:10:30 +01:00
|
|
|
LIST_DOTS
|
|
|
|
};
|
|
|
|
|
2024-02-29 20:21:13 +01:00
|
|
|
enum MetaUnderline {
|
|
|
|
META_UNDERLINE_NEVER,
|
|
|
|
META_UNDERLINE_ALWAYS,
|
|
|
|
META_UNDERLINE_ON_HOVER,
|
|
|
|
};
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
enum ItemType {
|
2015-12-26 14:25:17 +01:00
|
|
|
ITEM_FRAME,
|
2014-02-10 02:10:30 +01:00
|
|
|
ITEM_TEXT,
|
|
|
|
ITEM_IMAGE,
|
|
|
|
ITEM_NEWLINE,
|
|
|
|
ITEM_FONT,
|
2020-10-02 14:02:02 +02:00
|
|
|
ITEM_FONT_SIZE,
|
|
|
|
ITEM_FONT_FEATURES,
|
2014-02-10 02:10:30 +01:00
|
|
|
ITEM_COLOR,
|
2020-10-02 14:02:02 +02:00
|
|
|
ITEM_OUTLINE_SIZE,
|
|
|
|
ITEM_OUTLINE_COLOR,
|
2014-02-10 02:10:30 +01:00
|
|
|
ITEM_UNDERLINE,
|
2018-09-22 23:41:13 +02:00
|
|
|
ITEM_STRIKETHROUGH,
|
2020-10-02 14:02:02 +02:00
|
|
|
ITEM_PARAGRAPH,
|
2014-02-10 02:10:30 +01:00
|
|
|
ITEM_INDENT,
|
|
|
|
ITEM_LIST,
|
2015-12-26 14:25:17 +01:00
|
|
|
ITEM_TABLE,
|
2018-11-10 03:44:58 +01:00
|
|
|
ITEM_FADE,
|
|
|
|
ITEM_SHAKE,
|
|
|
|
ITEM_WAVE,
|
|
|
|
ITEM_TORNADO,
|
|
|
|
ITEM_RAINBOW,
|
2023-05-16 01:09:23 +02:00
|
|
|
ITEM_PULSE,
|
2020-01-26 23:11:09 +01:00
|
|
|
ITEM_BGCOLOR,
|
|
|
|
ITEM_FGCOLOR,
|
2018-11-10 03:44:58 +01:00
|
|
|
ITEM_META,
|
2022-02-21 18:34:16 +01:00
|
|
|
ITEM_HINT,
|
2020-11-19 15:45:23 +01:00
|
|
|
ITEM_DROPCAP,
|
2023-07-04 08:52:50 +02:00
|
|
|
ITEM_CUSTOMFX,
|
2023-08-21 13:52:09 +02:00
|
|
|
ITEM_CONTEXT,
|
|
|
|
ITEM_LANGUAGE,
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2022-04-12 08:58:04 +02:00
|
|
|
enum MenuItems {
|
|
|
|
MENU_COPY,
|
|
|
|
MENU_SELECT_ALL,
|
2023-02-03 10:07:36 +01:00
|
|
|
MENU_MAX
|
2022-04-12 08:58:04 +02:00
|
|
|
};
|
|
|
|
|
2022-09-16 21:24:11 +02:00
|
|
|
enum DefaultFont {
|
|
|
|
NORMAL_FONT,
|
|
|
|
BOLD_FONT,
|
|
|
|
ITALICS_FONT,
|
|
|
|
BOLD_ITALICS_FONT,
|
|
|
|
MONO_FONT,
|
|
|
|
CUSTOM_FONT,
|
|
|
|
};
|
|
|
|
|
2022-12-07 21:40:03 +01:00
|
|
|
enum ImageUpdateMask {
|
|
|
|
UPDATE_TEXTURE = 1 << 0,
|
|
|
|
UPDATE_SIZE = 1 << 1,
|
|
|
|
UPDATE_COLOR = 1 << 2,
|
|
|
|
UPDATE_ALIGNMENT = 1 << 3,
|
|
|
|
UPDATE_REGION = 1 << 4,
|
|
|
|
UPDATE_PAD = 1 << 5,
|
|
|
|
UPDATE_TOOLTIP = 1 << 6,
|
|
|
|
UPDATE_WIDTH_IN_PERCENT = 1 << 7,
|
|
|
|
};
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
protected:
|
2022-09-01 17:52:49 +02:00
|
|
|
virtual void _update_theme_item_cache() override;
|
2023-09-08 21:00:10 +02:00
|
|
|
|
2021-03-04 00:51:35 +01:00
|
|
|
void _notification(int p_what);
|
2014-02-10 02:10:30 +01:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2022-12-07 21:40:03 +01:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
2024-02-29 20:21:13 +01:00
|
|
|
void _push_meta_bind_compat_89024(const Variant &p_meta);
|
2022-12-07 21:40:03 +01:00
|
|
|
void _add_image_bind_compat_80410(const Ref<Texture2D> &p_image, const int p_width, const int p_height, const Color &p_color, InlineAlignment p_alignment, const Rect2 &p_region);
|
|
|
|
static void _bind_compatibility_methods();
|
|
|
|
#endif
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
private:
|
2019-09-25 22:05:42 +02:00
|
|
|
struct Item;
|
2015-12-26 14:25:17 +01:00
|
|
|
|
|
|
|
struct Line {
|
2020-10-02 14:02:02 +02:00
|
|
|
Item *from = nullptr;
|
|
|
|
|
|
|
|
Ref<TextParagraph> text_buf;
|
2020-11-19 15:45:23 +01:00
|
|
|
Color dc_color;
|
|
|
|
int dc_ol_size = 0;
|
|
|
|
Color dc_ol_color;
|
2020-10-02 14:02:02 +02:00
|
|
|
|
|
|
|
Vector2 offset;
|
|
|
|
int char_offset = 0;
|
|
|
|
int char_count = 0;
|
|
|
|
|
2021-06-18 00:03:09 +02:00
|
|
|
Line() { text_buf.instantiate(); }
|
2022-06-05 12:58:04 +02:00
|
|
|
|
|
|
|
_FORCE_INLINE_ float get_height(float line_separation) const {
|
|
|
|
return offset.y + text_buf->get_size().y + text_buf->get_line_count() * line_separation;
|
|
|
|
}
|
2015-12-26 14:25:17 +01:00
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct Item {
|
2020-10-02 14:02:02 +02:00
|
|
|
int index = 0;
|
|
|
|
int char_ofs = 0;
|
|
|
|
Item *parent = nullptr;
|
|
|
|
ItemType type = ITEM_FRAME;
|
2014-02-10 02:10:30 +01:00
|
|
|
List<Item *> subitems;
|
2020-10-02 14:02:02 +02:00
|
|
|
List<Item *>::Element *E = nullptr;
|
2024-01-25 16:51:18 +01:00
|
|
|
ObjectID owner;
|
2020-10-02 14:02:02 +02:00
|
|
|
int line = 0;
|
2024-01-25 16:51:18 +01:00
|
|
|
RID rid;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void _clear_children() {
|
2024-01-25 16:51:18 +01:00
|
|
|
RichTextLabel *owner_rtl = Object::cast_to<RichTextLabel>(ObjectDB::get_instance(owner));
|
2014-02-10 02:10:30 +01:00
|
|
|
while (subitems.size()) {
|
2024-01-25 16:51:18 +01:00
|
|
|
Item *subitem = subitems.front()->get();
|
|
|
|
if (subitem && subitem->rid.is_valid() && owner_rtl) {
|
|
|
|
owner_rtl->items.free(subitem->rid);
|
|
|
|
}
|
|
|
|
memdelete(subitem);
|
2014-02-10 02:10:30 +01:00
|
|
|
subitems.pop_front();
|
|
|
|
}
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
virtual ~Item() { _clear_children(); }
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemFrame : public Item {
|
2020-10-02 14:02:02 +02:00
|
|
|
bool cell = false;
|
|
|
|
|
2022-05-18 09:17:55 +02:00
|
|
|
LocalVector<Line> lines;
|
|
|
|
std::atomic<int> first_invalid_line;
|
|
|
|
std::atomic<int> first_invalid_font_line;
|
|
|
|
std::atomic<int> first_resized_line;
|
2020-10-02 14:02:02 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2022-05-18 09:17:55 +02:00
|
|
|
ItemFrame() {
|
|
|
|
type = ITEM_FRAME;
|
|
|
|
first_invalid_line.store(0);
|
|
|
|
first_invalid_font_line.store(0);
|
|
|
|
first_resized_line.store(0);
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemText : public Item {
|
2014-02-10 02:10:30 +01:00
|
|
|
String text;
|
|
|
|
ItemText() { type = ITEM_TEXT; }
|
|
|
|
};
|
|
|
|
|
2020-11-19 15:45:23 +01:00
|
|
|
struct ItemDropcap : public Item {
|
|
|
|
String text;
|
|
|
|
Ref<Font> font;
|
2021-02-09 18:24:36 +01:00
|
|
|
int font_size = 0;
|
2020-11-19 15:45:23 +01:00
|
|
|
Color color;
|
2021-02-09 18:24:36 +01:00
|
|
|
int ol_size = 0;
|
2020-11-19 15:45:23 +01:00
|
|
|
Color ol_color;
|
|
|
|
Rect2 dropcap_margins;
|
|
|
|
ItemDropcap() { type = ITEM_DROPCAP; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemImage : public Item {
|
2019-06-11 20:43:37 +02:00
|
|
|
Ref<Texture2D> image;
|
2021-11-25 03:58:47 +01:00
|
|
|
InlineAlignment inline_align = INLINE_ALIGNMENT_CENTER;
|
2022-12-07 21:40:03 +01:00
|
|
|
bool pad = false;
|
|
|
|
bool size_in_percent = false;
|
|
|
|
Rect2 region;
|
2019-10-16 12:00:15 +02:00
|
|
|
Size2 size;
|
2022-12-07 21:40:03 +01:00
|
|
|
Size2 rq_size;
|
2020-05-28 08:17:17 +02:00
|
|
|
Color color;
|
2022-12-07 21:40:03 +01:00
|
|
|
Variant key;
|
|
|
|
String tooltip;
|
2014-02-10 02:10:30 +01:00
|
|
|
ItemImage() { type = ITEM_IMAGE; }
|
2024-01-25 16:51:18 +01:00
|
|
|
~ItemImage() {
|
|
|
|
if (image.is_valid()) {
|
|
|
|
RichTextLabel *owner_rtl = Object::cast_to<RichTextLabel>(ObjectDB::get_instance(owner));
|
|
|
|
if (owner_rtl) {
|
|
|
|
image->disconnect_changed(callable_mp(owner_rtl, &RichTextLabel::_texture_changed));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemFont : public Item {
|
2022-09-16 21:24:11 +02:00
|
|
|
DefaultFont def_font = CUSTOM_FONT;
|
2014-02-10 02:10:30 +01:00
|
|
|
Ref<Font> font;
|
2022-09-26 12:02:25 +02:00
|
|
|
bool variation = false;
|
|
|
|
bool def_size = false;
|
2022-07-26 09:45:40 +02:00
|
|
|
int font_size = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
ItemFont() { type = ITEM_FONT; }
|
|
|
|
};
|
|
|
|
|
2020-10-02 14:02:02 +02:00
|
|
|
struct ItemFontSize : public Item {
|
|
|
|
int font_size = 16;
|
|
|
|
ItemFontSize() { type = ITEM_FONT_SIZE; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemColor : public Item {
|
2014-02-10 02:10:30 +01:00
|
|
|
Color color;
|
|
|
|
ItemColor() { type = ITEM_COLOR; }
|
|
|
|
};
|
|
|
|
|
2020-10-02 14:02:02 +02: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 22:05:42 +02:00
|
|
|
struct ItemUnderline : public Item {
|
2014-02-10 02:10:30 +01:00
|
|
|
ItemUnderline() { type = ITEM_UNDERLINE; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemStrikethrough : public Item {
|
2018-09-22 23:41:13 +02:00
|
|
|
ItemStrikethrough() { type = ITEM_STRIKETHROUGH; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemMeta : public Item {
|
2014-02-10 02:10:30 +01:00
|
|
|
Variant meta;
|
2024-02-29 20:21:13 +01:00
|
|
|
MetaUnderline underline = META_UNDERLINE_ALWAYS;
|
2014-02-10 02:10:30 +01:00
|
|
|
ItemMeta() { type = ITEM_META; }
|
|
|
|
};
|
|
|
|
|
2022-02-21 18:34:16 +01:00
|
|
|
struct ItemHint : public Item {
|
|
|
|
String description;
|
|
|
|
ItemHint() { type = ITEM_HINT; }
|
|
|
|
};
|
|
|
|
|
2023-08-21 13:52:09 +02:00
|
|
|
struct ItemLanguage : public Item {
|
|
|
|
String language;
|
|
|
|
ItemLanguage() { type = ITEM_LANGUAGE; }
|
|
|
|
};
|
|
|
|
|
2020-10-02 14:02:02 +02:00
|
|
|
struct ItemParagraph : public Item {
|
2021-11-25 03:58:47 +01:00
|
|
|
HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT;
|
2020-10-02 14:02:02 +02:00
|
|
|
String language;
|
|
|
|
Control::TextDirection direction = Control::TEXT_DIRECTION_AUTO;
|
2022-04-19 12:27:18 +02:00
|
|
|
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
2023-03-23 10:22:37 +01:00
|
|
|
BitField<TextServer::JustificationFlag> jst_flags = TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_SKIP_LAST_LINE | TextServer::JUSTIFICATION_DO_NOT_SKIP_SINGLE_LINE;
|
2023-04-24 13:45:45 +02:00
|
|
|
PackedFloat32Array tab_stops;
|
2020-10-02 14:02:02 +02:00
|
|
|
ItemParagraph() { type = ITEM_PARAGRAPH; }
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemIndent : public Item {
|
2020-10-02 14:02:02 +02:00
|
|
|
int level = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
ItemIndent() { type = ITEM_INDENT; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemList : public Item {
|
2020-10-02 14:02:02 +02:00
|
|
|
ListType list_type = LIST_DOTS;
|
|
|
|
bool capitalize = false;
|
|
|
|
int level = 0;
|
2023-08-07 10:37:41 +02:00
|
|
|
String bullet = U"•";
|
2014-02-10 02:10:30 +01:00
|
|
|
ItemList() { type = ITEM_LIST; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemNewline : public Item {
|
2014-02-10 02:10:30 +01:00
|
|
|
ItemNewline() { type = ITEM_NEWLINE; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemTable : public Item {
|
2015-12-26 14:25:17 +01:00
|
|
|
struct Column {
|
2021-02-09 18:24:36 +01:00
|
|
|
bool expand = false;
|
|
|
|
int expand_ratio = 0;
|
|
|
|
int min_width = 0;
|
|
|
|
int max_width = 0;
|
|
|
|
int width = 0;
|
2015-12-26 14:25:17 +01:00
|
|
|
};
|
|
|
|
|
2022-05-18 09:17:55 +02:00
|
|
|
LocalVector<Column> columns;
|
|
|
|
LocalVector<float> rows;
|
2022-12-08 21:01:07 +01:00
|
|
|
LocalVector<float> rows_baseline;
|
2020-10-02 14:02:02 +02:00
|
|
|
|
2022-12-08 21:01:07 +01:00
|
|
|
int align_to_row = -1;
|
2020-10-02 14:02:02 +02:00
|
|
|
int total_width = 0;
|
|
|
|
int total_height = 0;
|
2021-11-25 03:58:47 +01:00
|
|
|
InlineAlignment inline_align = INLINE_ALIGNMENT_TOP;
|
2015-12-26 14:25:17 +01:00
|
|
|
ItemTable() { type = ITEM_TABLE; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemFade : public Item {
|
2020-10-02 14:02:02 +02:00
|
|
|
int starting_index = 0;
|
|
|
|
int length = 0;
|
2018-11-10 03:44:58 +01:00
|
|
|
|
|
|
|
ItemFade() { type = ITEM_FADE; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemFX : public Item {
|
2021-02-02 03:16:37 +01:00
|
|
|
double elapsed_time = 0.f;
|
2022-09-18 21:20:48 +02:00
|
|
|
bool connected = true;
|
2018-11-10 03:44:58 +01:00
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemShake : public ItemFX {
|
2020-10-02 14:02:02 +02:00
|
|
|
int strength = 0;
|
|
|
|
float rate = 0.0f;
|
|
|
|
uint64_t _current_rng = 0;
|
|
|
|
uint64_t _previous_rng = 0;
|
2021-09-21 11:27:06 +02:00
|
|
|
Vector2 prev_off;
|
2020-10-02 14:02:02 +02:00
|
|
|
|
|
|
|
ItemShake() { type = ITEM_SHAKE; }
|
2018-11-10 03:44:58 +01:00
|
|
|
|
|
|
|
void reroll_random() {
|
|
|
|
_previous_rng = _current_rng;
|
|
|
|
_current_rng = Math::rand();
|
|
|
|
}
|
|
|
|
|
2022-09-29 11:53:28 +02:00
|
|
|
uint64_t offset_random(int p_index) {
|
|
|
|
return (_current_rng >> (p_index % 64)) |
|
|
|
|
(_current_rng << (64 - (p_index % 64)));
|
2018-11-10 03:44:58 +01:00
|
|
|
}
|
|
|
|
|
2022-09-29 11:53:28 +02:00
|
|
|
uint64_t offset_previous_random(int p_index) {
|
|
|
|
return (_previous_rng >> (p_index % 64)) |
|
|
|
|
(_previous_rng << (64 - (p_index % 64)));
|
2018-11-10 03:44:58 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemWave : public ItemFX {
|
2020-10-02 14:02:02 +02:00
|
|
|
float frequency = 1.0f;
|
|
|
|
float amplitude = 1.0f;
|
2021-09-21 11:27:06 +02:00
|
|
|
Vector2 prev_off;
|
2018-11-10 03:44:58 +01:00
|
|
|
|
2020-10-02 14:02:02 +02:00
|
|
|
ItemWave() { type = ITEM_WAVE; }
|
2018-11-10 03:44:58 +01:00
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemTornado : public ItemFX {
|
2020-10-02 14:02:02 +02:00
|
|
|
float radius = 1.0f;
|
|
|
|
float frequency = 1.0f;
|
2021-09-21 11:27:06 +02:00
|
|
|
Vector2 prev_off;
|
2018-11-10 03:44:58 +01:00
|
|
|
|
2020-10-02 14:02:02 +02:00
|
|
|
ItemTornado() { type = ITEM_TORNADO; }
|
2018-11-10 03:44:58 +01:00
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemRainbow : public ItemFX {
|
2020-10-02 14:02:02 +02:00
|
|
|
float saturation = 0.8f;
|
|
|
|
float value = 0.8f;
|
|
|
|
float frequency = 1.0f;
|
|
|
|
|
|
|
|
ItemRainbow() { type = ITEM_RAINBOW; }
|
2018-11-10 03:44:58 +01:00
|
|
|
};
|
|
|
|
|
2023-05-16 01:09:23 +02:00
|
|
|
struct ItemPulse : public ItemFX {
|
|
|
|
Color color = Color(1.0, 1.0, 1.0, 0.25);
|
|
|
|
float frequency = 1.0f;
|
|
|
|
float ease = -2.0f;
|
|
|
|
|
|
|
|
ItemPulse() { type = ITEM_PULSE; }
|
|
|
|
};
|
|
|
|
|
2020-01-26 23:11:09 +01:00
|
|
|
struct ItemBGColor : public Item {
|
|
|
|
Color color;
|
|
|
|
ItemBGColor() { type = ITEM_BGCOLOR; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ItemFGColor : public Item {
|
|
|
|
Color color;
|
|
|
|
ItemFGColor() { type = ITEM_FGCOLOR; }
|
|
|
|
};
|
|
|
|
|
2019-09-25 22:05:42 +02:00
|
|
|
struct ItemCustomFX : public ItemFX {
|
|
|
|
Ref<CharFXTransform> char_fx_transform;
|
|
|
|
Ref<RichTextEffect> custom_effect;
|
2018-11-10 03:44:58 +01:00
|
|
|
|
2023-06-03 16:42:26 +02:00
|
|
|
ItemCustomFX();
|
2019-09-25 22:05:42 +02:00
|
|
|
|
2023-06-03 16:42:26 +02:00
|
|
|
virtual ~ItemCustomFX();
|
2018-11-10 03:44:58 +01:00
|
|
|
};
|
|
|
|
|
2023-07-04 08:52:50 +02:00
|
|
|
struct ItemContext : public Item {
|
|
|
|
ItemContext() { type = ITEM_CONTEXT; }
|
|
|
|
};
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
ItemFrame *main = nullptr;
|
|
|
|
Item *current = nullptr;
|
|
|
|
ItemFrame *current_frame = nullptr;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-01-27 21:53:06 +01:00
|
|
|
WorkerThreadPool::TaskID task = WorkerThreadPool::INVALID_TASK_ID;
|
2022-05-18 09:17:55 +02:00
|
|
|
Mutex data_mutex;
|
|
|
|
bool threaded = false;
|
|
|
|
std::atomic<bool> stop_thread;
|
|
|
|
std::atomic<bool> updating;
|
2023-04-12 10:39:05 +02:00
|
|
|
std::atomic<bool> validating;
|
2022-05-18 09:17:55 +02:00
|
|
|
std::atomic<double> loaded;
|
|
|
|
|
|
|
|
uint64_t loading_started = 0;
|
|
|
|
int progress_delay = 1000;
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
VScrollBar *vscroll = nullptr;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-06-15 10:01:45 +02:00
|
|
|
TextServer::AutowrapMode autowrap_mode = TextServer::AUTOWRAP_WORD_SMART;
|
2022-02-03 14:56:44 +01:00
|
|
|
|
2021-02-09 18:24:36 +01: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 14:02:02 +02:00
|
|
|
int current_idx = 1;
|
|
|
|
int current_char_ofs = 0;
|
2021-02-09 18:24:36 +01:00
|
|
|
int visible_paragraph_count = 0;
|
|
|
|
int visible_line_count = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
int tab_size = 4;
|
|
|
|
bool underline_meta = true;
|
2022-02-21 18:34:16 +01:00
|
|
|
bool underline_hint = true;
|
2022-10-26 00:46:06 +02:00
|
|
|
bool use_selected_font_color = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-11-25 03:58:47 +01:00
|
|
|
HorizontalAlignment default_alignment = HORIZONTAL_ALIGNMENT_LEFT;
|
2023-03-23 10:22:37 +01:00
|
|
|
BitField<TextServer::JustificationFlag> default_jst_flags = TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_SKIP_LAST_LINE | TextServer::JUSTIFICATION_DO_NOT_SKIP_SINGLE_LINE;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
ItemMeta *meta_hovering = nullptr;
|
2017-11-17 06:49:39 +01:00
|
|
|
Variant current_meta;
|
|
|
|
|
2021-08-24 22:02:24 +02:00
|
|
|
Array custom_effects;
|
2018-11-10 03:44:58 +01:00
|
|
|
|
2015-12-26 14:25:17 +01:00
|
|
|
void _invalidate_current_line(ItemFrame *p_frame);
|
2022-05-18 09:17:55 +02:00
|
|
|
|
2023-01-27 21:53:06 +01:00
|
|
|
void _thread_function(void *p_userdata);
|
|
|
|
void _thread_end();
|
2022-05-18 09:17:55 +02:00
|
|
|
void _stop_thread();
|
|
|
|
bool _validate_line_caches();
|
|
|
|
void _process_line_caches();
|
2023-06-14 22:15:16 +02:00
|
|
|
_FORCE_INLINE_ float _update_scroll_exceeds(float p_total_height, float p_ctrl_height, float p_width, int p_idx, float p_old_scroll, float p_text_rect_height);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-12-26 14:25:17 +01:00
|
|
|
void _add_item(Item *p_item, bool p_enter = false, bool p_ensure_newline = false);
|
2024-04-10 09:03:37 +02:00
|
|
|
void _remove_frame(HashSet<Item *> &r_erase_list, ItemFrame *p_frame, int p_line, bool p_erase, int p_char_offset, int p_line_offset);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2024-01-25 16:51:18 +01:00
|
|
|
void _texture_changed(RID p_item);
|
|
|
|
|
|
|
|
RID_PtrOwner<Item> items;
|
|
|
|
|
2020-10-02 14:02:02 +02:00
|
|
|
String language;
|
|
|
|
TextDirection text_direction = TEXT_DIRECTION_AUTO;
|
2022-04-19 12:27:18 +02:00
|
|
|
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
2020-10-02 14:02:02 +02:00
|
|
|
Array st_args;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
struct Selection {
|
2021-02-09 18:24:36 +01: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?
|
2021-11-21 19:26:15 +01:00
|
|
|
bool drag_attempt = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Selection selection;
|
2021-10-21 23:02:46 +02:00
|
|
|
bool deselect_on_focus_loss_enabled = true;
|
2023-07-17 02:32:00 +02:00
|
|
|
bool drag_and_drop_selection_enabled = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-04-12 08:58:04 +02:00
|
|
|
bool context_menu_enabled = false;
|
|
|
|
bool shortcut_keys_enabled = true;
|
|
|
|
|
|
|
|
// Context menu.
|
|
|
|
PopupMenu *menu = nullptr;
|
|
|
|
void _generate_context_menu();
|
2023-02-03 10:07:36 +01:00
|
|
|
void _update_context_menu();
|
2022-04-12 08:58:04 +02:00
|
|
|
Key _get_menu_action_accelerator(const String &p_action);
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
int visible_characters = -1;
|
2022-08-20 20:06:13 +02:00
|
|
|
float visible_ratio = 1.0;
|
2022-06-15 10:01:45 +02:00
|
|
|
TextServer::VisibleCharactersBehavior visible_chars_behavior = TextServer::VC_CHARS_BEFORE_SHAPING;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-11-21 19:26:15 +01:00
|
|
|
bool _is_click_inside_selection() const;
|
2022-08-23 08:57:22 +02: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, bool p_meta = false);
|
2020-10-02 14:02:02 +02:00
|
|
|
|
2021-02-11 17:33:45 +01:00
|
|
|
String _get_line_text(ItemFrame *p_frame, int p_line, Selection p_sel) const;
|
2021-06-16 18:43:34 +02:00
|
|
|
bool _search_line(ItemFrame *p_frame, int p_line, const String &p_string, int p_char_idx, bool p_reverse_search);
|
|
|
|
bool _search_table(ItemTable *p_table, List<Item *>::Element *p_from, const String &p_string, bool p_reverse_search);
|
2020-10-02 14:02:02 +02:00
|
|
|
|
2022-05-18 09:17:55 +02:00
|
|
|
float _shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width, float p_h, int *r_char_offset);
|
|
|
|
float _resize_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width, float p_h);
|
|
|
|
|
2022-01-20 08:30:42 +01:00
|
|
|
void _update_line_font(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size);
|
2021-12-05 13:28:32 +01: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, int p_shadow_outline_size, const Point2 &p_shadow_ofs, int &r_processed_glyphs);
|
2022-08-23 08:57:22 +02: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, bool p_table = false, bool p_meta = false);
|
2020-10-02 14:02:02 +02:00
|
|
|
|
|
|
|
String _roman(int p_num, bool p_capitalize) const;
|
|
|
|
String _letters(int p_num, bool p_capitalize) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-07-06 14:16:50 +02:00
|
|
|
Item *_find_indentable(Item *p_item);
|
2020-10-02 14:02:02 +02: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);
|
2022-07-26 09:45:40 +02:00
|
|
|
ItemFontSize *_find_font_size(Item *p_item);
|
|
|
|
ItemFont *_find_font(Item *p_item);
|
2020-12-25 22:45:28 +01:00
|
|
|
int _find_outline_size(Item *p_item, int p_default);
|
2020-10-02 14:02:02 +02:00
|
|
|
ItemList *_find_list_item(Item *p_item);
|
2020-11-19 15:45:23 +01:00
|
|
|
ItemDropcap *_find_dc_item(Item *p_item);
|
2020-10-02 14:02:02 +02: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);
|
2023-04-24 13:45:45 +02:00
|
|
|
PackedFloat32Array _find_tab_stops(Item *p_item);
|
2021-11-25 03:58:47 +01:00
|
|
|
HorizontalAlignment _find_alignment(Item *p_item);
|
2023-03-23 10:22:37 +01:00
|
|
|
BitField<TextServer::JustificationFlag> _find_jst_flags(Item *p_item);
|
2020-10-02 14:02:02 +02:00
|
|
|
TextServer::Direction _find_direction(Item *p_item);
|
2022-04-19 12:27:18 +02:00
|
|
|
TextServer::StructuredTextParser _find_stt(Item *p_item);
|
2020-10-02 14:02:02 +02:00
|
|
|
String _find_language(Item *p_item);
|
2014-02-10 02:10:30 +01:00
|
|
|
Color _find_color(Item *p_item, const Color &p_default_color);
|
2020-10-02 14:02:02 +02:00
|
|
|
Color _find_outline_color(Item *p_item, const Color &p_default_color);
|
2014-02-10 02:10:30 +01:00
|
|
|
bool _find_underline(Item *p_item);
|
2018-09-22 23:41:13 +02:00
|
|
|
bool _find_strikethrough(Item *p_item);
|
2020-04-02 01:20:12 +02:00
|
|
|
bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = nullptr);
|
2022-02-21 18:34:16 +01:00
|
|
|
bool _find_hint(Item *p_item, String *r_description);
|
2020-01-26 23:11:09 +01:00
|
|
|
Color _find_bgcolor(Item *p_item);
|
|
|
|
Color _find_fgcolor(Item *p_item);
|
2019-06-20 12:42:25 +02:00
|
|
|
bool _find_layout_subitem(Item *from, Item *to);
|
2019-09-25 22:05:42 +02:00
|
|
|
void _fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack);
|
2023-04-03 18:52:43 +02:00
|
|
|
void _normalize_subtags(Vector<String> &subtags);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-02 03:16:37 +01:00
|
|
|
void _update_fx(ItemFrame *p_frame, double p_delta_time);
|
2014-02-10 02:10:30 +01:00
|
|
|
void _scroll_changed(double);
|
2022-05-18 09:17:55 +02:00
|
|
|
int _find_first_line(int p_from, int p_to, int p_vofs) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-06-05 12:58:04 +02:00
|
|
|
_FORCE_INLINE_ float _calculate_line_vertical_offset(const Line &line) const;
|
|
|
|
|
2021-08-22 17:37:22 +02:00
|
|
|
virtual void gui_input(const Ref<InputEvent> &p_event) override;
|
2022-02-21 18:34:16 +01:00
|
|
|
virtual String get_tooltip(const Point2 &p_pos) const override;
|
2021-02-11 17:33:45 +01: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 02:10:30 +01:00
|
|
|
|
2017-09-02 18:20:04 +02:00
|
|
|
Rect2 _get_text_rect();
|
2018-11-10 03:44:58 +01: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 18:20:04 +02:00
|
|
|
|
2022-12-07 21:40:03 +01:00
|
|
|
Size2 _get_image_size(const Ref<Texture2D> &p_image, int p_width = 0, int p_height = 0, const Rect2 &p_region = Rect2());
|
|
|
|
|
2020-01-26 23:11:09 +01:00
|
|
|
void _draw_fbg_boxes(RID p_ci, RID p_rid, Vector2 line_off, Item *it_from, Item *it_to, int start, int end, int fbg_flag);
|
2020-05-29 16:25:12 +02:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
|
|
|
// Kept for compatibility from 3.x to 4.0.
|
|
|
|
bool _set(const StringName &p_name, const Variant &p_value);
|
|
|
|
#endif
|
2021-02-09 18:24:36 +01:00
|
|
|
bool use_bbcode = false;
|
2020-05-29 16:25:12 +02:00
|
|
|
String text;
|
2023-02-28 16:48:49 +01:00
|
|
|
void _apply_translation();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-01-13 15:17:26 +01:00
|
|
|
bool fit_content = false;
|
2019-11-01 15:17:40 +01:00
|
|
|
|
2022-09-01 17:52:49 +02:00
|
|
|
struct ThemeCache {
|
|
|
|
Ref<StyleBox> normal_style;
|
|
|
|
Ref<StyleBox> focus_style;
|
|
|
|
Ref<StyleBox> progress_bg_style;
|
|
|
|
Ref<StyleBox> progress_fg_style;
|
|
|
|
|
|
|
|
int line_separation;
|
|
|
|
|
|
|
|
Ref<Font> normal_font;
|
|
|
|
int normal_font_size;
|
|
|
|
|
|
|
|
Color default_color;
|
|
|
|
Color font_selected_color;
|
|
|
|
Color selection_color;
|
|
|
|
Color font_outline_color;
|
|
|
|
Color font_shadow_color;
|
|
|
|
int shadow_outline_size;
|
|
|
|
int shadow_offset_x;
|
|
|
|
int shadow_offset_y;
|
|
|
|
int outline_size;
|
|
|
|
Color outline_color;
|
|
|
|
|
|
|
|
Ref<Font> bold_font;
|
|
|
|
int bold_font_size;
|
|
|
|
Ref<Font> bold_italics_font;
|
|
|
|
int bold_italics_font_size;
|
|
|
|
Ref<Font> italics_font;
|
|
|
|
int italics_font_size;
|
|
|
|
Ref<Font> mono_font;
|
|
|
|
int mono_font_size;
|
|
|
|
|
2023-09-12 15:01:42 +02:00
|
|
|
int text_highlight_h_padding;
|
|
|
|
int text_highlight_v_padding;
|
|
|
|
|
2022-09-01 17:52:49 +02:00
|
|
|
int table_h_separation;
|
|
|
|
int table_v_separation;
|
|
|
|
Color table_odd_row_bg;
|
|
|
|
Color table_even_row_bg;
|
|
|
|
Color table_border;
|
|
|
|
|
|
|
|
float base_scale = 1.0;
|
|
|
|
} theme_cache;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
public:
|
2020-05-29 16:25:12 +02:00
|
|
|
String get_parsed_text() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
void add_text(const String &p_text);
|
2022-12-07 21:40:03 +01:00
|
|
|
void add_image(const Ref<Texture2D> &p_image, int p_width = 0, int p_height = 0, const Color &p_color = Color(1.0, 1.0, 1.0), InlineAlignment p_alignment = INLINE_ALIGNMENT_CENTER, const Rect2 &p_region = Rect2(), const Variant &p_key = Variant(), bool p_pad = false, const String &p_tooltip = String(), bool p_size_in_percent = false);
|
|
|
|
void update_image(const Variant &p_key, BitField<ImageUpdateMask> p_mask, const Ref<Texture2D> &p_image, int p_width = 0, int p_height = 0, const Color &p_color = Color(1.0, 1.0, 1.0), InlineAlignment p_alignment = INLINE_ALIGNMENT_CENTER, const Rect2 &p_region = Rect2(), bool p_pad = false, const String &p_tooltip = String(), bool p_size_in_percent = false);
|
2014-02-10 02:10:30 +01:00
|
|
|
void add_newline();
|
2022-12-21 18:54:18 +01:00
|
|
|
bool remove_paragraph(const int p_paragraph);
|
2020-11-19 15:45:23 +01: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));
|
2022-09-26 12:02:25 +02:00
|
|
|
void _push_def_font(DefaultFont p_def_font);
|
|
|
|
void _push_def_font_var(DefaultFont p_def_font, const Ref<Font> &p_font, int p_size = -1);
|
2022-07-26 09:45:40 +02:00
|
|
|
void push_font(const Ref<Font> &p_font, int p_size = 0);
|
2020-10-02 14:02:02 +02:00
|
|
|
void push_font_size(int p_font_size);
|
|
|
|
void push_outline_size(int p_font_size);
|
2019-10-16 15:22:56 +02:00
|
|
|
void push_normal();
|
|
|
|
void push_bold();
|
|
|
|
void push_bold_italics();
|
|
|
|
void push_italics();
|
|
|
|
void push_mono();
|
2014-02-10 02:10:30 +01:00
|
|
|
void push_color(const Color &p_color);
|
2020-10-02 14:02:02 +02:00
|
|
|
void push_outline_color(const Color &p_color);
|
2014-02-10 02:10:30 +01:00
|
|
|
void push_underline();
|
2018-09-22 23:41:13 +02:00
|
|
|
void push_strikethrough();
|
2023-08-21 13:52:09 +02:00
|
|
|
void push_language(const String &p_language);
|
2023-04-24 13:45:45 +02:00
|
|
|
void push_paragraph(HorizontalAlignment p_alignment, Control::TextDirection p_direction = Control::TEXT_DIRECTION_INHERITED, const String &p_language = "", TextServer::StructuredTextParser p_st_parser = TextServer::STRUCTURED_TEXT_DEFAULT, BitField<TextServer::JustificationFlag> p_jst_flags = TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_SKIP_LAST_LINE | TextServer::JUSTIFICATION_DO_NOT_SKIP_SINGLE_LINE, const PackedFloat32Array &p_tab_stops = PackedFloat32Array());
|
2014-02-10 02:10:30 +01:00
|
|
|
void push_indent(int p_level);
|
2023-03-17 07:44:11 +01:00
|
|
|
void push_list(int p_level, ListType p_list, bool p_capitalize, const String &p_bullet = String::utf8("•"));
|
2024-02-29 20:21:13 +01:00
|
|
|
void push_meta(const Variant &p_meta, MetaUnderline p_underline_mode = META_UNDERLINE_ALWAYS);
|
2022-02-21 18:34:16 +01:00
|
|
|
void push_hint(const String &p_string);
|
2022-12-08 21:01:07 +01:00
|
|
|
void push_table(int p_columns, InlineAlignment p_alignment = INLINE_ALIGNMENT_TOP, int p_align_to_row = -1);
|
2018-11-10 03:44:58 +01:00
|
|
|
void push_fade(int p_start_index, int p_length);
|
2022-09-18 21:20:48 +02:00
|
|
|
void push_shake(int p_strength, float p_rate, bool p_connected);
|
|
|
|
void push_wave(float p_frequency, float p_amplitude, bool p_connected);
|
|
|
|
void push_tornado(float p_frequency, float p_radius, bool p_connected);
|
2018-11-10 03:44:58 +01:00
|
|
|
void push_rainbow(float p_saturation, float p_value, float p_frequency);
|
2023-05-16 01:09:23 +02:00
|
|
|
void push_pulse(const Color &p_color, float p_frequency, float p_ease);
|
2020-01-26 23:11:09 +01:00
|
|
|
void push_bgcolor(const Color &p_color);
|
|
|
|
void push_fgcolor(const Color &p_color);
|
2019-09-25 22:05:42 +02:00
|
|
|
void push_customfx(Ref<RichTextEffect> p_custom_effect, Dictionary p_environment);
|
2023-07-04 08:52:50 +02:00
|
|
|
void push_context();
|
2015-12-26 14:25:17 +01:00
|
|
|
void set_table_column_expand(int p_column, bool p_expand, int p_ratio = 1);
|
2020-10-02 14:02:02 +02: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 14:25:17 +01:00
|
|
|
int get_current_table_column() const;
|
|
|
|
void push_cell();
|
2014-02-10 02:10:30 +01:00
|
|
|
void pop();
|
2023-07-04 08:52:50 +02:00
|
|
|
void pop_context();
|
|
|
|
void pop_all();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
void set_offset(int p_pixel);
|
|
|
|
|
|
|
|
void set_meta_underline(bool p_underline);
|
|
|
|
bool is_meta_underlined() const;
|
|
|
|
|
2022-02-21 18:34:16 +01:00
|
|
|
void set_hint_underline(bool p_underline);
|
|
|
|
bool is_hint_underlined() const;
|
|
|
|
|
2014-02-10 02:10:30 +01: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;
|
|
|
|
|
2022-04-12 08:58:04 +02:00
|
|
|
void set_context_menu_enabled(bool p_enabled);
|
|
|
|
bool is_context_menu_enabled() const;
|
|
|
|
|
|
|
|
void set_shortcut_keys_enabled(bool p_enabled);
|
|
|
|
bool is_shortcut_keys_enabled() const;
|
|
|
|
|
2023-01-13 15:17:26 +01:00
|
|
|
void set_fit_content(bool p_enabled);
|
|
|
|
bool is_fit_content_enabled() const;
|
2019-11-01 15:17:40 +01:00
|
|
|
|
2017-12-22 19:09:31 +01:00
|
|
|
bool search(const String &p_string, bool p_from_selection = false, bool p_search_previous = false);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-01-12 13:03:10 +01:00
|
|
|
void scroll_to_paragraph(int p_paragraph);
|
|
|
|
int get_paragraph_count() const;
|
|
|
|
int get_visible_paragraph_count() const;
|
|
|
|
|
2022-02-13 18:33:37 +01:00
|
|
|
float get_line_offset(int p_line);
|
|
|
|
float get_paragraph_offset(int p_paragraph);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void scroll_to_line(int p_line);
|
|
|
|
int get_line_count() const;
|
2016-10-17 21:03:47 +02:00
|
|
|
int get_visible_line_count() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2019-11-01 15:17:40 +01:00
|
|
|
int get_content_height() const;
|
2022-02-09 21:02:46 +01:00
|
|
|
int get_content_width() const;
|
2018-04-11 15:53:13 +02:00
|
|
|
|
2022-12-04 21:11:21 +01:00
|
|
|
void scroll_to_selection();
|
|
|
|
|
2021-11-30 17:46:36 +01:00
|
|
|
VScrollBar *get_v_scroll_bar() { return vscroll; }
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override;
|
2021-11-21 19:26:15 +01:00
|
|
|
virtual Variant get_drag_data(const Point2 &p_point) override;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void set_selection_enabled(bool p_enabled);
|
|
|
|
bool is_selection_enabled() const;
|
2021-02-11 17:33:45 +01:00
|
|
|
int get_selection_from() const;
|
|
|
|
int get_selection_to() const;
|
|
|
|
String get_selected_text() const;
|
2022-04-10 18:03:10 +02:00
|
|
|
void select_all();
|
2014-02-16 01:16:33 +01:00
|
|
|
void selection_copy();
|
2023-07-17 02:32:00 +02:00
|
|
|
|
2021-10-21 23:02:46 +02:00
|
|
|
void set_deselect_on_focus_loss_enabled(const bool p_enabled);
|
|
|
|
bool is_deselect_on_focus_loss_enabled() const;
|
2023-07-17 02:32:00 +02:00
|
|
|
|
|
|
|
void set_drag_and_drop_selection_enabled(const bool p_enabled);
|
|
|
|
bool is_drag_and_drop_selection_enabled() const;
|
|
|
|
|
2022-04-04 16:06:57 +02:00
|
|
|
void deselect();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-06-07 19:09:09 +02:00
|
|
|
int get_pending_paragraphs() const;
|
2022-05-18 09:17:55 +02:00
|
|
|
bool is_ready() const;
|
2023-04-12 10:39:05 +02:00
|
|
|
bool is_updating() const;
|
2022-05-18 09:17:55 +02:00
|
|
|
|
|
|
|
void set_threaded(bool p_threaded);
|
|
|
|
bool is_threaded() const;
|
|
|
|
|
|
|
|
void set_progress_bar_delay(int p_delay_ms);
|
|
|
|
int get_progress_bar_delay() const;
|
|
|
|
|
2022-04-12 08:58:04 +02:00
|
|
|
// Context menu.
|
|
|
|
PopupMenu *get_menu() const;
|
|
|
|
bool is_menu_visible() const;
|
2023-02-03 10:07:36 +01:00
|
|
|
void menu_option(int p_option);
|
2022-04-12 08:58:04 +02:00
|
|
|
|
2021-10-23 08:25:39 +02:00
|
|
|
void parse_bbcode(const String &p_bbcode);
|
|
|
|
void append_text(const String &p_bbcode);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-04-21 21:01:58 +02:00
|
|
|
void set_use_bbcode(bool p_enable);
|
|
|
|
bool is_using_bbcode() const;
|
|
|
|
|
2020-05-29 16:25:12 +02:00
|
|
|
void set_text(const String &p_bbcode);
|
|
|
|
String get_text() const;
|
2017-07-03 21:59:58 +02:00
|
|
|
|
2020-10-02 14:02:02 +02: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;
|
|
|
|
|
2022-06-15 10:01:45 +02:00
|
|
|
void set_autowrap_mode(TextServer::AutowrapMode p_mode);
|
|
|
|
TextServer::AutowrapMode get_autowrap_mode() const;
|
2022-02-03 14:56:44 +01:00
|
|
|
|
2022-04-19 12:27:18 +02:00
|
|
|
void set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser);
|
|
|
|
TextServer::StructuredTextParser get_structured_text_bidi_override() const;
|
2020-10-02 14:02:02 +02:00
|
|
|
|
|
|
|
void set_structured_text_bidi_override_options(Array p_args);
|
|
|
|
Array get_structured_text_bidi_override_options() const;
|
|
|
|
|
2015-06-02 00:42:34 +02:00
|
|
|
void set_visible_characters(int p_visible);
|
|
|
|
int get_visible_characters() const;
|
2022-02-11 22:02:59 +01:00
|
|
|
int get_character_line(int p_char);
|
|
|
|
int get_character_paragraph(int p_char);
|
2015-06-02 00:42:34 +02:00
|
|
|
int get_total_character_count() const;
|
2021-12-05 13:28:32 +01:00
|
|
|
int get_total_glyph_count() const;
|
2015-06-02 00:42:34 +02:00
|
|
|
|
2022-08-20 20:06:13 +02:00
|
|
|
void set_visible_ratio(float p_ratio);
|
|
|
|
float get_visible_ratio() const;
|
2017-07-03 21:59:58 +02:00
|
|
|
|
2022-06-15 10:01:45 +02:00
|
|
|
TextServer::VisibleCharactersBehavior get_visible_characters_behavior() const;
|
|
|
|
void set_visible_characters_behavior(TextServer::VisibleCharactersBehavior p_behavior);
|
2021-12-05 13:28:32 +01:00
|
|
|
|
2021-08-24 22:02:24 +02:00
|
|
|
void set_effects(Array p_effects);
|
|
|
|
Array get_effects();
|
2018-11-10 03:44:58 +01:00
|
|
|
|
|
|
|
void install_effect(const Variant effect);
|
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual Size2 get_minimum_size() const override;
|
2018-07-20 23:14:33 +02:00
|
|
|
|
2022-03-04 09:18:44 +01:00
|
|
|
RichTextLabel(const String &p_text = String());
|
2014-02-10 02:10:30 +01:00
|
|
|
~RichTextLabel();
|
|
|
|
};
|
|
|
|
|
|
|
|
VARIANT_ENUM_CAST(RichTextLabel::ListType);
|
2023-02-03 10:07:36 +01:00
|
|
|
VARIANT_ENUM_CAST(RichTextLabel::MenuItems);
|
2024-02-29 20:21:13 +01:00
|
|
|
VARIANT_ENUM_CAST(RichTextLabel::MetaUnderline);
|
2022-12-07 21:40:03 +01:00
|
|
|
VARIANT_BITFIELD_CAST(RichTextLabel::ImageUpdateMask);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
#endif // RICH_TEXT_LABEL_H
|