1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

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.
This commit is contained in:
Rémi Verschelde
2020-05-14 13:23:58 +02:00
parent 710b34b702
commit 0be6d925dc
1552 changed files with 1 additions and 33876 deletions

View File

@@ -39,23 +39,19 @@
#include "scene/2d/skeleton_2d.h"
Node2D *Polygon2DEditor::_get_node() const {
return node;
}
void Polygon2DEditor::_set_node(Node *p_polygon) {
node = Object::cast_to<Polygon2D>(p_polygon);
_update_polygon_editing_state();
}
Vector2 Polygon2DEditor::_get_offset(int p_idx) const {
return node->get_offset();
}
int Polygon2DEditor::_get_polygon_count() const {
if (node->get_internal_vertex_count() > 0) {
return 0; //do not edit if internal vertices exist
} else {
@@ -64,17 +60,13 @@ int Polygon2DEditor::_get_polygon_count() const {
}
void Polygon2DEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
bone_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
} break;
case NOTIFICATION_READY: {
button_uv->set_icon(get_theme_icon("Uv", "EditorIcons"));
uv_button[UV_MODE_CREATE]->set_icon(get_theme_icon("Edit", "EditorIcons"));
@@ -97,7 +89,6 @@ void Polygon2DEditor::_notification(int p_what) {
uv_hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible()) {
uv_edit->hide();
}
@@ -106,7 +97,6 @@ void Polygon2DEditor::_notification(int p_what) {
}
void Polygon2DEditor::_sync_bones() {
Skeleton2D *skeleton = nullptr;
if (!node->has_node(node->get_skeleton())) {
error->set_text(TTR("The skeleton property of the Polygon2D does not point to a Skeleton2D node"));
@@ -161,7 +151,6 @@ void Polygon2DEditor::_sync_bones() {
}
void Polygon2DEditor::_update_bone_list() {
NodePath selected;
while (bone_scroll_vb->get_child_count()) {
CheckBox *cb = Object::cast_to<CheckBox>(bone_scroll_vb->get_child(0));
@@ -203,7 +192,6 @@ void Polygon2DEditor::_bone_paint_selected(int p_index) {
}
void Polygon2DEditor::_uv_edit_mode_select(int p_mode) {
if (p_mode == 0) { //uv
uv_button[UV_MODE_CREATE]->hide();
@@ -274,20 +262,15 @@ void Polygon2DEditor::_uv_edit_mode_select(int p_mode) {
}
void Polygon2DEditor::_uv_edit_popup_hide() {
EditorSettings::get_singleton()->set("interface/dialogs/uv_editor_bounds", Rect2(uv_edit->get_position(), uv_edit->get_size()));
_cancel_editing();
}
void Polygon2DEditor::_menu_option(int p_option) {
switch (p_option) {
case MODE_EDIT_UV: {
if (node->get_texture().is_null()) {
error->set_text(TTR("No texture in this polygon.\nSet a texture to be able to edit UV."));
error->popup_centered();
return;
@@ -311,7 +294,6 @@ void Polygon2DEditor::_menu_option(int p_option) {
_update_bone_list();
} break;
case UVEDIT_POLYGON_TO_UV: {
Vector<Vector2> points = node->get_polygon();
if (points.size() == 0)
break;
@@ -324,7 +306,6 @@ void Polygon2DEditor::_menu_option(int p_option) {
undo_redo->commit_action();
} break;
case UVEDIT_UV_TO_POLYGON: {
Vector<Vector2> points = node->get_polygon();
Vector<Vector2> uvs = node->get_uv();
if (uvs.size() == 0)
@@ -338,7 +319,6 @@ void Polygon2DEditor::_menu_option(int p_option) {
undo_redo->commit_action();
} break;
case UVEDIT_UV_CLEAR: {
Vector<Vector2> uvs = node->get_uv();
if (uvs.size() == 0)
break;
@@ -350,18 +330,15 @@ void Polygon2DEditor::_menu_option(int p_option) {
undo_redo->commit_action();
} break;
case UVEDIT_GRID_SETTINGS: {
grid_settings->popup_centered();
} break;
default: {
AbstractPolygon2DEditor::_menu_option(p_option);
} break;
}
}
void Polygon2DEditor::_cancel_editing() {
if (uv_create) {
uv_drag = false;
uv_create = false;
@@ -386,7 +363,6 @@ void Polygon2DEditor::_cancel_editing() {
}
void Polygon2DEditor::_update_polygon_editing_state() {
if (!_get_node())
return;
@@ -397,7 +373,6 @@ void Polygon2DEditor::_update_polygon_editing_state() {
}
void Polygon2DEditor::_commit_action() {
// Makes that undo/redoing actions made outside of the UV editor still affect its polygon.
undo_redo->add_do_method(uv_edit_draw, "update");
undo_redo->add_undo_method(uv_edit_draw, "update");
@@ -442,7 +417,6 @@ void Polygon2DEditor::_set_snap_step_y(float p_val) {
}
void Polygon2DEditor::_uv_mode(int p_mode) {
polygon_create.clear();
uv_drag = false;
uv_create = false;
@@ -454,7 +428,6 @@ void Polygon2DEditor::_uv_mode(int p_mode) {
}
void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
if (!_get_node())
return;
@@ -465,11 +438,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseButton> mb = p_input;
if (mb.is_valid()) {
if (mb->get_button_index() == BUTTON_LEFT) {
if (mb->is_pressed()) {
uv_drag_from = snap_point(Vector2(mb->get_position().x, mb->get_position().y));
uv_drag = true;
points_prev = node->get_uv();
@@ -482,9 +452,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
uv_move_current = uv_mode;
if (uv_move_current == UV_MODE_CREATE) {
if (!uv_create) {
points_prev.resize(0);
Vector2 tuv = mtx.affine_inverse().xform(snap_point(Vector2(mb->get_position().x, mb->get_position().y)));
points_prev.push_back(tuv);
@@ -506,7 +474,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
uv_edit_draw->update();
} else {
Vector2 tuv = mtx.affine_inverse().xform(snap_point(Vector2(mb->get_position().x, mb->get_position().y)));
if (points_prev.size() > 2 && tuv.distance_to(points_prev[0]) < 8) {
@@ -544,7 +511,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (uv_move_current == UV_MODE_CREATE_INTERNAL) {
uv_create_uv_prev = node->get_uv();
uv_create_poly_prev = node->get_polygon();
uv_create_colors_prev = node->get_vertex_colors();
@@ -582,7 +548,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (uv_move_current == UV_MODE_REMOVE_INTERNAL) {
uv_create_uv_prev = node->get_uv();
uv_create_poly_prev = node->get_polygon();
uv_create_colors_prev = node->get_vertex_colors();
@@ -596,7 +561,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
float closest_dist = 1e20;
for (int i = points_prev.size() - internal_vertices; i < points_prev.size(); i++) {
Vector2 tuv = mtx.xform(uv_create_poly_prev[i]);
float dist = tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y));
if (dist < 8 && dist < closest_dist) {
@@ -637,7 +601,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (uv_move_current == UV_MODE_EDIT_POINT) {
if (mb->get_shift() && mb->get_command())
uv_move_current = UV_MODE_SCALE;
else if (mb->get_shift())
@@ -647,10 +610,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (uv_move_current == UV_MODE_EDIT_POINT) {
point_drag_index = -1;
for (int i = 0; i < points_prev.size(); i++) {
Vector2 tuv = mtx.xform(points_prev[i]);
if (tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y)) < 8) {
uv_drag_from = tuv;
@@ -664,12 +625,10 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (uv_move_current == UV_MODE_ADD_POLYGON) {
int closest = -1;
float closest_dist = 1e20;
for (int i = 0; i < points_prev.size(); i++) {
Vector2 tuv = mtx.xform(points_prev[i]);
float dist = tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y));
if (dist < 8 && dist < closest_dist) {
@@ -740,7 +699,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (uv_move_current == UV_MODE_PAINT_WEIGHT || uv_move_current == UV_MODE_CLEAR_WEIGHT) {
int bone_selected = -1;
for (int i = 0; i < bone_scroll_vb->get_child_count(); i++) {
CheckBox *c = Object::cast_to<CheckBox>(bone_scroll_vb->get_child(i));
@@ -751,7 +709,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
if (bone_selected != -1 && node->get_bone_weights(bone_selected).size() == points_prev.size()) {
prev_weights = node->get_bone_weights(bone_selected);
bone_painting = true;
bone_painting_bone = bone_selected;
@@ -759,7 +716,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
} else if (uv_drag && !uv_create) {
if (uv_edit_mode[0]->is_pressed()) { // Edit UV.
undo_redo->create_action(TTR("Transform UV Map"));
undo_redo->add_do_method(node, "set_uv", node->get_uv());
@@ -778,7 +734,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
uv_drag = false;
} else if (bone_painting) {
undo_redo->create_action(TTR("Paint Bone Weights"));
undo_redo->add_do_method(node, "set_bone_weights", bone_painting_bone, node->get_bone_weights(bone_painting_bone));
undo_redo->add_undo_method(node, "set_bone_weights", bone_painting_bone, prev_weights);
@@ -789,7 +744,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
} else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) {
_cancel_editing();
if (bone_painting)
@@ -798,10 +752,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
uv_edit_draw->update();
} else if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed()) {
uv_zoom->set_value(uv_zoom->get_value() / (1 - (0.1 * mb->get_factor())));
} else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && mb->is_pressed()) {
uv_zoom->set_value(uv_zoom->get_value() * (1 - (0.1 * mb->get_factor())));
}
}
@@ -809,29 +761,23 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMouseMotion> mm = p_input;
if (mm.is_valid()) {
if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
Vector2 drag(mm->get_relative().x, mm->get_relative().y);
uv_hscroll->set_value(uv_hscroll->get_value() - drag.x);
uv_vscroll->set_value(uv_vscroll->get_value() - drag.y);
} else if (uv_drag) {
Vector2 uv_drag_to = mm->get_position();
uv_drag_to = snap_point(uv_drag_to); // FIXME: Only works correctly with 'UV_MODE_EDIT_POINT', it's imprecise with the rest.
Vector2 drag = mtx.affine_inverse().xform(uv_drag_to) - mtx.affine_inverse().xform(uv_drag_from);
switch (uv_move_current) {
case UV_MODE_CREATE: {
if (uv_create) {
uv_create_to = mtx.affine_inverse().xform(snap_point(Vector2(mm->get_position().x, mm->get_position().y)));
}
} break;
case UV_MODE_EDIT_POINT: {
Vector<Vector2> uv_new = points_prev;
uv_new.set(point_drag_index, uv_new[point_drag_index] + drag);
@@ -842,7 +788,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
} break;
case UV_MODE_MOVE: {
Vector<Vector2> uv_new = points_prev;
for (int i = 0; i < uv_new.size(); i++)
uv_new.set(i, uv_new[i] + drag);
@@ -854,7 +799,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
} break;
case UV_MODE_ROTATE: {
Vector2 center;
Vector<Vector2> uv_new = points_prev;
@@ -877,7 +821,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
} break;
case UV_MODE_SCALE: {
Vector2 center;
Vector<Vector2> uv_new = points_prev;
@@ -906,7 +849,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
} break;
case UV_MODE_PAINT_WEIGHT:
case UV_MODE_CLEAR_WEIGHT: {
bone_paint_pos = Vector2(mm->get_position().x, mm->get_position().y);
} break;
default: {
@@ -952,20 +894,17 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
Ref<InputEventMagnifyGesture> magnify_gesture = p_input;
if (magnify_gesture.is_valid()) {
uv_zoom->set_value(uv_zoom->get_value() * magnify_gesture->get_factor());
}
Ref<InputEventPanGesture> pan_gesture = p_input;
if (pan_gesture.is_valid()) {
uv_hscroll->set_value(uv_hscroll->get_value() + uv_hscroll->get_page() * pan_gesture->get_delta().x / 8);
uv_vscroll->set_value(uv_vscroll->get_value() + uv_vscroll->get_page() * pan_gesture->get_delta().y / 8);
}
}
void Polygon2DEditor::_uv_scroll_changed(float) {
if (updating_uv_scroll)
return;
@@ -976,7 +915,6 @@ void Polygon2DEditor::_uv_scroll_changed(float) {
}
void Polygon2DEditor::_uv_draw() {
if (!uv_edit->is_visible() || !_get_node())
return;
@@ -1073,7 +1011,6 @@ void Polygon2DEditor::_uv_draw() {
}
for (int i = 0; i < uvs.size(); i++) {
int next = uv_draw_max > 0 ? (i + 1) % uv_draw_max : 0;
if (i < uv_draw_max && uv_drag && uv_move_current == UV_MODE_EDIT_POINT && EDITOR_DEF("editors/poly_editor/show_previous_outline", true)) {
@@ -1092,7 +1029,6 @@ void Polygon2DEditor::_uv_draw() {
}
for (int i = 0; i < polygons.size(); i++) {
Vector<int> points = polygons[i];
Vector<Vector2> polypoints;
for (int j = 0; j < points.size(); j++) {
@@ -1114,7 +1050,6 @@ void Polygon2DEditor::_uv_draw() {
}
for (int i = 0; i < uvs.size(); i++) {
if (weight_r) {
Vector2 draw_pos = mtx.xform(uvs[i]);
float weight = weight_r[i];
@@ -1138,7 +1073,6 @@ void Polygon2DEditor::_uv_draw() {
}
if (uv_mode == UV_MODE_PAINT_WEIGHT || uv_mode == UV_MODE_CLEAR_WEIGHT) {
NodePath bone_path;
for (int i = 0; i < bone_scroll_vb->get_child_count(); i++) {
CheckBox *c = Object::cast_to<CheckBox>(bone_scroll_vb->get_child(i));
@@ -1154,7 +1088,6 @@ void Polygon2DEditor::_uv_draw() {
Skeleton2D *skeleton = Object::cast_to<Skeleton2D>(node->get_node(skeleton_path));
if (skeleton) {
for (int i = 0; i < skeleton->get_bone_count(); i++) {
Bone2D *bone = skeleton->get_bone(i);
if (bone->get_rest() == Transform2D(0, 0, 0, 0, 0, 0))
continue; //not set
@@ -1164,7 +1097,6 @@ void Polygon2DEditor::_uv_draw() {
bool found_child = false;
for (int j = 0; j < bone->get_child_count(); j++) {
Bone2D *n = Object::cast_to<Bone2D>(bone->get_child(j));
if (!n)
continue;
@@ -1232,7 +1164,6 @@ void Polygon2DEditor::_uv_draw() {
}
void Polygon2DEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_bone_list"), &Polygon2DEditor::_update_bone_list);
ClassDB::bind_method(D_METHOD("_update_polygon_editing_state"), &Polygon2DEditor::_update_polygon_editing_state);
}
@@ -1248,7 +1179,6 @@ Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const {
Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
AbstractPolygon2DEditor(p_editor) {
node = nullptr;
snap_offset = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_offset", Vector2());
snap_step = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_step", Vector2(10, 10));
@@ -1305,7 +1235,6 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
uv_main_vb->add_child(uv_mode_hb);
for (int i = 0; i < UV_MODE_MAX; i++) {
uv_button[i] = memnew(ToolButton);
uv_button[i]->set_toggle_mode(true);
uv_mode_hb->add_child(uv_button[i]);