summaryrefslogtreecommitdiff
path: root/scene/gui/link_button.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/link_button.cpp')
-rw-r--r--scene/gui/link_button.cpp39
1 files changed, 13 insertions, 26 deletions
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index 4b8054bac6..f8c8bd4caf 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -31,7 +31,6 @@
#include "link_button.h"
void LinkButton::set_text(const String &p_text) {
-
text = p_text;
update();
minimum_size_changed();
@@ -42,80 +41,69 @@ String LinkButton::get_text() const {
}
void LinkButton::set_underline_mode(UnderlineMode p_underline_mode) {
-
underline_mode = p_underline_mode;
update();
}
LinkButton::UnderlineMode LinkButton::get_underline_mode() const {
-
return underline_mode;
}
Size2 LinkButton::get_minimum_size() const {
-
- return get_font("font")->get_string_size(text);
+ return get_theme_font("font")->get_string_size(text);
}
void LinkButton::_notification(int p_what) {
-
switch (p_what) {
-
case NOTIFICATION_DRAW: {
-
RID ci = get_canvas_item();
Size2 size = get_size();
Color color;
bool do_underline = false;
switch (get_draw_mode()) {
-
case DRAW_NORMAL: {
-
- color = get_color("font_color");
+ color = get_theme_color("font_color");
do_underline = underline_mode == UNDERLINE_MODE_ALWAYS;
} break;
case DRAW_HOVER_PRESSED:
case DRAW_PRESSED: {
-
- if (has_color("font_color_pressed"))
- color = get_color("font_color_pressed");
- else
- color = get_color("font_color");
+ if (has_theme_color("font_color_pressed")) {
+ color = get_theme_color("font_color_pressed");
+ } else {
+ color = get_theme_color("font_color");
+ }
do_underline = underline_mode != UNDERLINE_MODE_NEVER;
} break;
case DRAW_HOVER: {
-
- color = get_color("font_color_hover");
+ color = get_theme_color("font_color_hover");
do_underline = underline_mode != UNDERLINE_MODE_NEVER;
} break;
case DRAW_DISABLED: {
-
- color = get_color("font_color_disabled");
+ color = get_theme_color("font_color_disabled");
do_underline = underline_mode == UNDERLINE_MODE_ALWAYS;
} break;
}
if (has_focus()) {
-
- Ref<StyleBox> style = get_stylebox("focus");
+ Ref<StyleBox> style = get_theme_stylebox("focus");
style->draw(ci, Rect2(Point2(), size));
}
- Ref<Font> font = get_font("font");
+ Ref<Font> font = get_theme_font("font");
draw_string(font, Vector2(0, font->get_ascent()), text, color);
if (do_underline) {
- int underline_spacing = get_constant("underline_spacing");
+ int underline_spacing = get_theme_constant("underline_spacing") + font->get_underline_position();
int width = font->get_string_size(text).width;
int y = font->get_ascent() + underline_spacing;
- draw_line(Vector2(0, y), Vector2(width, y), color);
+ draw_line(Vector2(0, y), Vector2(width, y), color, font->get_underline_thickness());
}
} break;
@@ -123,7 +111,6 @@ void LinkButton::_notification(int p_what) {
}
void LinkButton::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_text", "text"), &LinkButton::set_text);
ClassDB::bind_method(D_METHOD("get_text"), &LinkButton::get_text);