From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- scene/gui/link_button.cpp | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'scene/gui/link_button.cpp') diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp index 098e8297ad..d772b257fc 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,42 +41,33 @@ 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_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_theme_color("font_color"); do_underline = underline_mode == UNDERLINE_MODE_ALWAYS; } break; case DRAW_HOVER_PRESSED: case DRAW_PRESSED: { - if (has_theme_color("font_color_pressed")) color = get_theme_color("font_color_pressed"); else @@ -87,13 +77,11 @@ void LinkButton::_notification(int p_what) { } break; case DRAW_HOVER: { - color = get_theme_color("font_color_hover"); do_underline = underline_mode != UNDERLINE_MODE_NEVER; } break; case DRAW_DISABLED: { - color = get_theme_color("font_color_disabled"); do_underline = underline_mode == UNDERLINE_MODE_ALWAYS; @@ -101,7 +89,6 @@ void LinkButton::_notification(int p_what) { } if (has_focus()) { - Ref style = get_theme_stylebox("focus"); style->draw(ci, Rect2(Point2(), size)); } @@ -123,7 +110,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); -- cgit v1.2.3 From 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 16:41:43 +0200 Subject: Style: Enforce braces around if blocks and loops Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html --- scene/gui/link_button.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scene/gui/link_button.cpp') diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp index d772b257fc..f8c8bd4caf 100644 --- a/scene/gui/link_button.cpp +++ b/scene/gui/link_button.cpp @@ -68,10 +68,11 @@ void LinkButton::_notification(int p_what) { } break; case DRAW_HOVER_PRESSED: case DRAW_PRESSED: { - if (has_theme_color("font_color_pressed")) + if (has_theme_color("font_color_pressed")) { color = get_theme_color("font_color_pressed"); - else + } else { color = get_theme_color("font_color"); + } do_underline = underline_mode != UNDERLINE_MODE_NEVER; -- cgit v1.2.3