| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/gui/base_button.h" |
| 34 |
#include "scene/resources/text_line.h" |
| 35 |
|
| 36 |
class LinkButton : public BaseButton { |
| 37 |
GDCLASS(LinkButton, BaseButton); |
| 38 |
|
| 39 |
public: |
| 40 |
enum UnderlineMode { |
| 41 |
UNDERLINE_MODE_ALWAYS, |
| 42 |
UNDERLINE_MODE_ON_HOVER, |
| 43 |
UNDERLINE_MODE_NEVER |
| 44 |
}; |
| 45 |
|
| 46 |
private: |
| 47 |
String text; |
| 48 |
String xl_text; |
| 49 |
Ref<TextLine> text_buf; |
| 50 |
UnderlineMode underline_mode = UNDERLINE_MODE_ALWAYS; |
| 51 |
String uri; |
| 52 |
|
| 53 |
String language; |
| 54 |
TextDirection text_direction = TEXT_DIRECTION_AUTO; |
| 55 |
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT; |
| 56 |
Array st_args; |
| 57 |
TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_NO_TRIMMING; |
| 58 |
String el_char = U"…"; |
| 59 |
|
| 60 |
struct ThemeCache { |
| 61 |
Ref<StyleBox> focus; |
| 62 |
|
| 63 |
Color font_color; |
| 64 |
Color font_focus_color; |
| 65 |
Color font_pressed_color; |
| 66 |
Color font_hover_color; |
| 67 |
Color font_hover_pressed_color; |
| 68 |
Color font_disabled_color; |
| 69 |
|
| 70 |
Ref<Font> font; |
| 71 |
int font_size = 0; |
| 72 |
int outline_size = 0; |
| 73 |
Color font_outline_color; |
| 74 |
|
| 75 |
int underline_spacing = 0; |
| 76 |
} theme_cache; |
| 77 |
|
| 78 |
void _shape(); |
| 79 |
|
| 80 |
protected: |
| 81 |
virtual void pressed() override; |
| 82 |
virtual Size2 get_minimum_size() const override; |
| 83 |
|
| 84 |
void _notification(int p_what); |
| 85 |
static void _bind_methods(); |
| 86 |
|
| 87 |
public: |
| 88 |
void set_text(const String &p_text); |
| 89 |
String get_text() const; |
| 90 |
void set_uri(const String &p_uri); |
| 91 |
String get_uri() const; |
| 92 |
|
| 93 |
void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior); |
| 94 |
TextServer::OverrunBehavior get_text_overrun_behavior() const; |
| 95 |
|
| 96 |
void set_ellipsis_char(const String &p_char); |
| 97 |
String get_ellipsis_char() const; |
| 98 |
|
| 99 |
void set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser); |
| 100 |
TextServer::StructuredTextParser get_structured_text_bidi_override() const; |
| 101 |
|
| 102 |
void set_structured_text_bidi_override_options(const Array &p_args); |
| 103 |
Array get_structured_text_bidi_override_options() const; |
| 104 |
|
| 105 |
void set_text_direction(TextDirection p_text_direction); |
| 106 |
TextDirection get_text_direction() const; |
| 107 |
|
| 108 |
void set_language(const String &p_language); |
| 109 |
String get_language() const; |
| 110 |
|
| 111 |
void set_underline_mode(UnderlineMode p_underline_mode); |
| 112 |
UnderlineMode get_underline_mode() const; |
| 113 |
|
| 114 |
Ref<Font> get_button_font() const; |
| 115 |
int get_button_font_size() const; |
| 116 |
|
| 117 |
virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override; |
| 118 |
|
| 119 |
LinkButton(const String &p_text = String()); |
| 120 |
}; |
| 121 |
|
| 122 |
VARIANT_ENUM_CAST(LinkButton::UnderlineMode); |