You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-28 16:07:14 +00:00
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
This commit is contained in:
@@ -200,8 +200,9 @@ void GraphEditMinimap::_adjust_graph_scroll(const Vector2 &p_offset) {
|
||||
}
|
||||
|
||||
Error GraphEdit::connect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) {
|
||||
if (is_node_connected(p_from, p_from_port, p_to, p_to_port))
|
||||
if (is_node_connected(p_from, p_from_port, p_to, p_to_port)) {
|
||||
return OK;
|
||||
}
|
||||
Connection c;
|
||||
c.from = p_from;
|
||||
c.from_port = p_from_port;
|
||||
@@ -219,8 +220,9 @@ Error GraphEdit::connect_node(const StringName &p_from, int p_from_port, const S
|
||||
|
||||
bool GraphEdit::is_node_connected(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) {
|
||||
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
|
||||
if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port)
|
||||
if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -278,8 +280,9 @@ void GraphEdit::_update_scroll_offset() {
|
||||
|
||||
for (int i = 0; i < get_child_count(); i++) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (!gn)
|
||||
if (!gn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Point2 pos = gn->get_offset() * zoom;
|
||||
pos -= Point2(h_scroll->get_value(), v_scroll->get_value());
|
||||
@@ -295,8 +298,9 @@ void GraphEdit::_update_scroll_offset() {
|
||||
}
|
||||
|
||||
void GraphEdit::_update_scroll() {
|
||||
if (updating)
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
updating = true;
|
||||
|
||||
@@ -305,8 +309,9 @@ void GraphEdit::_update_scroll() {
|
||||
Rect2 screen;
|
||||
for (int i = 0; i < get_child_count(); i++) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (!gn)
|
||||
if (!gn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Rect2 r;
|
||||
r.position = gn->get_offset() * zoom;
|
||||
@@ -320,19 +325,21 @@ void GraphEdit::_update_scroll() {
|
||||
h_scroll->set_min(screen.position.x);
|
||||
h_scroll->set_max(screen.position.x + screen.size.x);
|
||||
h_scroll->set_page(get_size().x);
|
||||
if (h_scroll->get_max() - h_scroll->get_min() <= h_scroll->get_page())
|
||||
if (h_scroll->get_max() - h_scroll->get_min() <= h_scroll->get_page()) {
|
||||
h_scroll->hide();
|
||||
else
|
||||
} else {
|
||||
h_scroll->show();
|
||||
}
|
||||
|
||||
v_scroll->set_min(screen.position.y);
|
||||
v_scroll->set_max(screen.position.y + screen.size.y);
|
||||
v_scroll->set_page(get_size().y);
|
||||
|
||||
if (v_scroll->get_max() - v_scroll->get_min() <= v_scroll->get_page())
|
||||
if (v_scroll->get_max() - v_scroll->get_min() <= v_scroll->get_page()) {
|
||||
v_scroll->hide();
|
||||
else
|
||||
} else {
|
||||
v_scroll->show();
|
||||
}
|
||||
|
||||
Size2 hmin = h_scroll->get_combined_minimum_size();
|
||||
Size2 vmin = v_scroll->get_combined_minimum_size();
|
||||
@@ -484,10 +491,11 @@ void GraphEdit::_notification(int p_what) {
|
||||
for (int i = from.x; i < from.x + len.x; i++) {
|
||||
Color color;
|
||||
|
||||
if (ABS(i) % 10 == 0)
|
||||
if (ABS(i) % 10 == 0) {
|
||||
color = grid_major;
|
||||
else
|
||||
} else {
|
||||
color = grid_minor;
|
||||
}
|
||||
|
||||
float base_ofs = i * snap * zoom - offset.x * zoom;
|
||||
draw_line(Vector2(base_ofs, 0), Vector2(base_ofs, get_size().height), color);
|
||||
@@ -496,10 +504,11 @@ void GraphEdit::_notification(int p_what) {
|
||||
for (int i = from.y; i < from.y + len.y; i++) {
|
||||
Color color;
|
||||
|
||||
if (ABS(i) % 10 == 0)
|
||||
if (ABS(i) % 10 == 0) {
|
||||
color = grid_major;
|
||||
else
|
||||
} else {
|
||||
color = grid_minor;
|
||||
}
|
||||
|
||||
float base_ofs = i * snap * zoom - offset.y * zoom;
|
||||
draw_line(Vector2(0, base_ofs), Vector2(get_size().width, base_ofs), color);
|
||||
@@ -519,8 +528,9 @@ bool GraphEdit::_filter_input(const Point2 &p_point) {
|
||||
|
||||
for (int i = get_child_count() - 1; i >= 0; i--) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (!gn)
|
||||
if (!gn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < gn->get_connection_output_count(); j++) {
|
||||
Vector2 pos = gn->get_connection_output_position(j) + gn->get_position();
|
||||
@@ -548,8 +558,9 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
|
||||
click_pos = mb->get_position() / zoom;
|
||||
for (int i = get_child_count() - 1; i >= 0; i--) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (!gn)
|
||||
if (!gn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < gn->get_connection_output_count(); j++) {
|
||||
Vector2 pos = gn->get_connection_output_position(j) + gn->get_position();
|
||||
@@ -720,15 +731,17 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) {
|
||||
}
|
||||
|
||||
bool GraphEdit::_check_clickable_control(Control *p_control, const Vector2 &pos) {
|
||||
if (p_control->is_set_as_toplevel() || !p_control->is_visible())
|
||||
if (p_control->is_set_as_toplevel() || !p_control->is_visible()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!p_control->has_point(pos) || p_control->get_mouse_filter() == MOUSE_FILTER_IGNORE) {
|
||||
//test children
|
||||
for (int i = 0; i < p_control->get_child_count(); i++) {
|
||||
Control *subchild = Object::cast_to<Control>(p_control->get_child(i));
|
||||
if (!subchild)
|
||||
if (!subchild) {
|
||||
continue;
|
||||
}
|
||||
if (_check_clickable_control(subchild, pos - subchild->get_position())) {
|
||||
return true;
|
||||
}
|
||||
@@ -741,13 +754,15 @@ bool GraphEdit::_check_clickable_control(Control *p_control, const Vector2 &pos)
|
||||
}
|
||||
|
||||
bool GraphEdit::is_in_hot_zone(const Vector2 &pos, const Vector2 &p_mouse_pos) {
|
||||
if (!Rect2(pos.x - port_grab_distance_horizontal, pos.y - port_grab_distance_vertical, port_grab_distance_horizontal * 2, port_grab_distance_vertical * 2).has_point(p_mouse_pos))
|
||||
if (!Rect2(pos.x - port_grab_distance_horizontal, pos.y - port_grab_distance_vertical, port_grab_distance_horizontal * 2, port_grab_distance_vertical * 2).has_point(p_mouse_pos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < get_child_count(); i++) {
|
||||
Control *child = Object::cast_to<Control>(get_child(i));
|
||||
if (!child)
|
||||
if (!child) {
|
||||
continue;
|
||||
}
|
||||
Rect2 rect = child->get_rect();
|
||||
|
||||
// To prevent intersections with other nodes.
|
||||
@@ -760,8 +775,9 @@ bool GraphEdit::is_in_hot_zone(const Vector2 &pos, const Vector2 &p_mouse_pos) {
|
||||
|
||||
for (int j = 0; j < child->get_child_count(); j++) {
|
||||
Control *subchild = Object::cast_to<Control>(child->get_child(j));
|
||||
if (!subchild)
|
||||
if (!subchild) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_check_clickable_control(subchild, subpos - subchild->get_position())) {
|
||||
return false;
|
||||
@@ -899,10 +915,11 @@ void GraphEdit::_top_layer_draw() {
|
||||
GraphNode *from = Object::cast_to<GraphNode>(fromn);
|
||||
ERR_FAIL_COND(!from);
|
||||
Vector2 pos;
|
||||
if (connecting_out)
|
||||
if (connecting_out) {
|
||||
pos = from->get_connection_output_position(connecting_index);
|
||||
else
|
||||
} else {
|
||||
pos = from->get_connection_input_position(connecting_index);
|
||||
}
|
||||
pos += from->get_position();
|
||||
|
||||
Vector2 topos;
|
||||
@@ -1039,8 +1056,9 @@ void GraphEdit::_minimap_draw() {
|
||||
void GraphEdit::set_selected(Node *p_child) {
|
||||
for (int i = get_child_count() - 1; i >= 0; i--) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (!gn)
|
||||
if (!gn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
gn->set_selected(gn == p_child);
|
||||
}
|
||||
@@ -1088,8 +1106,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
|
||||
|
||||
for (int i = get_child_count() - 1; i >= 0; i--) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (!gn)
|
||||
if (!gn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Rect2 r = gn->get_rect();
|
||||
r.size *= zoom;
|
||||
@@ -1124,8 +1143,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
|
||||
box_selecting = false;
|
||||
for (int i = get_child_count() - 1; i >= 0; i--) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (!gn)
|
||||
if (!gn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool select = (previous_selected.find(gn) != nullptr);
|
||||
if (gn->is_selected() && !select) {
|
||||
@@ -1168,8 +1188,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
|
||||
if (drag_accum != Vector2()) {
|
||||
for (int i = get_child_count() - 1; i >= 0; i--) {
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (gn && gn->is_selected())
|
||||
if (gn && gn->is_selected()) {
|
||||
gn->set_drag(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1193,8 +1214,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
|
||||
GraphNode *gn_selected = Object::cast_to<GraphNode>(get_child(i));
|
||||
|
||||
if (gn_selected) {
|
||||
if (gn_selected->is_resizing())
|
||||
if (gn_selected->is_resizing()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gn_selected->has_point((b->get_position() - gn_selected->get_position()) / zoom)) {
|
||||
gn = gn_selected;
|
||||
@@ -1204,8 +1226,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
|
||||
}
|
||||
|
||||
if (gn) {
|
||||
if (_filter_input(b->get_position()))
|
||||
if (_filter_input(b->get_position())) {
|
||||
return;
|
||||
}
|
||||
|
||||
dragging = true;
|
||||
drag_accum = Vector2();
|
||||
@@ -1229,17 +1252,21 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
|
||||
gn->set_selected(true);
|
||||
for (int i = 0; i < get_child_count(); i++) {
|
||||
GraphNode *o_gn = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (!o_gn)
|
||||
if (!o_gn) {
|
||||
continue;
|
||||
if (o_gn->is_selected())
|
||||
}
|
||||
if (o_gn->is_selected()) {
|
||||
o_gn->set_drag(true);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (_filter_input(b->get_position()))
|
||||
if (_filter_input(b->get_position())) {
|
||||
return;
|
||||
if (Input::get_singleton()->is_key_pressed(KEY_SPACE))
|
||||
}
|
||||
if (Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
box_selecting = true;
|
||||
box_selecting_from = b->get_position();
|
||||
@@ -1248,8 +1275,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
|
||||
previous_selected.clear();
|
||||
for (int i = get_child_count() - 1; i >= 0; i--) {
|
||||
GraphNode *gn2 = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (!gn2 || !gn2->is_selected())
|
||||
if (!gn2 || !gn2->is_selected()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
previous_selected.push_back(gn2);
|
||||
}
|
||||
@@ -1258,8 +1286,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
|
||||
previous_selected.clear();
|
||||
for (int i = get_child_count() - 1; i >= 0; i--) {
|
||||
GraphNode *gn2 = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (!gn2 || !gn2->is_selected())
|
||||
if (!gn2 || !gn2->is_selected()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
previous_selected.push_back(gn2);
|
||||
}
|
||||
@@ -1268,8 +1297,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
|
||||
previous_selected.clear();
|
||||
for (int i = get_child_count() - 1; i >= 0; i--) {
|
||||
GraphNode *gn2 = Object::cast_to<GraphNode>(get_child(i));
|
||||
if (!gn2)
|
||||
if (!gn2) {
|
||||
continue;
|
||||
}
|
||||
if (gn2->is_selected()) {
|
||||
emit_signal("node_unselected", gn2);
|
||||
}
|
||||
@@ -1366,8 +1396,9 @@ void GraphEdit::set_zoom(float p_zoom) {
|
||||
|
||||
void GraphEdit::set_zoom_custom(float p_zoom, const Vector2 &p_center) {
|
||||
p_zoom = CLAMP(p_zoom, MIN_ZOOM, MAX_ZOOM);
|
||||
if (zoom == p_zoom)
|
||||
if (zoom == p_zoom) {
|
||||
return;
|
||||
}
|
||||
|
||||
zoom_minus->set_disabled(zoom == MIN_ZOOM);
|
||||
zoom_plus->set_disabled(zoom == MAX_ZOOM);
|
||||
|
||||
Reference in New Issue
Block a user