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. --- editor/pane_drag.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'editor/pane_drag.cpp') diff --git a/editor/pane_drag.cpp b/editor/pane_drag.cpp index ce90fa94dc..0f21a2af88 100644 --- a/editor/pane_drag.cpp +++ b/editor/pane_drag.cpp @@ -31,20 +31,15 @@ #include "pane_drag.h" void PaneDrag::_gui_input(const Ref &p_input) { - Ref mm = p_input; if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) { - emit_signal("dragged", Point2(mm->get_relative().x, mm->get_relative().y)); } } void PaneDrag::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_DRAW: { - Ref icon = mouse_over ? get_theme_icon("PaneDragHover", "EditorIcons") : get_theme_icon("PaneDrag", "EditorIcons"); if (!icon.is_null()) icon->draw(get_canvas_item(), Point2(0, 0)); @@ -61,7 +56,6 @@ void PaneDrag::_notification(int p_what) { } } Size2 PaneDrag::get_minimum_size() const { - Ref icon = get_theme_icon("PaneDrag", "EditorIcons"); if (!icon.is_null()) return icon->get_size(); @@ -69,12 +63,10 @@ Size2 PaneDrag::get_minimum_size() const { } void PaneDrag::_bind_methods() { - ClassDB::bind_method("_gui_input", &PaneDrag::_gui_input); ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::VECTOR2, "amount"))); } PaneDrag::PaneDrag() { - mouse_over = false; } -- cgit v1.2.3 From 07bc4e2f96f8f47991339654ff4ab16acc19d44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 14:29:06 +0200 Subject: Style: Enforce separation line between function definitions I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027. --- editor/pane_drag.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'editor/pane_drag.cpp') diff --git a/editor/pane_drag.cpp b/editor/pane_drag.cpp index 0f21a2af88..8cadc3925e 100644 --- a/editor/pane_drag.cpp +++ b/editor/pane_drag.cpp @@ -55,6 +55,7 @@ void PaneDrag::_notification(int p_what) { break; } } + Size2 PaneDrag::get_minimum_size() const { Ref icon = get_theme_icon("PaneDrag", "EditorIcons"); if (!icon.is_null()) -- 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 --- editor/pane_drag.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'editor/pane_drag.cpp') diff --git a/editor/pane_drag.cpp b/editor/pane_drag.cpp index 8cadc3925e..09f2b90b90 100644 --- a/editor/pane_drag.cpp +++ b/editor/pane_drag.cpp @@ -41,8 +41,9 @@ void PaneDrag::_notification(int p_what) { switch (p_what) { case NOTIFICATION_DRAW: { Ref icon = mouse_over ? get_theme_icon("PaneDragHover", "EditorIcons") : get_theme_icon("PaneDrag", "EditorIcons"); - if (!icon.is_null()) + if (!icon.is_null()) { icon->draw(get_canvas_item(), Point2(0, 0)); + } } break; case NOTIFICATION_MOUSE_ENTER: @@ -58,8 +59,9 @@ void PaneDrag::_notification(int p_what) { Size2 PaneDrag::get_minimum_size() const { Ref icon = get_theme_icon("PaneDrag", "EditorIcons"); - if (!icon.is_null()) + if (!icon.is_null()) { return icon->get_size(); + } return Size2(); } -- cgit v1.2.3