You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
@@ -37,11 +37,8 @@
|
||||
#include "editor/editor_settings.h"
|
||||
|
||||
void Path2DEditor::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
|
||||
case NOTIFICATION_READY: {
|
||||
|
||||
//button_create->set_icon( get_icon("Edit","EditorIcons"));
|
||||
//button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
|
||||
//set_pressed_button(button_edit);
|
||||
@@ -49,12 +46,10 @@ void Path2DEditor::_notification(int p_what) {
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_PHYSICS_PROCESS: {
|
||||
|
||||
} break;
|
||||
}
|
||||
}
|
||||
void Path2DEditor::_node_removed(Node *p_node) {
|
||||
|
||||
if (p_node == node) {
|
||||
node = NULL;
|
||||
hide();
|
||||
@@ -75,18 +70,15 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
|
||||
Ref<InputEventMouseButton> mb = p_event;
|
||||
if (mb.is_valid()) {
|
||||
|
||||
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
|
||||
|
||||
Vector2 gpoint = mb->get_position();
|
||||
Vector2 cpoint = node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position())));
|
||||
|
||||
if (mb->is_pressed() && action == ACTION_NONE) {
|
||||
|
||||
Ref<Curve2D> curve = node->get_curve();
|
||||
|
||||
for (int i = 0; i < curve->get_point_count(); i++) {
|
||||
|
||||
real_t dist_to_p = gpoint.distance_to(xform.xform(curve->get_point_position(i)));
|
||||
real_t dist_to_p_out = gpoint.distance_to(xform.xform(curve->get_point_position(i) + curve->get_point_out(i)));
|
||||
real_t dist_to_p_in = gpoint.distance_to(xform.xform(curve->get_point_position(i) + curve->get_point_in(i)));
|
||||
@@ -104,7 +96,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
} else if (mode == MODE_EDIT || mode == MODE_EDIT_CURVE) {
|
||||
// In/out controls can be moved in multiple modes.
|
||||
if (dist_to_p_out < grab_threshold && i < (curve->get_point_count() - 1)) {
|
||||
|
||||
action = ACTION_MOVING_OUT;
|
||||
action_point = i;
|
||||
moving_from = curve->get_point_out(i);
|
||||
@@ -112,7 +103,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
orig_in_length = curve->get_point_in(action_point).length();
|
||||
return true;
|
||||
} else if (dist_to_p_in < grab_threshold && i > 0) {
|
||||
|
||||
action = ACTION_MOVING_IN;
|
||||
action_point = i;
|
||||
moving_from = curve->get_point_in(i);
|
||||
@@ -126,7 +116,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
// Check for point deletion.
|
||||
if ((mb->get_button_index() == BUTTON_RIGHT && mode == MODE_EDIT) || (mb->get_button_index() == BUTTON_LEFT && mode == MODE_DELETE)) {
|
||||
if (dist_to_p < grab_threshold) {
|
||||
|
||||
undo_redo->create_action(TTR("Remove Point from Curve"));
|
||||
undo_redo->add_do_method(curve.ptr(), "remove_point", i);
|
||||
undo_redo->add_undo_method(curve.ptr(), "add_point", curve->get_point_position(i), curve->get_point_in(i), curve->get_point_out(i), i);
|
||||
@@ -135,7 +124,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
undo_redo->commit_action();
|
||||
return true;
|
||||
} else if (dist_to_p_out < grab_threshold) {
|
||||
|
||||
undo_redo->create_action(TTR("Remove Out-Control from Curve"));
|
||||
undo_redo->add_do_method(curve.ptr(), "set_point_out", i, Vector2());
|
||||
undo_redo->add_undo_method(curve.ptr(), "set_point_out", i, curve->get_point_out(i));
|
||||
@@ -144,7 +132,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
undo_redo->commit_action();
|
||||
return true;
|
||||
} else if (dist_to_p_in < grab_threshold) {
|
||||
|
||||
undo_redo->create_action(TTR("Remove In-Control from Curve"));
|
||||
undo_redo->add_do_method(curve.ptr(), "set_point_in", i, Vector2());
|
||||
undo_redo->add_undo_method(curve.ptr(), "set_point_in", i, curve->get_point_in(i));
|
||||
@@ -159,7 +146,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
|
||||
// Check for point creation.
|
||||
if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && ((mb->get_command() && mode == MODE_EDIT) || mode == MODE_CREATE)) {
|
||||
|
||||
Ref<Curve2D> curve = node->get_curve();
|
||||
|
||||
undo_redo->create_action(TTR("Add Point to Curve"));
|
||||
@@ -216,18 +202,15 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
|
||||
// Check for point movement completion.
|
||||
if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && action != ACTION_NONE) {
|
||||
|
||||
Ref<Curve2D> curve = node->get_curve();
|
||||
|
||||
Vector2 new_pos = moving_from + xform.affine_inverse().basis_xform(gpoint - moving_screen_from);
|
||||
switch (action) {
|
||||
|
||||
case ACTION_NONE:
|
||||
// N/A, handled in above condition.
|
||||
break;
|
||||
|
||||
case ACTION_MOVING_POINT: {
|
||||
|
||||
undo_redo->create_action(TTR("Move Point in Curve"));
|
||||
undo_redo->add_do_method(curve.ptr(), "set_point_position", action_point, cpoint);
|
||||
undo_redo->add_undo_method(curve.ptr(), "set_point_position", action_point, moving_from);
|
||||
@@ -238,7 +221,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
} break;
|
||||
|
||||
case ACTION_MOVING_IN: {
|
||||
|
||||
undo_redo->create_action(TTR("Move In-Control in Curve"));
|
||||
undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, new_pos);
|
||||
undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, moving_from);
|
||||
@@ -254,7 +236,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
} break;
|
||||
|
||||
case ACTION_MOVING_OUT: {
|
||||
|
||||
undo_redo->create_action(TTR("Move Out-Control in Curve"));
|
||||
undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, new_pos);
|
||||
undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, moving_from);
|
||||
@@ -279,7 +260,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
|
||||
if (mm.is_valid()) {
|
||||
|
||||
if (action == ACTION_NONE && mode == MODE_EDIT) {
|
||||
// Handle Edge Follow
|
||||
bool old_edge = on_edge;
|
||||
@@ -336,7 +316,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
Vector2 new_pos = moving_from + xform.affine_inverse().basis_xform(gpoint - moving_screen_from);
|
||||
|
||||
switch (action) {
|
||||
|
||||
case ACTION_NONE:
|
||||
// N/A, handled in above condition.
|
||||
break;
|
||||
@@ -369,7 +348,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
|
||||
void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
|
||||
|
||||
if (!node || !node->is_visible_in_tree() || !node->get_curve().is_valid())
|
||||
return;
|
||||
|
||||
@@ -435,19 +413,16 @@ void Path2DEditor::_node_visibility_changed() {
|
||||
}
|
||||
|
||||
void Path2DEditor::edit(Node *p_path2d) {
|
||||
|
||||
if (!canvas_item_editor) {
|
||||
canvas_item_editor = CanvasItemEditor::get_singleton();
|
||||
}
|
||||
|
||||
if (p_path2d) {
|
||||
|
||||
node = Object::cast_to<Path2D>(p_path2d);
|
||||
if (!node->is_connected("visibility_changed", this, "_node_visibility_changed"))
|
||||
node->connect("visibility_changed", this, "_node_visibility_changed");
|
||||
|
||||
} else {
|
||||
|
||||
// node may have been deleted at this point
|
||||
if (node && node->is_connected("visibility_changed", this, "_node_visibility_changed"))
|
||||
node->disconnect("visibility_changed", this, "_node_visibility_changed");
|
||||
@@ -456,7 +431,6 @@ void Path2DEditor::edit(Node *p_path2d) {
|
||||
}
|
||||
|
||||
void Path2DEditor::_bind_methods() {
|
||||
|
||||
//ClassDB::bind_method(D_METHOD("_menu_option"),&Path2DEditor::_menu_option);
|
||||
ClassDB::bind_method(D_METHOD("_node_visibility_changed"), &Path2DEditor::_node_visibility_changed);
|
||||
ClassDB::bind_method(D_METHOD("_mode_selected"), &Path2DEditor::_mode_selected);
|
||||
@@ -464,33 +438,27 @@ void Path2DEditor::_bind_methods() {
|
||||
}
|
||||
|
||||
void Path2DEditor::_mode_selected(int p_mode) {
|
||||
|
||||
if (p_mode == MODE_CREATE) {
|
||||
|
||||
curve_create->set_pressed(true);
|
||||
curve_edit->set_pressed(false);
|
||||
curve_edit_curve->set_pressed(false);
|
||||
curve_del->set_pressed(false);
|
||||
} else if (p_mode == MODE_EDIT) {
|
||||
|
||||
curve_create->set_pressed(false);
|
||||
curve_edit->set_pressed(true);
|
||||
curve_edit_curve->set_pressed(false);
|
||||
curve_del->set_pressed(false);
|
||||
} else if (p_mode == MODE_EDIT_CURVE) {
|
||||
|
||||
curve_create->set_pressed(false);
|
||||
curve_edit->set_pressed(false);
|
||||
curve_edit_curve->set_pressed(true);
|
||||
curve_del->set_pressed(false);
|
||||
} else if (p_mode == MODE_DELETE) {
|
||||
|
||||
curve_create->set_pressed(false);
|
||||
curve_edit->set_pressed(false);
|
||||
curve_edit_curve->set_pressed(false);
|
||||
curve_del->set_pressed(true);
|
||||
} else if (p_mode == ACTION_CLOSE) {
|
||||
|
||||
//?
|
||||
|
||||
if (!node->get_curve().is_valid())
|
||||
@@ -516,7 +484,6 @@ void Path2DEditor::_mode_selected(int p_mode) {
|
||||
}
|
||||
|
||||
void Path2DEditor::_handle_option_pressed(int p_option) {
|
||||
|
||||
PopupMenu *pm;
|
||||
pm = handle_menu->get_popup();
|
||||
|
||||
@@ -536,7 +503,6 @@ void Path2DEditor::_handle_option_pressed(int p_option) {
|
||||
}
|
||||
|
||||
Path2DEditor::Path2DEditor(EditorNode *p_editor) {
|
||||
|
||||
canvas_item_editor = NULL;
|
||||
editor = p_editor;
|
||||
undo_redo = editor->get_undo_redo();
|
||||
@@ -606,23 +572,19 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) {
|
||||
}
|
||||
|
||||
void Path2DEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
path2d_editor->edit(Object::cast_to<Node>(p_object));
|
||||
}
|
||||
|
||||
bool Path2DEditorPlugin::handles(Object *p_object) const {
|
||||
|
||||
return p_object->is_class("Path2D");
|
||||
}
|
||||
|
||||
void Path2DEditorPlugin::make_visible(bool p_visible) {
|
||||
|
||||
if (p_visible) {
|
||||
path2d_editor->show();
|
||||
path2d_editor->base_hb->show();
|
||||
|
||||
} else {
|
||||
|
||||
path2d_editor->hide();
|
||||
path2d_editor->base_hb->hide();
|
||||
path2d_editor->edit(NULL);
|
||||
@@ -630,7 +592,6 @@ void Path2DEditorPlugin::make_visible(bool p_visible) {
|
||||
}
|
||||
|
||||
Path2DEditorPlugin::Path2DEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
editor = p_node;
|
||||
path2d_editor = memnew(Path2DEditor(p_node));
|
||||
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(path2d_editor);
|
||||
|
||||
Reference in New Issue
Block a user