summaryrefslogtreecommitdiff
path: root/scene/gui/rich_text_label.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/rich_text_label.h')
-rw-r--r--scene/gui/rich_text_label.h127
1 files changed, 63 insertions, 64 deletions
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 3bdd2cd7e3..a5f23d0ba9 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -29,14 +29,13 @@
#ifndef RICH_TEXT_LABEL_H
#define RICH_TEXT_LABEL_H
-
#include "scene/gui/scroll_bar.h"
class RichTextLabel : public Control {
- GDCLASS( RichTextLabel, Control );
-public:
+ GDCLASS(RichTextLabel, Control);
+public:
enum Align {
ALIGN_LEFT,
@@ -69,10 +68,9 @@ public:
};
protected:
-
static void _bind_methods();
-private:
+private:
struct Item;
struct Line {
@@ -86,27 +84,37 @@ private:
int char_count;
int minimum_width;
- Line() { from=NULL; char_count=0; }
+ Line() {
+ from = NULL;
+ char_count = 0;
+ }
};
-
-
struct Item {
int index;
Item *parent;
ItemType type;
- List<Item*> subitems;
- List<Item*>::Element *E;
+ List<Item *> subitems;
+ List<Item *>::Element *E;
int line;
- void _clear_children() { while (subitems.size()) { memdelete(subitems.front()->get()); subitems.pop_front(); } }
-
- Item() { parent=NULL; E=NULL; line=0;}
- virtual ~Item() { _clear_children(); }
+ void _clear_children() {
+ while (subitems.size()) {
+ memdelete(subitems.front()->get());
+ subitems.pop_front();
+ }
+ }
+
+ Item() {
+ parent = NULL;
+ E = NULL;
+ line = 0;
+ }
+ virtual ~Item() { _clear_children(); }
};
- struct ItemFrame : public Item{
+ struct ItemFrame : public Item {
int parent_line;
bool cell;
@@ -114,71 +122,74 @@ private:
int first_invalid_line;
ItemFrame *parent_frame;
- ItemFrame() { type=ITEM_FRAME; parent_frame=NULL; cell=false; parent_line=0; }
+ ItemFrame() {
+ type = ITEM_FRAME;
+ parent_frame = NULL;
+ cell = false;
+ parent_line = 0;
+ }
};
-
struct ItemText : public Item {
String text;
- ItemText() { type=ITEM_TEXT; }
+ ItemText() { type = ITEM_TEXT; }
};
struct ItemImage : public Item {
Ref<Texture> image;
- ItemImage() { type=ITEM_IMAGE; }
+ ItemImage() { type = ITEM_IMAGE; }
};
struct ItemFont : public Item {
Ref<Font> font;
- ItemFont() { type=ITEM_FONT; }
+ ItemFont() { type = ITEM_FONT; }
};
struct ItemColor : public Item {
Color color;
- ItemColor() { type=ITEM_COLOR; }
+ ItemColor() { type = ITEM_COLOR; }
};
struct ItemUnderline : public Item {
- ItemUnderline() { type=ITEM_UNDERLINE; }
+ ItemUnderline() { type = ITEM_UNDERLINE; }
};
struct ItemMeta : public Item {
Variant meta;
- ItemMeta() { type=ITEM_META; }
+ ItemMeta() { type = ITEM_META; }
};
struct ItemAlign : public Item {
Align align;
- ItemAlign() { type=ITEM_ALIGN; }
+ ItemAlign() { type = ITEM_ALIGN; }
};
struct ItemIndent : public Item {
int level;
- ItemIndent() { type=ITEM_INDENT; }
+ ItemIndent() { type = ITEM_INDENT; }
};
struct ItemList : public Item {
ListType list_type;
- ItemList() { type=ITEM_LIST; }
+ ItemList() { type = ITEM_LIST; }
};
struct ItemNewline : public Item {
- int line; // FIXME: Overriding base's line ?
- ItemNewline() { type=ITEM_NEWLINE; }
+ int line; // FIXME: Overriding base's line ?
+ ItemNewline() { type = ITEM_NEWLINE; }
};
-
- struct ItemTable : public Item{
+ struct ItemTable : public Item {
struct Column {
bool expand;
@@ -189,7 +200,7 @@ private:
Vector<Column> columns;
int total_width;
- ItemTable() { type=ITEM_TABLE; }
+ ItemTable() { type = ITEM_TABLE; }
};
ItemFrame *main;
@@ -198,7 +209,6 @@ private:
VScrollBar *vscroll;
-
bool scroll_visible;
bool scroll_follow;
bool scroll_following;
@@ -207,7 +217,6 @@ private:
bool updating_scroll;
int current_idx;
-
int tab_size;
bool underline_meta;
@@ -216,12 +225,9 @@ private:
void _invalidate_current_line(ItemFrame *p_frame);
void _validate_line_caches(ItemFrame *p_frame);
- void _add_item(Item *p_item, bool p_enter=false,bool p_ensure_newline=false);
+ void _add_item(Item *p_item, bool p_enter = false, bool p_ensure_newline = false);
void _remove_item(Item *p_item, const int p_line, const int p_subitem_line);
-
-
-
struct ProcessState {
int line_width;
@@ -250,26 +256,23 @@ private:
Selection selection;
-
int visible_characters;
-
- void _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 Point2i& p_click_pos=Point2i(),Item **r_click_item=NULL,int *r_click_char=NULL,bool *r_outside=NULL,int p_char_count=0);
- void _find_click(ItemFrame *p_frame, const Point2i& p_click,Item **r_click_item=NULL,int *r_click_char=NULL,bool *r_outside=NULL);
-
+ void _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 Point2i &p_click_pos = Point2i(), Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL, int p_char_count = 0);
+ void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL);
Ref<Font> _find_font(Item *p_item);
- int _find_margin(Item *p_item,const Ref<Font>& p_base_font);
+ int _find_margin(Item *p_item, const Ref<Font> &p_base_font);
Align _find_align(Item *p_item);
- Color _find_color(Item *p_item,const Color& p_default_color);
+ Color _find_color(Item *p_item, const Color &p_default_color);
bool _find_underline(Item *p_item);
- bool _find_meta(Item *p_item,Variant *r_meta);
+ bool _find_meta(Item *p_item, Variant *r_meta);
void _update_scroll();
void _scroll_changed(double);
void _gui_input(InputEvent p_event);
- Item *_get_next_item(Item* p_item, bool p_free=false);
+ Item *_get_next_item(Item *p_item, bool p_free = false);
bool use_bbcode;
String bbcode;
@@ -280,21 +283,20 @@ protected:
void _notification(int p_what);
public:
-
String get_text();
- void add_text(const String& p_text);
- void add_image(const Ref<Texture>& p_image);
+ void add_text(const String &p_text);
+ void add_image(const Ref<Texture> &p_image);
void add_newline();
bool remove_line(const int p_line);
- void push_font(const Ref<Font>& p_font);
- void push_color(const Color& p_color);
+ void push_font(const Ref<Font> &p_font);
+ void push_color(const Color &p_color);
void push_underline();
void push_align(Align p_align);
void push_indent(int p_level);
void push_list(ListType p_list);
- void push_meta(const Variant& p_data);
+ void push_meta(const Variant &p_data);
void push_table(int p_columns);
- void set_table_column_expand(int p_column, bool p_expand, int p_ratio=1);
+ void set_table_column_expand(int p_column, bool p_expand, int p_ratio = 1);
int get_current_table_column() const;
void push_cell();
void pop();
@@ -315,29 +317,26 @@ public:
void set_tab_size(int p_spaces);
int get_tab_size() const;
-
-
- bool search(const String& p_string,bool p_from_selection=false);
+ bool search(const String &p_string, bool p_from_selection = false);
void scroll_to_line(int p_line);
int get_line_count() const;
VScrollBar *get_v_scroll() { return vscroll; }
- virtual CursorShape get_cursor_shape(const Point2& p_pos) const;
+ virtual CursorShape get_cursor_shape(const Point2 &p_pos) const;
void set_selection_enabled(bool p_enabled);
bool is_selection_enabled() const;
void selection_copy();
-
- Error parse_bbcode(const String& p_bbcode);
- Error append_bbcode(const String& p_bbcode);
+ Error parse_bbcode(const String &p_bbcode);
+ Error append_bbcode(const String &p_bbcode);
void set_use_bbcode(bool p_enable);
bool is_using_bbcode() const;
- void set_bbcode(const String& p_bbcode);
+ void set_bbcode(const String &p_bbcode);
String get_bbcode() const;
void set_visible_characters(int p_visible);
@@ -348,8 +347,8 @@ public:
~RichTextLabel();
};
-VARIANT_ENUM_CAST( RichTextLabel::Align );
-VARIANT_ENUM_CAST( RichTextLabel::ListType );
-VARIANT_ENUM_CAST( RichTextLabel::ItemType );
+VARIANT_ENUM_CAST(RichTextLabel::Align);
+VARIANT_ENUM_CAST(RichTextLabel::ListType);
+VARIANT_ENUM_CAST(RichTextLabel::ItemType);
#endif // RICH_TEXT_LABEL_H