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
|
|
|
/*************************************************************************/
|
2019-01-01 11:53:14 +00:00
|
|
|
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2019 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"
|
|
|
|
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
ITEM_COLOR,
|
|
|
|
ITEM_UNDERLINE,
|
2018-09-22 21:41:13 +00:00
|
|
|
ITEM_STRIKETHROUGH,
|
2014-02-10 01:10:30 +00:00
|
|
|
ITEM_ALIGN,
|
|
|
|
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,
|
|
|
|
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-19 09:16:42 +00:00
|
|
|
class Item;
|
2015-12-26 13:25:17 +00:00
|
|
|
|
|
|
|
struct Line {
|
|
|
|
|
|
|
|
Item *from;
|
|
|
|
Vector<int> offset_caches;
|
|
|
|
Vector<int> height_caches;
|
2018-01-14 17:12:09 +00:00
|
|
|
Vector<int> ascent_caches;
|
|
|
|
Vector<int> descent_caches;
|
2015-12-26 13:25:17 +00:00
|
|
|
Vector<int> space_caches;
|
|
|
|
int height_cache;
|
|
|
|
int height_accum_cache;
|
|
|
|
int char_count;
|
|
|
|
int minimum_width;
|
2018-03-18 10:28:17 +00:00
|
|
|
int maximum_width;
|
2015-12-26 13:25:17 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Line() {
|
|
|
|
from = NULL;
|
|
|
|
char_count = 0;
|
|
|
|
}
|
2015-12-26 13:25:17 +00:00
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class Item : public Object {
|
|
|
|
GDCLASS(Item, Object);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
2014-02-10 01:10:30 +00:00
|
|
|
int index;
|
|
|
|
Item *parent;
|
|
|
|
ItemType type;
|
2017-03-05 15:44:50 +00:00
|
|
|
List<Item *> subitems;
|
|
|
|
List<Item *>::Element *E;
|
2015-12-26 13:25:17 +00:00
|
|
|
int line;
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item() {
|
|
|
|
parent = NULL;
|
|
|
|
E = NULL;
|
|
|
|
line = 0;
|
|
|
|
}
|
|
|
|
virtual ~Item() { _clear_children(); }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemFrame : public Item {
|
|
|
|
GDCLASS(ItemFrame, Item);
|
2015-12-26 13:25:17 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
2015-12-26 13:25:17 +00:00
|
|
|
int parent_line;
|
|
|
|
bool cell;
|
|
|
|
Vector<Line> lines;
|
|
|
|
int first_invalid_line;
|
|
|
|
ItemFrame *parent_frame;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemFrame() {
|
|
|
|
type = ITEM_FRAME;
|
|
|
|
parent_frame = NULL;
|
|
|
|
cell = false;
|
|
|
|
parent_line = 0;
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemText : public Item {
|
|
|
|
GDCLASS(ItemText, Item);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
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
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemImage : public Item {
|
|
|
|
GDCLASS(ItemImage, Item);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
2014-02-10 01:10:30 +00:00
|
|
|
Ref<Texture> image;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemImage() { type = ITEM_IMAGE; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemFont : public Item {
|
|
|
|
GDCLASS(ItemFont, Item);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
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
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemColor : public Item {
|
|
|
|
GDCLASS(ItemColor, Item);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
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
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemUnderline : public Item {
|
|
|
|
GDCLASS(ItemUnderline, Item);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemUnderline() { type = ITEM_UNDERLINE; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemStrikethrough : public Item {
|
|
|
|
GDCLASS(ItemStrikethrough, Item);
|
2018-09-22 21:41:13 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
2018-09-22 21:41:13 +00:00
|
|
|
ItemStrikethrough() { type = ITEM_STRIKETHROUGH; }
|
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemMeta : public Item {
|
|
|
|
GDCLASS(ItemMeta, Item);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
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
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemAlign : public Item {
|
|
|
|
GDCLASS(ItemAlign, Item);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
2014-02-10 01:10:30 +00:00
|
|
|
Align align;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemAlign() { type = ITEM_ALIGN; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemIndent : public Item {
|
|
|
|
GDCLASS(ItemIndent, Item);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
2014-02-10 01:10:30 +00:00
|
|
|
int level;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemIndent() { type = ITEM_INDENT; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemList : public Item {
|
|
|
|
GDCLASS(ItemList, Item);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
2014-02-10 01:10:30 +00:00
|
|
|
ListType list_type;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemList() { type = ITEM_LIST; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemNewline : public Item {
|
|
|
|
GDCLASS(ItemNewline, Item);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemNewline() { type = ITEM_NEWLINE; }
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemTable : public Item {
|
|
|
|
GDCLASS(ItemTable, Item);
|
2015-12-26 13:25:17 +00:00
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
public:
|
2015-12-26 13:25:17 +00:00
|
|
|
struct Column {
|
|
|
|
bool expand;
|
|
|
|
int expand_ratio;
|
|
|
|
int min_width;
|
2018-03-18 10:28:17 +00:00
|
|
|
int max_width;
|
2015-12-26 13:25:17 +00:00
|
|
|
int width;
|
|
|
|
};
|
|
|
|
|
|
|
|
Vector<Column> columns;
|
|
|
|
int total_width;
|
2017-03-05 15:44:50 +00:00
|
|
|
ItemTable() { type = ITEM_TABLE; }
|
2015-12-26 13:25:17 +00:00
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemFade : public Item {
|
|
|
|
GDCLASS(ItemFade, Item);
|
|
|
|
|
|
|
|
public:
|
2018-11-10 02:44:58 +00:00
|
|
|
int starting_index;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
ItemFade() { type = ITEM_FADE; }
|
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemFX : public Item {
|
|
|
|
GDCLASS(ItemFX, Item);
|
|
|
|
|
|
|
|
public:
|
2018-11-10 02:44:58 +00:00
|
|
|
float elapsed_time;
|
|
|
|
|
|
|
|
ItemFX() {
|
|
|
|
elapsed_time = 0.0f;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemShake : public ItemFX {
|
|
|
|
GDCLASS(ItemShake, ItemFX);
|
|
|
|
|
|
|
|
public:
|
2018-11-10 02:44:58 +00:00
|
|
|
int strength;
|
|
|
|
float rate;
|
|
|
|
uint64_t _current_rng;
|
|
|
|
uint64_t _previous_rng;
|
|
|
|
|
|
|
|
ItemShake() {
|
|
|
|
strength = 0;
|
|
|
|
rate = 0.0f;
|
|
|
|
_current_rng = 0;
|
|
|
|
type = ITEM_SHAKE;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-19 09:16:42 +00:00
|
|
|
class ItemWave : public ItemFX {
|
|
|
|
GDCLASS(ItemWave, ItemFX);
|
|
|
|
|
|
|
|
public:
|
2018-11-10 02:44:58 +00:00
|
|
|
float frequency;
|
|
|
|
float amplitude;
|
|
|
|
|
|
|
|
ItemWave() {
|
|
|
|
frequency = 1.0f;
|
|
|
|
amplitude = 1.0f;
|
|
|
|
type = ITEM_WAVE;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemTornado : public ItemFX {
|
|
|
|
GDCLASS(ItemTornado, ItemFX);
|
|
|
|
|
|
|
|
public:
|
2018-11-10 02:44:58 +00:00
|
|
|
float radius;
|
|
|
|
float frequency;
|
|
|
|
|
|
|
|
ItemTornado() {
|
|
|
|
radius = 1.0f;
|
|
|
|
frequency = 1.0f;
|
|
|
|
type = ITEM_TORNADO;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemRainbow : public ItemFX {
|
|
|
|
GDCLASS(ItemRainbow, ItemFX);
|
|
|
|
|
|
|
|
public:
|
2018-11-10 02:44:58 +00:00
|
|
|
float saturation;
|
|
|
|
float value;
|
|
|
|
float frequency;
|
|
|
|
|
|
|
|
ItemRainbow() {
|
|
|
|
saturation = 0.8f;
|
|
|
|
value = 0.8f;
|
|
|
|
frequency = 1.0f;
|
|
|
|
type = ITEM_RAINBOW;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-19 09:16:42 +00:00
|
|
|
class ItemCustomFX : public ItemFX {
|
|
|
|
GDCLASS(ItemCustomFX, ItemFX);
|
|
|
|
|
|
|
|
public:
|
2018-11-10 02:44:58 +00:00
|
|
|
String identifier;
|
|
|
|
Dictionary environment;
|
|
|
|
|
|
|
|
ItemCustomFX() {
|
|
|
|
identifier = "";
|
|
|
|
environment = Dictionary();
|
|
|
|
type = ITEM_CUSTOMFX;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~ItemCustomFX() {
|
|
|
|
_clear_children();
|
|
|
|
environment.clear();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-12-26 13:25:17 +00:00
|
|
|
ItemFrame *main;
|
2014-02-10 01:10:30 +00:00
|
|
|
Item *current;
|
2015-12-26 13:25:17 +00:00
|
|
|
ItemFrame *current_frame;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
VScrollBar *vscroll;
|
|
|
|
|
|
|
|
bool scroll_visible;
|
|
|
|
bool scroll_follow;
|
|
|
|
bool scroll_following;
|
|
|
|
bool scroll_active;
|
|
|
|
int scroll_w;
|
2018-10-09 00:04:59 +00:00
|
|
|
bool scroll_updated;
|
2014-02-10 01:10:30 +00:00
|
|
|
bool updating_scroll;
|
|
|
|
int current_idx;
|
2016-10-17 19:03:47 +00:00
|
|
|
int visible_line_count;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
int tab_size;
|
|
|
|
bool underline_meta;
|
2017-09-27 17:24:05 +00:00
|
|
|
bool override_selected_font_color;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Align default_align;
|
|
|
|
|
2017-11-17 05:49:39 +00:00
|
|
|
ItemMeta *meta_hovering;
|
|
|
|
Variant current_meta;
|
|
|
|
|
2018-11-10 02:44:58 +00:00
|
|
|
Vector<Ref<RichTextEffect> > custom_effects;
|
|
|
|
|
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
|
|
|
|
|
|
|
struct ProcessState {
|
|
|
|
int line_width;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ProcessMode {
|
|
|
|
|
|
|
|
PROCESS_CACHE,
|
|
|
|
PROCESS_DRAW,
|
|
|
|
PROCESS_POINTER
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Selection {
|
|
|
|
|
|
|
|
Item *click;
|
|
|
|
int click_char;
|
|
|
|
|
|
|
|
Item *from;
|
|
|
|
int from_char;
|
|
|
|
Item *to;
|
|
|
|
int to_char;
|
|
|
|
|
2017-12-10 15:08:24 +00:00
|
|
|
bool active; // anything selected? i.e. from, to, etc. valid?
|
|
|
|
bool enabled; // allow selections?
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Selection selection;
|
|
|
|
|
2015-06-01 22:42:34 +00:00
|
|
|
int visible_characters;
|
2017-07-03 19:59:58 +00:00
|
|
|
float percent_visible;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2018-04-11 13:08:56 +00:00
|
|
|
int _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &shadow_ofs, const Point2i &p_click_pos = Point2i(), Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL, int p_char_count = 0);
|
2017-03-05 15:44:50 +00:00
|
|
|
void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Ref<Font> _find_font(Item *p_item);
|
2017-03-05 15:44:50 +00:00
|
|
|
int _find_margin(Item *p_item, const Ref<Font> &p_base_font);
|
2014-02-10 01:10:30 +00:00
|
|
|
Align _find_align(Item *p_item);
|
2017-03-05 15:44:50 +00:00
|
|
|
Color _find_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);
|
2019-02-21 22:23:05 +00:00
|
|
|
bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = NULL);
|
2019-06-20 10:42:25 +00:00
|
|
|
bool _find_layout_subitem(Item *from, Item *to);
|
2018-11-10 02:44:58 +00:00
|
|
|
bool _find_by_type(Item *p_item, ItemType p_type);
|
|
|
|
template <typename T>
|
|
|
|
T *_fetch_by_type(Item *p_item, ItemType p_type) {
|
|
|
|
Item *item = p_item;
|
|
|
|
T *result = NULL;
|
|
|
|
while (item) {
|
|
|
|
if (item->type == p_type) {
|
|
|
|
result = Object::cast_to<T>(item);
|
|
|
|
if (result)
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
item = item->parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
template <typename T>
|
|
|
|
void _fetch_item_stack(Item *p_item, Vector<T *> &r_stack) {
|
|
|
|
Item *item = p_item;
|
|
|
|
while (item) {
|
|
|
|
T *found = Object::cast_to<T>(item);
|
|
|
|
if (found) {
|
|
|
|
r_stack.push_back(found);
|
|
|
|
}
|
|
|
|
item = item->parent;
|
|
|
|
}
|
|
|
|
}
|
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);
|
2017-03-05 15:44:50 +00:00
|
|
|
Item *_get_next_item(Item *p_item, bool p_free = false);
|
2017-12-22 18:09:31 +00:00
|
|
|
Item *_get_prev_item(Item *p_item, bool p_free = false);
|
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
|
|
|
|
2015-04-21 19:01:58 +00:00
|
|
|
bool use_bbcode;
|
|
|
|
String bbcode;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-12-26 13:25:17 +00:00
|
|
|
void _update_all_lines();
|
2015-06-01 22:42:34 +00:00
|
|
|
|
2018-07-20 21:14:33 +00:00
|
|
|
int fixed_width;
|
|
|
|
|
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);
|
|
|
|
void add_image(const Ref<Texture> &p_image);
|
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);
|
2017-03-05 15:44:50 +00:00
|
|
|
void push_font(const Ref<Font> &p_font);
|
|
|
|
void push_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();
|
2014-02-10 01:10:30 +00:00
|
|
|
void push_align(Align p_align);
|
|
|
|
void push_indent(int p_level);
|
|
|
|
void push_list(ListType p_list);
|
2017-08-11 19:10:05 +00:00
|
|
|
void push_meta(const Variant &p_meta);
|
2015-12-26 13:25:17 +00:00
|
|
|
void push_table(int p_columns);
|
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);
|
|
|
|
void push_customfx(String p_identifier, 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);
|
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;
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
2018-04-11 13:53:13 +00:00
|
|
|
int get_content_height();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
VScrollBar *get_v_scroll() { return vscroll; }
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
virtual CursorShape get_cursor_shape(const Point2 &p_pos) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void set_selection_enabled(bool p_enabled);
|
|
|
|
bool is_selection_enabled() 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);
|
|
|
|
|
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);
|
|
|
|
virtual Size2 get_minimum_size() const;
|
|
|
|
|
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
|