Debian Codegraph @

scene/gui/link_button.h

raw symbols SCIP
1 /**************************************************************************/
2 /* link_button.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
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);