feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -49,10 +49,10 @@
|
|||
#include "editor/themes/editor_scale.h"
|
||||
#include "editor/themes/editor_theme_manager.h"
|
||||
#include "scene/2d/audio_stream_player_2d.h"
|
||||
#include "scene/2d/physics/touch_screen_button.h"
|
||||
#include "scene/2d/polygon_2d.h"
|
||||
#include "scene/2d/skeleton_2d.h"
|
||||
#include "scene/2d/sprite_2d.h"
|
||||
#include "scene/2d/touch_screen_button.h"
|
||||
#include "scene/gui/base_button.h"
|
||||
#include "scene/gui/flow_container.h"
|
||||
#include "scene/gui/grid_container.h"
|
||||
|
|
@ -118,6 +118,7 @@ public:
|
|||
grid_offset_x->set_suffix("px");
|
||||
grid_offset_x->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
grid_offset_x->set_select_all_on_focus(true);
|
||||
grid_offset_x->set_accessibility_name(TTRC("X Offset"));
|
||||
child_container->add_child(grid_offset_x);
|
||||
|
||||
grid_offset_y = memnew(SpinBox);
|
||||
|
|
@ -128,6 +129,7 @@ public:
|
|||
grid_offset_y->set_suffix("px");
|
||||
grid_offset_y->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
grid_offset_y->set_select_all_on_focus(true);
|
||||
grid_offset_y->set_accessibility_name(TTRC("Y Offset"));
|
||||
child_container->add_child(grid_offset_y);
|
||||
|
||||
label = memnew(Label);
|
||||
|
|
@ -142,6 +144,7 @@ public:
|
|||
grid_step_x->set_suffix("px");
|
||||
grid_step_x->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
grid_step_x->set_select_all_on_focus(true);
|
||||
grid_step_x->set_accessibility_name(TTRC("X Step"));
|
||||
child_container->add_child(grid_step_x);
|
||||
|
||||
grid_step_y = memnew(SpinBox);
|
||||
|
|
@ -151,6 +154,7 @@ public:
|
|||
grid_step_y->set_suffix("px");
|
||||
grid_step_y->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
grid_step_y->set_select_all_on_focus(true);
|
||||
grid_step_y->set_accessibility_name(TTRC("X Step"));
|
||||
child_container->add_child(grid_step_y);
|
||||
|
||||
label = memnew(Label);
|
||||
|
|
@ -166,6 +170,7 @@ public:
|
|||
primary_grid_step_x->set_suffix("steps");
|
||||
primary_grid_step_x->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
primary_grid_step_x->set_select_all_on_focus(true);
|
||||
primary_grid_step_x->set_accessibility_name(TTRC("X Primary Step"));
|
||||
child_container->add_child(primary_grid_step_x);
|
||||
|
||||
primary_grid_step_y = memnew(SpinBox);
|
||||
|
|
@ -176,6 +181,7 @@ public:
|
|||
primary_grid_step_y->set_suffix("steps");
|
||||
primary_grid_step_y->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
primary_grid_step_y->set_select_all_on_focus(true);
|
||||
primary_grid_step_y->set_accessibility_name(TTRC("Y Primary Step"));
|
||||
child_container->add_child(primary_grid_step_y);
|
||||
|
||||
container->add_child(memnew(HSeparator));
|
||||
|
|
@ -197,6 +203,7 @@ public:
|
|||
rotation_offset->set_suffix("deg");
|
||||
rotation_offset->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
rotation_offset->set_select_all_on_focus(true);
|
||||
rotation_offset->set_accessibility_name(TTRC("Rotation Offset"));
|
||||
child_container->add_child(rotation_offset);
|
||||
|
||||
label = memnew(Label);
|
||||
|
|
@ -210,6 +217,7 @@ public:
|
|||
rotation_step->set_suffix("deg");
|
||||
rotation_step->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
rotation_step->set_select_all_on_focus(true);
|
||||
rotation_step->set_accessibility_name(TTRC("Rotation Step"));
|
||||
child_container->add_child(rotation_step);
|
||||
|
||||
container->add_child(memnew(HSeparator));
|
||||
|
|
@ -229,6 +237,7 @@ public:
|
|||
scale_step->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
scale_step->set_step(0.01f);
|
||||
scale_step->set_select_all_on_focus(true);
|
||||
scale_step->set_accessibility_name(TTRC("Scale Step"));
|
||||
child_container->add_child(scale_step);
|
||||
}
|
||||
|
||||
|
|
@ -770,14 +779,15 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n
|
|||
|
||||
bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_pos, bool p_append) {
|
||||
bool still_selected = true;
|
||||
if (p_append && !editor_selection->get_selected_node_list().is_empty()) {
|
||||
const List<Node *> &top_node_list = editor_selection->get_top_selected_node_list();
|
||||
if (p_append && !top_node_list.is_empty()) {
|
||||
if (editor_selection->is_selected(item)) {
|
||||
// Already in the selection, remove it from the selected nodes
|
||||
editor_selection->remove_node(item);
|
||||
still_selected = false;
|
||||
|
||||
if (editor_selection->get_selected_node_list().size() == 1) {
|
||||
EditorNode::get_singleton()->push_item(editor_selection->get_selected_node_list().front()->get());
|
||||
if (top_node_list.size() == 1) {
|
||||
EditorNode::get_singleton()->push_item(top_node_list.front()->get());
|
||||
}
|
||||
} else {
|
||||
// Add the item to the selection
|
||||
|
|
@ -974,7 +984,7 @@ void CanvasItemEditor::_add_node_pressed(int p_result) {
|
|||
[[fallthrough]];
|
||||
}
|
||||
case ADD_MOVE: {
|
||||
nodes_to_move = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
|
||||
nodes_to_move = EditorNode::get_singleton()->get_editor_selection()->get_top_selected_node_list();
|
||||
if (nodes_to_move.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1116,7 +1126,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
|
|||
if (m.is_valid() && m->get_position().x < RULER_WIDTH) {
|
||||
// Check if we are hovering an existing horizontal guide
|
||||
for (int i = 0; i < hguides.size(); i++) {
|
||||
if (ABS(xform.xform(Point2(0, hguides[i])).y - m->get_position().y) < MIN(minimum, 8)) {
|
||||
if (Math::abs(xform.xform(Point2(0, hguides[i])).y - m->get_position().y) < MIN(minimum, 8)) {
|
||||
is_hovering_h_guide = true;
|
||||
is_hovering_v_guide = false;
|
||||
break;
|
||||
|
|
@ -1126,7 +1136,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
|
|||
} else if (m.is_valid() && m->get_position().y < RULER_WIDTH) {
|
||||
// Check if we are hovering an existing vertical guide
|
||||
for (int i = 0; i < vguides.size(); i++) {
|
||||
if (ABS(xform.xform(Point2(vguides[i], 0)).x - m->get_position().x) < MIN(minimum, 8)) {
|
||||
if (Math::abs(xform.xform(Point2(vguides[i], 0)).x - m->get_position().x) < MIN(minimum, 8)) {
|
||||
is_hovering_v_guide = true;
|
||||
is_hovering_h_guide = false;
|
||||
break;
|
||||
|
|
@ -1146,7 +1156,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
|
|||
// Check if we drag an existing horizontal guide
|
||||
dragged_guide_index = -1;
|
||||
for (int i = 0; i < hguides.size(); i++) {
|
||||
if (ABS(xform.xform(Point2(0, hguides[i])).y - b->get_position().y) < MIN(minimum, 8)) {
|
||||
if (Math::abs(xform.xform(Point2(0, hguides[i])).y - b->get_position().y) < MIN(minimum, 8)) {
|
||||
dragged_guide_index = i;
|
||||
}
|
||||
}
|
||||
|
|
@ -1163,7 +1173,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
|
|||
// Check if we drag an existing vertical guide
|
||||
dragged_guide_index = -1;
|
||||
for (int i = 0; i < vguides.size(); i++) {
|
||||
if (ABS(xform.xform(Point2(vguides[i], 0)).x - b->get_position().x) < MIN(minimum, 8)) {
|
||||
if (Math::abs(xform.xform(Point2(vguides[i], 0)).x - b->get_position().x) < MIN(minimum, 8)) {
|
||||
dragged_guide_index = i;
|
||||
}
|
||||
}
|
||||
|
|
@ -1597,7 +1607,7 @@ bool CanvasItemEditor::_gui_input_open_scene_on_double_click(const Ref<InputEven
|
|||
if (selection.size() == 1) {
|
||||
CanvasItem *ci = selection.front()->get();
|
||||
if (!ci->get_scene_file_path().is_empty() && ci != EditorNode::get_singleton()->get_edited_scene()) {
|
||||
EditorNode::get_singleton()->open_request(ci->get_scene_file_path());
|
||||
EditorNode::get_singleton()->load_scene(ci->get_scene_file_path());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -2220,7 +2230,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
|||
|
||||
bool single_axis = m->is_shift_pressed();
|
||||
if (single_axis) {
|
||||
if (ABS(new_pos.x - previous_pos.x) > ABS(new_pos.y - previous_pos.y)) {
|
||||
if (Math::abs(new_pos.x - previous_pos.x) > Math::abs(new_pos.y - previous_pos.y)) {
|
||||
new_pos.y = previous_pos.y;
|
||||
} else {
|
||||
new_pos.x = previous_pos.x;
|
||||
|
|
@ -2468,7 +2478,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
for (Node *node : EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()) {
|
||||
for (Node *node : EditorNode::get_singleton()->get_editor_selection()->get_top_selected_node_list()) {
|
||||
if (Object::cast_to<CanvasItem>(node)) {
|
||||
add_node_menu->add_icon_item(get_editor_theme_icon(SNAME("ToolMove")), TTR("Move Node(s) Here"), ADD_MOVE);
|
||||
break;
|
||||
|
|
@ -2599,7 +2609,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
|
|||
}
|
||||
|
||||
_find_canvas_items_in_rect(Rect2(bsfrom, bsto - bsfrom), scene, &selitems);
|
||||
if (selitems.size() == 1 && editor_selection->get_selected_node_list().is_empty()) {
|
||||
if (selitems.size() == 1 && editor_selection->get_top_selected_node_list().is_empty()) {
|
||||
EditorNode::get_singleton()->push_item(selitems.front()->get());
|
||||
}
|
||||
for (CanvasItem *E : selitems) {
|
||||
|
|
@ -2812,7 +2822,7 @@ void CanvasItemEditor::_update_lock_and_group_button() {
|
|||
bool all_locked = true;
|
||||
bool all_group = true;
|
||||
bool has_canvas_item = false;
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
List<Node *> selection = editor_selection->get_top_selected_node_list();
|
||||
if (selection.is_empty()) {
|
||||
all_locked = false;
|
||||
all_group = false;
|
||||
|
|
@ -2854,14 +2864,14 @@ Control::CursorShape CanvasItemEditor::get_cursor_shape(const Point2 &p_pos) con
|
|||
|
||||
List<CanvasItem *> selection = _get_edited_canvas_items();
|
||||
if (selection.size() == 1) {
|
||||
const double angle = Math::fposmod((double)selection.front()->get()->get_global_transform_with_canvas().get_rotation(), Math_PI);
|
||||
if (angle > Math_PI * 7.0 / 8.0) {
|
||||
const double angle = Math::fposmod((double)selection.front()->get()->get_global_transform_with_canvas().get_rotation(), Math::PI);
|
||||
if (angle > Math::PI * 7.0 / 8.0) {
|
||||
rotation_array_index = 0;
|
||||
} else if (angle > Math_PI * 5.0 / 8.0) {
|
||||
} else if (angle > Math::PI * 5.0 / 8.0) {
|
||||
rotation_array_index = 1;
|
||||
} else if (angle > Math_PI * 3.0 / 8.0) {
|
||||
} else if (angle > Math::PI * 3.0 / 8.0) {
|
||||
rotation_array_index = 2;
|
||||
} else if (angle > Math_PI * 1.0 / 8.0) {
|
||||
} else if (angle > Math::PI * 1.0 / 8.0) {
|
||||
rotation_array_index = 3;
|
||||
} else {
|
||||
rotation_array_index = 0;
|
||||
|
|
@ -3075,7 +3085,7 @@ void CanvasItemEditor::_draw_rulers() {
|
|||
if (i % (major_subdivision * minor_subdivision) == 0) {
|
||||
viewport->draw_line(Point2(position.x, 0), Point2(position.x, RULER_WIDTH), graduation_color, Math::round(EDSCALE));
|
||||
real_t val = (ruler_transform * major_subdivide * minor_subdivide).xform(Point2(i, 0)).x;
|
||||
viewport->draw_string(font, Point2(position.x + 2, font->get_height(font_size)), TS->format_number(vformat(((int)val == val) ? "%d" : "%.1f", val)), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color);
|
||||
viewport->draw_string(font, Point2(position.x + 2, font->get_ascent(font_size) + Math::round(EDSCALE)), TS->format_number(vformat(((int)val == val) ? "%d" : "%.1f", val)), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color);
|
||||
} else {
|
||||
if (i % minor_subdivision == 0) {
|
||||
viewport->draw_line(Point2(position.x, RULER_WIDTH * 0.33), Point2(position.x, RULER_WIDTH), graduation_color, Math::round(EDSCALE));
|
||||
|
|
@ -3093,7 +3103,7 @@ void CanvasItemEditor::_draw_rulers() {
|
|||
viewport->draw_line(Point2(0, position.y), Point2(RULER_WIDTH, position.y), graduation_color, Math::round(EDSCALE));
|
||||
real_t val = (ruler_transform * major_subdivide * minor_subdivide).xform(Point2(0, i)).y;
|
||||
|
||||
Transform2D text_xform = Transform2D(-Math_PI / 2.0, Point2(font->get_height(font_size), position.y - 2));
|
||||
Transform2D text_xform = Transform2D(-Math::PI / 2.0, Point2(font->get_ascent(font_size) + Math::round(EDSCALE), position.y - 2));
|
||||
viewport->draw_set_transform_matrix(viewport->get_transform() * text_xform);
|
||||
viewport->draw_string(font, Point2(), TS->format_number(vformat(((int)val == val) ? "%d" : "%.1f", val)), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color);
|
||||
viewport->draw_set_transform_matrix(viewport->get_transform());
|
||||
|
|
@ -3200,7 +3210,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
|
|||
Vector2 length_vector = (begin - end).abs() / zoom;
|
||||
|
||||
const real_t horizontal_angle_rad = length_vector.angle();
|
||||
const real_t vertical_angle_rad = Math_PI / 2.0 - horizontal_angle_rad;
|
||||
const real_t vertical_angle_rad = Math::PI / 2.0 - horizontal_angle_rad;
|
||||
|
||||
Ref<Font> font = get_theme_font(SNAME("bold"), EditorStringName(EditorFonts));
|
||||
int font_size = 1.3 * get_theme_font_size(SNAME("bold_size"), EditorStringName(EditorFonts));
|
||||
|
|
@ -3236,18 +3246,18 @@ void CanvasItemEditor::_draw_ruler_tool() {
|
|||
const Vector2 end_to_begin = (end - begin);
|
||||
|
||||
real_t arc_1_start_angle = end_to_begin.x < 0
|
||||
? (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 - vertical_angle_rad : Math_PI / 2.0)
|
||||
: (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 : Math_PI / 2.0 - vertical_angle_rad);
|
||||
? (end_to_begin.y < 0 ? 3.0 * Math::PI / 2.0 - vertical_angle_rad : Math::PI / 2.0)
|
||||
: (end_to_begin.y < 0 ? 3.0 * Math::PI / 2.0 : Math::PI / 2.0 - vertical_angle_rad);
|
||||
real_t arc_1_end_angle = arc_1_start_angle + vertical_angle_rad;
|
||||
// Constrain arc to triangle height & max size.
|
||||
real_t arc_1_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.y)), arc_max_radius);
|
||||
real_t arc_1_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, Math::abs(end_to_begin.y)), arc_max_radius);
|
||||
|
||||
real_t arc_2_start_angle = end_to_begin.x < 0
|
||||
? (end_to_begin.y < 0 ? 0.0 : -horizontal_angle_rad)
|
||||
: (end_to_begin.y < 0 ? Math_PI - horizontal_angle_rad : Math_PI);
|
||||
: (end_to_begin.y < 0 ? Math::PI - horizontal_angle_rad : Math::PI);
|
||||
real_t arc_2_end_angle = arc_2_start_angle + horizontal_angle_rad;
|
||||
// Constrain arc to triangle width & max size.
|
||||
real_t arc_2_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.x)), arc_max_radius);
|
||||
real_t arc_2_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, Math::abs(end_to_begin.x)), arc_max_radius);
|
||||
|
||||
viewport->draw_arc(begin, arc_1_radius, arc_1_start_angle, arc_1_end_angle, arc_point_count, ruler_primary_color, Math::round(EDSCALE * arc_line_width));
|
||||
viewport->draw_arc(end, arc_2_radius, arc_2_start_angle, arc_2_end_angle, arc_point_count, ruler_primary_color, Math::round(EDSCALE * arc_line_width));
|
||||
|
|
@ -3265,8 +3275,8 @@ void CanvasItemEditor::_draw_ruler_tool() {
|
|||
viewport->draw_string(font, text_pos, TS->format_number(vformat("%.1f px", length_vector.length())), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color);
|
||||
|
||||
if (draw_secondary_lines) {
|
||||
const int horizontal_angle = round(180 * horizontal_angle_rad / Math_PI);
|
||||
const int vertical_angle = round(180 * vertical_angle_rad / Math_PI);
|
||||
const int horizontal_angle = round(180 * horizontal_angle_rad / Math::PI);
|
||||
const int vertical_angle = round(180 * vertical_angle_rad / Math::PI);
|
||||
|
||||
Point2 text_pos2 = text_pos;
|
||||
text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2);
|
||||
|
|
@ -3288,13 +3298,13 @@ void CanvasItemEditor::_draw_ruler_tool() {
|
|||
h_angle_text_pos.x = CLAMP(end.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width);
|
||||
if (begin.y < end.y) {
|
||||
h_angle_text_pos.y = end.y + text_height * 1.5;
|
||||
if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) {
|
||||
if (Math::abs(text_pos2.x - h_angle_text_pos.x) < text_width) {
|
||||
int height_multiplier = 1.5 + (int)grid_snap_active;
|
||||
h_angle_text_pos.y = MAX(text_pos.y + height_multiplier * text_height, MAX(end.y + text_height * 1.5, text_pos2.y + height_multiplier * text_height));
|
||||
}
|
||||
} else {
|
||||
h_angle_text_pos.y = end.y - text_height * 0.5;
|
||||
if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) {
|
||||
if (Math::abs(text_pos2.x - h_angle_text_pos.x) < text_width) {
|
||||
int height_multiplier = 1 + (int)grid_snap_active;
|
||||
h_angle_text_pos.y = MIN(text_pos.y - height_multiplier * text_height, MIN(end.y - text_height * 0.5, text_pos2.y - height_multiplier * text_height));
|
||||
}
|
||||
|
|
@ -3645,7 +3655,7 @@ void CanvasItemEditor::_draw_selection() {
|
|||
int next = (i + 1) % 4;
|
||||
|
||||
Vector2 ofs = ((endpoints[i] - endpoints[prev]).normalized() + ((endpoints[i] - endpoints[next]).normalized())).normalized();
|
||||
ofs *= Math_SQRT2 * (select_handle->get_size().width / 2);
|
||||
ofs *= Math::SQRT2 * (select_handle->get_size().width / 2);
|
||||
|
||||
select_handle->draw(vp_ci, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor());
|
||||
|
||||
|
|
@ -4127,6 +4137,15 @@ void CanvasItemEditor::_notification(int p_what) {
|
|||
ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &CanvasItemEditor::_project_settings_changed));
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
|
||||
RID ae = get_accessibility_element();
|
||||
ERR_FAIL_COND(ae.is_null());
|
||||
|
||||
//TODO
|
||||
DisplayServer::get_singleton()->accessibility_update_set_role(ae, DisplayServer::AccessibilityRole::ROLE_STATIC_TEXT);
|
||||
DisplayServer::get_singleton()->accessibility_update_set_value(ae, TTR(vformat("The %s is not accessible at this time.", "Canvas item editor")));
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_PROCESS: {
|
||||
// Update the viewport if the canvas_item changes
|
||||
List<CanvasItem *> selection = _get_edited_canvas_items(true);
|
||||
|
|
@ -4238,8 +4257,8 @@ void CanvasItemEditor::_selection_changed() {
|
|||
}
|
||||
selected_from_canvas = false;
|
||||
|
||||
if (temp_pivot != Vector2(INFINITY, INFINITY)) {
|
||||
temp_pivot = Vector2(INFINITY, INFINITY);
|
||||
if (temp_pivot != Vector2(Math::INF, Math::INF)) {
|
||||
temp_pivot = Vector2(Math::INF, Math::INF);
|
||||
viewport->queue_redraw();
|
||||
}
|
||||
}
|
||||
|
|
@ -4584,7 +4603,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
|||
snap_dialog->popup_centered(Size2(320, 160) * EDSCALE);
|
||||
} break;
|
||||
case SKELETON_SHOW_BONES: {
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
List<Node *> selection = editor_selection->get_top_selected_node_list();
|
||||
for (Node *E : selection) {
|
||||
// Add children nodes so they are processed
|
||||
for (int child = 0; child < E->get_child_count(); child++) {
|
||||
|
|
@ -4619,7 +4638,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
|||
case LOCK_SELECTED: {
|
||||
undo_redo->create_action(TTR("Lock Selected"));
|
||||
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
List<Node *> selection = editor_selection->get_top_selected_node_list();
|
||||
for (Node *E : selection) {
|
||||
CanvasItem *ci = Object::cast_to<CanvasItem>(E);
|
||||
if (!ci || !ci->is_inside_tree()) {
|
||||
|
|
@ -4638,7 +4657,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
|||
case UNLOCK_SELECTED: {
|
||||
undo_redo->create_action(TTR("Unlock Selected"));
|
||||
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
List<Node *> selection = editor_selection->get_top_selected_node_list();
|
||||
for (Node *E : selection) {
|
||||
CanvasItem *ci = Object::cast_to<CanvasItem>(E);
|
||||
if (!ci || !ci->is_inside_tree()) {
|
||||
|
|
@ -4657,7 +4676,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
|||
case GROUP_SELECTED: {
|
||||
undo_redo->create_action(TTR("Group Selected"));
|
||||
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
List<Node *> selection = editor_selection->get_top_selected_node_list();
|
||||
for (Node *E : selection) {
|
||||
CanvasItem *ci = Object::cast_to<CanvasItem>(E);
|
||||
if (!ci || !ci->is_inside_tree()) {
|
||||
|
|
@ -4676,7 +4695,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
|||
case UNGROUP_SELECTED: {
|
||||
undo_redo->create_action(TTR("Ungroup Selected"));
|
||||
|
||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
||||
List<Node *> selection = editor_selection->get_top_selected_node_list();
|
||||
for (Node *E : selection) {
|
||||
CanvasItem *ci = Object::cast_to<CanvasItem>(E);
|
||||
if (!ci || !ci->is_inside_tree()) {
|
||||
|
|
@ -4739,7 +4758,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
|||
|
||||
undo_redo->create_action(TTR("Paste Pose"));
|
||||
for (const PoseClipboard &E : pose_clipboard) {
|
||||
Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E.id));
|
||||
Node2D *n2d = ObjectDB::get_instance<Node2D>(E.id);
|
||||
if (!n2d) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -4872,7 +4891,6 @@ void CanvasItemEditor::_set_owner_for_node_and_children(Node *p_node, Node *p_ow
|
|||
}
|
||||
|
||||
void CanvasItemEditor::_focus_selection(int p_op) {
|
||||
Vector2 center(0.f, 0.f);
|
||||
Rect2 rect;
|
||||
int count = 0;
|
||||
|
||||
|
|
@ -4882,31 +4900,30 @@ void CanvasItemEditor::_focus_selection(int p_op) {
|
|||
if (!ci) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// counting invisible items, for now
|
||||
//if (!ci->is_visible_in_tree()) continue;
|
||||
++count;
|
||||
|
||||
const Transform2D canvas_item_transform = ci->get_global_transform();
|
||||
if (!canvas_item_transform.is_finite()) {
|
||||
continue;
|
||||
}
|
||||
Rect2 item_rect;
|
||||
if (ci->_edit_use_rect()) {
|
||||
item_rect = ci->_edit_get_rect();
|
||||
} else {
|
||||
item_rect = Rect2();
|
||||
}
|
||||
|
||||
Vector2 pos = ci->get_global_transform().get_origin();
|
||||
Vector2 scale = ci->get_global_transform().get_scale();
|
||||
real_t angle = ci->get_global_transform().get_rotation();
|
||||
Vector2 pos = canvas_item_transform.get_origin();
|
||||
const Vector2 scale = canvas_item_transform.get_scale();
|
||||
const real_t angle = canvas_item_transform.get_rotation();
|
||||
pos = ci->get_viewport()->get_popup_base_transform().xform(pos);
|
||||
|
||||
Transform2D t(angle, Vector2(0.f, 0.f));
|
||||
item_rect = t.xform(item_rect);
|
||||
Rect2 canvas_item_rect(pos + scale * item_rect.position, scale * item_rect.size);
|
||||
if (count == 1) {
|
||||
if (count == 0) {
|
||||
rect = canvas_item_rect;
|
||||
} else {
|
||||
rect = rect.merge(canvas_item_rect);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
if (p_op == VIEW_FRAME_TO_SELECTION && rect.size.x > CMP_EPSILON && rect.size.y > CMP_EPSILON) {
|
||||
|
|
@ -5361,6 +5378,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
controls_hb->add_child(button_center_view);
|
||||
button_center_view->set_flat(true);
|
||||
button_center_view->set_tooltip_text(TTR("Center View"));
|
||||
button_center_view->set_accessibility_name(TTRC("Center View"));
|
||||
button_center_view->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(VIEW_CENTER_TO_SELECTION));
|
||||
|
||||
zoom_widget = memnew(EditorZoomWidget);
|
||||
|
|
@ -5403,6 +5421,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTRC("Select Mode"), Key::Q));
|
||||
select_button->set_shortcut_context(this);
|
||||
select_button->set_tooltip_text(keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL) + TTR("Drag: Rotate selected node around pivot.") + "\n" + TTR("Alt+Drag: Move selected node.") + "\n" + keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL) + TTR("Alt+Drag: Scale selected node.") + "\n" + TTR("V: Set selected node's pivot position.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked.") + "\n" + TTR("(Available in all modes.)") + "\n" + TTR("RMB: Add node at position clicked."));
|
||||
select_button->set_accessibility_name(TTRC("Select Mode"));
|
||||
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
|
|
@ -5414,6 +5433,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
move_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/move_mode", TTRC("Move Mode"), Key::W));
|
||||
move_button->set_shortcut_context(this);
|
||||
move_button->set_tooltip_text(TTRC("Move Mode"));
|
||||
move_button->set_accessibility_name(TTRC("Move Mode"));
|
||||
|
||||
rotate_button = memnew(Button);
|
||||
rotate_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
|
|
@ -5423,6 +5443,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
rotate_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/rotate_mode", TTRC("Rotate Mode"), Key::E));
|
||||
rotate_button->set_shortcut_context(this);
|
||||
rotate_button->set_tooltip_text(TTRC("Rotate Mode"));
|
||||
rotate_button->set_accessibility_name(TTRC("Rotate Mode"));
|
||||
|
||||
scale_button = memnew(Button);
|
||||
scale_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
|
|
@ -5432,6 +5453,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
scale_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/scale_mode", TTRC("Scale Mode"), Key::S));
|
||||
scale_button->set_shortcut_context(this);
|
||||
scale_button->set_tooltip_text(TTRC("Shift: Scale proportionally."));
|
||||
scale_button->set_accessibility_name(TTRC("Scale Mode"));
|
||||
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
|
|
@ -5441,6 +5463,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
list_select_button->set_toggle_mode(true);
|
||||
list_select_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_LIST_SELECT));
|
||||
list_select_button->set_tooltip_text(TTR("Show list of selectable nodes at position clicked."));
|
||||
list_select_button->set_accessibility_name(TTRC("List Selectable Nodes"));
|
||||
|
||||
pivot_button = memnew(Button);
|
||||
pivot_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
|
|
@ -5448,6 +5471,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
pivot_button->set_toggle_mode(true);
|
||||
pivot_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_button_tool_select).bind(TOOL_EDIT_PIVOT));
|
||||
pivot_button->set_tooltip_text(TTR("Click to change object's pivot.") + "\n" + TTR("Shift: Set temporary pivot.") + "\n" + TTR("Click this button while holding Shift to put the temporary pivot in the center of the selected nodes."));
|
||||
pivot_button->set_accessibility_name(TTRC("Change Pivot"));
|
||||
|
||||
pan_button = memnew(Button);
|
||||
pan_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
|
|
@ -5457,6 +5481,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
pan_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/pan_mode", TTRC("Pan Mode"), Key::G));
|
||||
pan_button->set_shortcut_context(this);
|
||||
pan_button->set_tooltip_text(TTRC("You can also use Pan View shortcut (Space by default) to pan in any mode."));
|
||||
pan_button->set_accessibility_name(TTRC("Pan View"));
|
||||
|
||||
ruler_button = memnew(Button);
|
||||
ruler_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
|
|
@ -5466,6 +5491,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
ruler_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/ruler_mode", TTRC("Ruler Mode"), Key::R));
|
||||
ruler_button->set_shortcut_context(this);
|
||||
ruler_button->set_tooltip_text(TTRC("Ruler Mode"));
|
||||
ruler_button->set_accessibility_name(TTRC("Ruler Mode"));
|
||||
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
|
|
@ -5477,6 +5503,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
smart_snap_button->set_tooltip_text(TTRC("Toggle smart snapping."));
|
||||
smart_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_smart_snap", TTRC("Use Smart Snap"), KeyModifierMask::SHIFT | Key::S));
|
||||
smart_snap_button->set_shortcut_context(this);
|
||||
smart_snap_button->set_accessibility_name(TTRC("Smart Snap"));
|
||||
|
||||
grid_snap_button = memnew(Button);
|
||||
grid_snap_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
|
|
@ -5486,6 +5513,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
grid_snap_button->set_tooltip_text(TTRC("Toggle grid snapping."));
|
||||
grid_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_grid_snap", TTRC("Use Grid Snap"), KeyModifierMask::SHIFT | Key::G));
|
||||
grid_snap_button->set_shortcut_context(this);
|
||||
grid_snap_button->set_accessibility_name(TTRC("Grid Snap"));
|
||||
|
||||
snap_config_menu = memnew(MenuButton);
|
||||
snap_config_menu->set_flat(false);
|
||||
|
|
@ -5495,6 +5523,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
snap_config_menu->set_h_size_flags(SIZE_SHRINK_END);
|
||||
snap_config_menu->set_tooltip_text(TTR("Snapping Options"));
|
||||
snap_config_menu->set_switch_on_hover(true);
|
||||
snap_config_menu->set_accessibility_name(TTRC("Snapping Options"));
|
||||
|
||||
PopupMenu *p = snap_config_menu->get_popup();
|
||||
p->connect(SceneStringName(id_pressed), callable_mp(this, &CanvasItemEditor::_popup_callback));
|
||||
|
|
@ -5522,6 +5551,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
|
||||
lock_button = memnew(Button);
|
||||
lock_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
lock_button->set_accessibility_name(TTRC("Lock"));
|
||||
main_menu_hbox->add_child(lock_button);
|
||||
|
||||
lock_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(LOCK_SELECTED));
|
||||
|
|
@ -5530,6 +5560,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
lock_button->set_shortcut(ED_GET_SHORTCUT("editor/lock_selected_nodes"));
|
||||
|
||||
unlock_button = memnew(Button);
|
||||
unlock_button->set_accessibility_name(TTRC("Unlock"));
|
||||
unlock_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
main_menu_hbox->add_child(unlock_button);
|
||||
unlock_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(UNLOCK_SELECTED));
|
||||
|
|
@ -5538,6 +5569,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
unlock_button->set_shortcut(ED_GET_SHORTCUT("editor/unlock_selected_nodes"));
|
||||
|
||||
group_button = memnew(Button);
|
||||
group_button->set_accessibility_name(TTRC("Group"));
|
||||
group_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
main_menu_hbox->add_child(group_button);
|
||||
group_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(GROUP_SELECTED));
|
||||
|
|
@ -5546,6 +5578,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
group_button->set_shortcut(ED_GET_SHORTCUT("editor/group_selected_nodes"));
|
||||
|
||||
ungroup_button = memnew(Button);
|
||||
ungroup_button->set_accessibility_name(TTRC("Ungroup"));
|
||||
ungroup_button->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
main_menu_hbox->add_child(ungroup_button);
|
||||
ungroup_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(UNGROUP_SELECTED));
|
||||
|
|
@ -5562,6 +5595,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
main_menu_hbox->add_child(skeleton_menu);
|
||||
skeleton_menu->set_tooltip_text(TTR("Skeleton Options"));
|
||||
skeleton_menu->set_switch_on_hover(true);
|
||||
skeleton_menu->set_accessibility_name(TTRC("Skeleton Options"));
|
||||
|
||||
p = skeleton_menu->get_popup();
|
||||
p->set_hide_on_checkable_item_selection(false);
|
||||
|
|
@ -5653,6 +5687,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
key_loc_button->set_focus_mode(FOCUS_NONE);
|
||||
key_loc_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(ANIM_INSERT_POS));
|
||||
key_loc_button->set_tooltip_text(TTR("Translation mask for inserting keys."));
|
||||
key_loc_button->set_accessibility_name(TTRC("Translation Mask"));
|
||||
animation_hb->add_child(key_loc_button);
|
||||
|
||||
key_rot_button = memnew(Button);
|
||||
|
|
@ -5662,6 +5697,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
key_rot_button->set_focus_mode(FOCUS_NONE);
|
||||
key_rot_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(ANIM_INSERT_ROT));
|
||||
key_rot_button->set_tooltip_text(TTR("Rotation mask for inserting keys."));
|
||||
key_rot_button->set_accessibility_name(TTRC("Rotation Mask"));
|
||||
animation_hb->add_child(key_rot_button);
|
||||
|
||||
key_scale_button = memnew(Button);
|
||||
|
|
@ -5670,6 +5706,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
key_scale_button->set_focus_mode(FOCUS_NONE);
|
||||
key_scale_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(ANIM_INSERT_SCALE));
|
||||
key_scale_button->set_tooltip_text(TTR("Scale mask for inserting keys."));
|
||||
key_scale_button->set_accessibility_name(TTRC("Scale Mask"));
|
||||
animation_hb->add_child(key_scale_button);
|
||||
|
||||
key_insert_button = memnew(Button);
|
||||
|
|
@ -5678,6 +5715,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
key_insert_button->connect(SceneStringName(pressed), callable_mp(this, &CanvasItemEditor::_popup_callback).bind(ANIM_INSERT_KEY));
|
||||
key_insert_button->set_tooltip_text(TTRC("Insert keys (based on mask)."));
|
||||
key_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key", TTRC("Insert Key"), Key::INSERT));
|
||||
key_insert_button->set_accessibility_name(TTRC("Insert Keys"));
|
||||
key_insert_button->set_shortcut_context(this);
|
||||
animation_hb->add_child(key_insert_button);
|
||||
|
||||
|
|
@ -5687,6 +5725,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
key_auto_insert_button->set_focus_mode(FOCUS_NONE);
|
||||
key_auto_insert_button->set_tooltip_text(TTRC("Auto insert keys when objects are translated, rotated or scaled (based on mask).\nKeys are only added to existing tracks, no new tracks will be created.\nKeys must be inserted manually for the first time."));
|
||||
key_auto_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_auto_insert_key", TTRC("Auto Insert Key")));
|
||||
key_auto_insert_button->set_accessibility_name(TTRC("Auto Insert Keys"));
|
||||
key_auto_insert_button->set_shortcut_context(this);
|
||||
animation_hb->add_child(key_auto_insert_button);
|
||||
|
||||
|
|
@ -5695,6 +5734,7 @@ CanvasItemEditor::CanvasItemEditor() {
|
|||
animation_menu->set_theme_type_variation("FlatMenuButton");
|
||||
animation_menu->set_shortcut_context(this);
|
||||
animation_menu->set_tooltip_text(TTR("Animation Key and Pose Options"));
|
||||
animation_menu->set_accessibility_name(TTRC("Animation Key and Pose"));
|
||||
animation_hb->add_child(animation_menu);
|
||||
animation_menu->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &CanvasItemEditor::_popup_callback));
|
||||
animation_menu->set_switch_on_hover(true);
|
||||
|
|
@ -5794,9 +5834,6 @@ CanvasItemEditorPlugin::CanvasItemEditorPlugin() {
|
|||
canvas_item_editor->hide();
|
||||
}
|
||||
|
||||
CanvasItemEditorPlugin::~CanvasItemEditorPlugin() {
|
||||
}
|
||||
|
||||
void CanvasItemEditorViewport::_on_mouse_exit() {
|
||||
if (!texture_node_type_selector->is_visible()) {
|
||||
_remove_preview();
|
||||
|
|
@ -6067,7 +6104,7 @@ bool CanvasItemEditorViewport::_create_instance(Node *p_parent, const String &p_
|
|||
}
|
||||
|
||||
void CanvasItemEditorViewport::_perform_drop_data() {
|
||||
ERR_FAIL_COND(selected_files.size() <= 0);
|
||||
ERR_FAIL_COND(selected_files.is_empty());
|
||||
|
||||
_remove_preview();
|
||||
|
||||
|
|
@ -6138,6 +6175,9 @@ void CanvasItemEditorViewport::_perform_drop_data() {
|
|||
}
|
||||
|
||||
bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
return false;
|
||||
}
|
||||
Dictionary d = p_data;
|
||||
if (!d.has("type") || (String(d["type"]) != "files")) {
|
||||
label->hide();
|
||||
|
|
@ -6269,6 +6309,9 @@ bool CanvasItemEditorViewport::_is_any_texture_selected() const {
|
|||
}
|
||||
|
||||
void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) {
|
||||
if (p_point == Vector2(Math::INF, Math::INF)) {
|
||||
return;
|
||||
}
|
||||
bool is_shift = Input::get_singleton()->is_key_pressed(Key::SHIFT);
|
||||
bool is_alt = Input::get_singleton()->is_key_pressed(Key::ALT);
|
||||
|
||||
|
|
@ -6277,11 +6320,11 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
|
|||
if (d.has("type") && String(d["type"]) == "files") {
|
||||
selected_files = d["files"];
|
||||
}
|
||||
if (selected_files.size() == 0) {
|
||||
if (selected_files.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Node *> selected_nodes = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
|
||||
List<Node *> selected_nodes = EditorNode::get_singleton()->get_editor_selection()->get_top_selected_node_list();
|
||||
Node *root_node = EditorNode::get_singleton()->get_edited_scene();
|
||||
if (selected_nodes.size() > 0) {
|
||||
Node *selected_node = selected_nodes.front()->get();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue