diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 3 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 265 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.h | 73 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 48 | ||||
-rw-r--r-- | editor/project_manager.cpp | 3 | ||||
-rw-r--r-- | editor/property_editor.cpp | 2 |
6 files changed, 247 insertions, 147 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 4e0ad38320..ff415c83f1 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4588,7 +4588,8 @@ EditorNode::EditorNode() { { int dpi_mode = EditorSettings::get_singleton()->get("interface/editor/hidpi_mode"); if (dpi_mode == 0) { - editor_set_scale(OS::get_singleton()->get_screen_dpi(0) >= 192 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x > 2000 ? 2.0 : 1.0); + const int screen = OS::get_singleton()->get_current_screen(); + editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0); } else if (dpi_mode == 1) { editor_set_scale(0.75); } else if (dpi_mode == 2) { diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 4f6c8f89ee..4b216d63f5 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -993,7 +993,7 @@ void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) { se->pre_drag_rect = canvas_item->get_item_rect(); } - if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0])) { + if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0]) && bone_ik_list.size() == 0) { drag = DRAG_NODE_2D; drag_point_from = Object::cast_to<Node2D>(selection[0])->get_global_position(); } else { @@ -2748,9 +2748,9 @@ void CanvasItemEditor::_notification(int p_what) { } if (all_control && has_control) - anchor_menu->show(); + presets_menu->show(); else - anchor_menu->hide(); + presets_menu->hide(); for (Map<ObjectID, BoneList>::Element *E = bone_list.front(); E; E = E->next()) { @@ -2782,57 +2782,15 @@ void CanvasItemEditor::_notification(int p_what) { select_sb->set_default_margin(Margin(i), 4); } - select_button->set_icon(get_icon("ToolSelect", "EditorIcons")); - list_select_button->set_icon(get_icon("ListSelect", "EditorIcons")); - move_button->set_icon(get_icon("ToolMove", "EditorIcons")); - rotate_button->set_icon(get_icon("ToolRotate", "EditorIcons")); - snap_button->set_icon(get_icon("Snap", "EditorIcons")); - snap_config_menu->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons")); - skeleton_menu->set_icon(get_icon("Bone", "EditorIcons")); - pan_button->set_icon(get_icon("ToolPan", "EditorIcons")); - pivot_button->set_icon(get_icon("EditPivot", "EditorIcons")); - select_handle = get_icon("EditorHandle", "EditorIcons"); - anchor_handle = get_icon("EditorControlAnchor", "EditorIcons"); - lock_button->set_icon(get_icon("Lock", "EditorIcons")); - unlock_button->set_icon(get_icon("Unlock", "EditorIcons")); - group_button->set_icon(get_icon("Group", "EditorIcons")); - ungroup_button->set_icon(get_icon("Ungroup", "EditorIcons")); - key_insert_button->set_icon(get_icon("Key", "EditorIcons")); - - zoom_minus->set_icon(get_icon("ZoomLess", "EditorIcons")); - zoom_reset->set_icon(get_icon("ZoomReset", "EditorIcons")); - zoom_plus->set_icon(get_icon("ZoomMore", "EditorIcons")); - - anchor_menu->set_icon(get_icon("Anchor", "EditorIcons")); - PopupMenu *p = anchor_menu->get_popup(); - - p->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), "Top Left", ANCHOR_ALIGN_TOP_LEFT); - p->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), "Top Right", ANCHOR_ALIGN_TOP_RIGHT); - p->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), "Bottom Right", ANCHOR_ALIGN_BOTTOM_RIGHT); - p->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), "Bottom Left", ANCHOR_ALIGN_BOTTOM_LEFT); - p->add_separator(); - p->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), "Center Left", ANCHOR_ALIGN_CENTER_LEFT); - p->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), "Center Top", ANCHOR_ALIGN_CENTER_TOP); - p->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), "Center Right", ANCHOR_ALIGN_CENTER_RIGHT); - p->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), "Center Bottom", ANCHOR_ALIGN_CENTER_BOTTOM); - p->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), "Center", ANCHOR_ALIGN_CENTER); - p->add_separator(); - p->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), "Left Wide", ANCHOR_ALIGN_LEFT_WIDE); - p->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), "Top Wide", ANCHOR_ALIGN_TOP_WIDE); - p->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), "Right Wide", ANCHOR_ALIGN_RIGHT_WIDE); - p->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), "Bottom Wide", ANCHOR_ALIGN_BOTTOM_WIDE); - p->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), "VCenter Wide ", ANCHOR_ALIGN_VCENTER_WIDE); - p->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), "HCenter Wide ", ANCHOR_ALIGN_HCENTER_WIDE); - p->add_separator(); - p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), "Full Rect", ANCHOR_ALIGN_WIDE); - p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), "Full Rect and Fit Parent", ANCHOR_ALIGN_WIDE_FIT); - AnimationPlayerEditor::singleton->get_key_editor()->connect("visibility_changed", this, "_keying_changed"); _keying_changed(); + } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { select_sb->set_texture(get_icon("EditorRect2D", "EditorIcons")); + } + if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { select_button->set_icon(get_icon("ToolSelect", "EditorIcons")); list_select_button->set_icon(get_icon("ListSelect", "EditorIcons")); move_button->set_icon(get_icon("ToolMove", "EditorIcons")); @@ -2850,30 +2808,56 @@ void CanvasItemEditor::_notification(int p_what) { ungroup_button->set_icon(get_icon("Ungroup", "EditorIcons")); key_insert_button->set_icon(get_icon("Key", "EditorIcons")); - anchor_menu->set_icon(get_icon("Anchor", "EditorIcons")); - PopupMenu *p = anchor_menu->get_popup(); - p->clear(); + zoom_minus->set_icon(get_icon("ZoomLess", "EditorIcons")); + zoom_reset->set_icon(get_icon("ZoomReset", "EditorIcons")); + zoom_plus->set_icon(get_icon("ZoomMore", "EditorIcons")); - p->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), "Top Left", ANCHOR_ALIGN_TOP_LEFT); - p->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), "Top Right", ANCHOR_ALIGN_TOP_RIGHT); - p->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), "Bottom Right", ANCHOR_ALIGN_BOTTOM_RIGHT); - p->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), "Bottom Left", ANCHOR_ALIGN_BOTTOM_LEFT); + PopupMenu *p = presets_menu->get_popup(); + + p->clear(); + p->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), "Top Left", ANCHORS_AND_MARGINS_PRESET_TOP_LEFT); + p->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), "Top Right", ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT); + p->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), "Bottom Right", ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT); + p->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), "Bottom Left", ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT); p->add_separator(); - p->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), "Center Left", ANCHOR_ALIGN_CENTER_LEFT); - p->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), "Center Top", ANCHOR_ALIGN_CENTER_TOP); - p->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), "Center Right", ANCHOR_ALIGN_CENTER_RIGHT); - p->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), "Center Bottom", ANCHOR_ALIGN_CENTER_BOTTOM); - p->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), "Center", ANCHOR_ALIGN_CENTER); + p->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), "Center Left", ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT); + p->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), "Center Top", ANCHORS_AND_MARGINS_PRESET_CENTER_TOP); + p->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), "Center Right", ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT); + p->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), "Center Bottom", ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM); + p->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), "Center", ANCHORS_AND_MARGINS_PRESET_CENTER); p->add_separator(); - p->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), "Left Wide", ANCHOR_ALIGN_LEFT_WIDE); - p->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), "Top Wide", ANCHOR_ALIGN_TOP_WIDE); - p->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), "Right Wide", ANCHOR_ALIGN_RIGHT_WIDE); - p->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), "Bottom Wide", ANCHOR_ALIGN_BOTTOM_WIDE); - p->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), "VCenter Wide ", ANCHOR_ALIGN_VCENTER_WIDE); - p->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), "HCenter Wide ", ANCHOR_ALIGN_HCENTER_WIDE); + p->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), "Left Wide", ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE); + p->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), "Top Wide", ANCHORS_AND_MARGINS_PRESET_TOP_WIDE); + p->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), "Right Wide", ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE); + p->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), "Bottom Wide", ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE); + p->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), "VCenter Wide ", ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE); + p->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), "HCenter Wide ", ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE); p->add_separator(); - p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), "Full Rect", ANCHOR_ALIGN_WIDE); - p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), "Full Rect and Fit Parent", ANCHOR_ALIGN_WIDE_FIT); + p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), "Full Rect", ANCHORS_AND_MARGINS_PRESET_WIDE); + p->add_separator(); + p->add_submenu_item(TTR("Anchors only"), "Anchors"); + p->set_item_icon(20, get_icon("Anchor", "EditorIcons")); + + anchors_popup->clear(); + anchors_popup->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), "Top Left", ANCHORS_PRESET_TOP_LEFT); + anchors_popup->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), "Top Right", ANCHORS_PRESET_TOP_RIGHT); + anchors_popup->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), "Bottom Right", ANCHORS_PRESET_BOTTOM_RIGHT); + anchors_popup->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), "Bottom Left", ANCHORS_PRESET_BOTTOM_LEFT); + anchors_popup->add_separator(); + anchors_popup->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), "Center Left", ANCHORS_PRESET_CENTER_LEFT); + anchors_popup->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), "Center Top", ANCHORS_PRESET_CENTER_TOP); + anchors_popup->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), "Center Right", ANCHORS_PRESET_CENTER_RIGHT); + anchors_popup->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), "Center Bottom", ANCHORS_PRESET_CENTER_BOTTOM); + anchors_popup->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), "Center", ANCHORS_PRESET_CENTER); + anchors_popup->add_separator(); + anchors_popup->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), "Left Wide", ANCHORS_PRESET_LEFT_WIDE); + anchors_popup->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), "Top Wide", ANCHORS_PRESET_TOP_WIDE); + anchors_popup->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), "Right Wide", ANCHORS_PRESET_RIGHT_WIDE); + anchors_popup->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), "Bottom Wide", ANCHORS_PRESET_BOTTOM_WIDE); + anchors_popup->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), "VCenter Wide ", ANCHORS_PRESET_VCENTER_WIDE); + anchors_popup->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), "HCenter Wide ", ANCHORS_PRESET_HCENTER_WIDE); + anchors_popup->add_separator(); + anchors_popup->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), "Full Rect", ANCHORS_PRESET_WIDE); } } @@ -3005,25 +2989,51 @@ void CanvasItemEditor::_update_scroll(float) { viewport_base->update(); } -void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) { +void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_preset) { List<Node *> &selection = editor_selection->get_selected_node_list(); - undo_redo->create_action(TTR("Change Anchors")); + undo_redo->create_action(TTR("Change Anchors and Margins")); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { Control *c = Object::cast_to<Control>(E->get()); undo_redo->add_do_method(c, "set_anchors_preset", p_preset); + switch (p_preset) { + case PRESET_TOP_LEFT: + case PRESET_TOP_RIGHT: + case PRESET_BOTTOM_LEFT: + case PRESET_BOTTOM_RIGHT: + case PRESET_CENTER_LEFT: + case PRESET_CENTER_TOP: + case PRESET_CENTER_RIGHT: + case PRESET_CENTER_BOTTOM: + case PRESET_CENTER: + undo_redo->add_do_method(c, "set_margins_preset", p_preset, Control::PRESET_MODE_KEEP_SIZE); + break; + case PRESET_LEFT_WIDE: + case PRESET_TOP_WIDE: + case PRESET_RIGHT_WIDE: + case PRESET_BOTTOM_WIDE: + case PRESET_VCENTER_WIDE: + case PRESET_HCENTER_WIDE: + case PRESET_WIDE: + undo_redo->add_do_method(c, "set_margins_preset", p_preset, Control::PRESET_MODE_MINSIZE); + break; + } undo_redo->add_undo_method(c, "set_anchor", MARGIN_LEFT, c->get_anchor(MARGIN_LEFT)); undo_redo->add_undo_method(c, "set_anchor", MARGIN_TOP, c->get_anchor(MARGIN_TOP)); undo_redo->add_undo_method(c, "set_anchor", MARGIN_RIGHT, c->get_anchor(MARGIN_RIGHT)); undo_redo->add_undo_method(c, "set_anchor", MARGIN_BOTTOM, c->get_anchor(MARGIN_BOTTOM)); + undo_redo->add_undo_method(c, "set_margin", MARGIN_LEFT, c->get_margin(MARGIN_LEFT)); + undo_redo->add_undo_method(c, "set_margin", MARGIN_TOP, c->get_margin(MARGIN_TOP)); + undo_redo->add_undo_method(c, "set_margin", MARGIN_RIGHT, c->get_margin(MARGIN_RIGHT)); + undo_redo->add_undo_method(c, "set_margin", MARGIN_BOTTOM, c->get_margin(MARGIN_BOTTOM)); } undo_redo->commit_action(); } -void CanvasItemEditor::_set_full_rect() { +void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) { List<Node *> &selection = editor_selection->get_selected_node_list(); undo_redo->create_action(TTR("Change Anchors")); @@ -3031,19 +3041,11 @@ void CanvasItemEditor::_set_full_rect() { Control *c = Object::cast_to<Control>(E->get()); - undo_redo->add_do_method(c, "set_anchors_preset", Control::PRESET_WIDE); - undo_redo->add_do_method(c, "set_margin", MARGIN_LEFT, 0); - undo_redo->add_do_method(c, "set_margin", MARGIN_TOP, 0); - undo_redo->add_do_method(c, "set_margin", MARGIN_RIGHT, 0); - undo_redo->add_do_method(c, "set_margin", MARGIN_BOTTOM, 0); + undo_redo->add_do_method(c, "set_anchors_preset", p_preset); undo_redo->add_undo_method(c, "set_anchor", MARGIN_LEFT, c->get_anchor(MARGIN_LEFT)); undo_redo->add_undo_method(c, "set_anchor", MARGIN_TOP, c->get_anchor(MARGIN_TOP)); undo_redo->add_undo_method(c, "set_anchor", MARGIN_RIGHT, c->get_anchor(MARGIN_RIGHT)); undo_redo->add_undo_method(c, "set_anchor", MARGIN_BOTTOM, c->get_anchor(MARGIN_BOTTOM)); - undo_redo->add_undo_method(c, "set_margin", MARGIN_LEFT, c->get_margin(MARGIN_LEFT)); - undo_redo->add_undo_method(c, "set_margin", MARGIN_TOP, c->get_margin(MARGIN_TOP)); - undo_redo->add_undo_method(c, "set_margin", MARGIN_RIGHT, c->get_margin(MARGIN_RIGHT)); - undo_redo->add_undo_method(c, "set_margin", MARGIN_BOTTOM, c->get_margin(MARGIN_BOTTOM)); } undo_redo->commit_action(); @@ -3237,57 +3239,104 @@ void CanvasItemEditor::_popup_callback(int p_op) { viewport->update(); } break; - case ANCHOR_ALIGN_TOP_LEFT: { + + case ANCHORS_AND_MARGINS_PRESET_TOP_LEFT: { + _set_anchors_and_margins_preset(PRESET_TOP_LEFT); + } break; + case ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT: { + _set_anchors_and_margins_preset(PRESET_TOP_RIGHT); + } break; + case ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT: { + _set_anchors_and_margins_preset(PRESET_BOTTOM_LEFT); + } break; + case ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT: { + _set_anchors_and_margins_preset(PRESET_BOTTOM_RIGHT); + } break; + case ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT: { + _set_anchors_and_margins_preset(PRESET_CENTER_LEFT); + } break; + case ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT: { + _set_anchors_and_margins_preset(PRESET_CENTER_RIGHT); + } break; + case ANCHORS_AND_MARGINS_PRESET_CENTER_TOP: { + _set_anchors_and_margins_preset(PRESET_CENTER_TOP); + } break; + case ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM: { + _set_anchors_and_margins_preset(PRESET_CENTER_BOTTOM); + } break; + case ANCHORS_AND_MARGINS_PRESET_CENTER: { + _set_anchors_and_margins_preset(PRESET_CENTER); + } break; + case ANCHORS_AND_MARGINS_PRESET_TOP_WIDE: { + _set_anchors_and_margins_preset(PRESET_TOP_WIDE); + } break; + case ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE: { + _set_anchors_and_margins_preset(PRESET_LEFT_WIDE); + } break; + case ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE: { + _set_anchors_and_margins_preset(PRESET_RIGHT_WIDE); + } break; + case ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE: { + _set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE); + } break; + case ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE: { + _set_anchors_and_margins_preset(PRESET_VCENTER_WIDE); + } break; + case ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE: { + _set_anchors_and_margins_preset(PRESET_HCENTER_WIDE); + } break; + case ANCHORS_AND_MARGINS_PRESET_WIDE: { + _set_anchors_and_margins_preset(Control::PRESET_WIDE); + } break; + + case ANCHORS_PRESET_TOP_LEFT: { _set_anchors_preset(PRESET_TOP_LEFT); } break; - case ANCHOR_ALIGN_TOP_RIGHT: { + case ANCHORS_PRESET_TOP_RIGHT: { _set_anchors_preset(PRESET_TOP_RIGHT); } break; - case ANCHOR_ALIGN_BOTTOM_LEFT: { + case ANCHORS_PRESET_BOTTOM_LEFT: { _set_anchors_preset(PRESET_BOTTOM_LEFT); } break; - case ANCHOR_ALIGN_BOTTOM_RIGHT: { + case ANCHORS_PRESET_BOTTOM_RIGHT: { _set_anchors_preset(PRESET_BOTTOM_RIGHT); } break; - case ANCHOR_ALIGN_CENTER_LEFT: { + case ANCHORS_PRESET_CENTER_LEFT: { _set_anchors_preset(PRESET_CENTER_LEFT); } break; - case ANCHOR_ALIGN_CENTER_RIGHT: { + case ANCHORS_PRESET_CENTER_RIGHT: { _set_anchors_preset(PRESET_CENTER_RIGHT); } break; - case ANCHOR_ALIGN_CENTER_TOP: { + case ANCHORS_PRESET_CENTER_TOP: { _set_anchors_preset(PRESET_CENTER_TOP); } break; - case ANCHOR_ALIGN_CENTER_BOTTOM: { + case ANCHORS_PRESET_CENTER_BOTTOM: { _set_anchors_preset(PRESET_CENTER_BOTTOM); } break; - case ANCHOR_ALIGN_CENTER: { + case ANCHORS_PRESET_CENTER: { _set_anchors_preset(PRESET_CENTER); } break; - case ANCHOR_ALIGN_TOP_WIDE: { + case ANCHORS_PRESET_TOP_WIDE: { _set_anchors_preset(PRESET_TOP_WIDE); } break; - case ANCHOR_ALIGN_LEFT_WIDE: { + case ANCHORS_PRESET_LEFT_WIDE: { _set_anchors_preset(PRESET_LEFT_WIDE); } break; - case ANCHOR_ALIGN_RIGHT_WIDE: { + case ANCHORS_PRESET_RIGHT_WIDE: { _set_anchors_preset(PRESET_RIGHT_WIDE); } break; - case ANCHOR_ALIGN_BOTTOM_WIDE: { + case ANCHORS_PRESET_BOTTOM_WIDE: { _set_anchors_preset(PRESET_BOTTOM_WIDE); } break; - case ANCHOR_ALIGN_VCENTER_WIDE: { + case ANCHORS_PRESET_VCENTER_WIDE: { _set_anchors_preset(PRESET_VCENTER_WIDE); } break; - case ANCHOR_ALIGN_HCENTER_WIDE: { + case ANCHORS_PRESET_HCENTER_WIDE: { _set_anchors_preset(PRESET_HCENTER_WIDE); } break; - case ANCHOR_ALIGN_WIDE: { + case ANCHORS_PRESET_WIDE: { _set_anchors_preset(Control::PRESET_WIDE); } break; - case ANCHOR_ALIGN_WIDE_FIT: { - _set_full_rect(); - } break; case ANIM_INSERT_KEY: case ANIM_INSERT_KEY_EXISTING: { @@ -3865,7 +3914,6 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p->add_separator(); p->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_set_ik_chain", TTR("Make IK Chain")), SKELETON_SET_IK_CHAIN); p->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_ik_chain", TTR("Clear IK Chain")), SKELETON_CLEAR_IK_CHAIN); - p->set_hide_on_checkable_item_selection(false); p->connect("id_pressed", this, "_popup_callback"); hb->add_child(memnew(VSeparator)); @@ -3883,13 +3931,18 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p->add_shortcut(ED_SHORTCUT("canvas_item_editor/center_selection", TTR("Center Selection"), KEY_F), VIEW_CENTER_TO_SELECTION); p->add_shortcut(ED_SHORTCUT("canvas_item_editor/frame_selection", TTR("Frame Selection"), KEY_MASK_SHIFT | KEY_F), VIEW_FRAME_TO_SELECTION); - anchor_menu = memnew(MenuButton); - anchor_menu->set_text(TTR("Anchor")); - hb->add_child(anchor_menu); - anchor_menu->get_popup()->connect("id_pressed", this, "_popup_callback"); - anchor_menu->hide(); + presets_menu = memnew(MenuButton); + presets_menu->set_text(TTR("Layout")); + hb->add_child(presets_menu); + presets_menu->hide(); + + p = presets_menu->get_popup(); + p->connect("id_pressed", this, "_popup_callback"); - //p = anchor_menu->get_popup(); + anchors_popup = memnew(PopupMenu); + p->add_child(anchors_popup); + anchors_popup->set_name("Anchors"); + anchors_popup->connect("id_pressed", this, "_popup_callback"); animation_hb = memnew(HBoxContainer); hb->add_child(animation_hb); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index f87bfef8ad..69dc25d180 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -98,23 +98,54 @@ class CanvasItemEditor : public VBoxContainer { UNLOCK_SELECTED, GROUP_SELECTED, UNGROUP_SELECTED, - ANCHOR_ALIGN_TOP_LEFT, - ANCHOR_ALIGN_TOP_RIGHT, - ANCHOR_ALIGN_BOTTOM_LEFT, - ANCHOR_ALIGN_BOTTOM_RIGHT, - ANCHOR_ALIGN_CENTER_LEFT, - ANCHOR_ALIGN_CENTER_RIGHT, - ANCHOR_ALIGN_CENTER_TOP, - ANCHOR_ALIGN_CENTER_BOTTOM, - ANCHOR_ALIGN_CENTER, - ANCHOR_ALIGN_TOP_WIDE, - ANCHOR_ALIGN_LEFT_WIDE, - ANCHOR_ALIGN_RIGHT_WIDE, - ANCHOR_ALIGN_BOTTOM_WIDE, - ANCHOR_ALIGN_VCENTER_WIDE, - ANCHOR_ALIGN_HCENTER_WIDE, - ANCHOR_ALIGN_WIDE, - ANCHOR_ALIGN_WIDE_FIT, + ANCHORS_AND_MARGINS_PRESET_TOP_LEFT, + ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT, + ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT, + ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT, + ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT, + ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT, + ANCHORS_AND_MARGINS_PRESET_CENTER_TOP, + ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM, + ANCHORS_AND_MARGINS_PRESET_CENTER, + ANCHORS_AND_MARGINS_PRESET_TOP_WIDE, + ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE, + ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE, + ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE, + ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE, + ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE, + ANCHORS_AND_MARGINS_PRESET_WIDE, + ANCHORS_PRESET_TOP_LEFT, + ANCHORS_PRESET_TOP_RIGHT, + ANCHORS_PRESET_BOTTOM_LEFT, + ANCHORS_PRESET_BOTTOM_RIGHT, + ANCHORS_PRESET_CENTER_LEFT, + ANCHORS_PRESET_CENTER_RIGHT, + ANCHORS_PRESET_CENTER_TOP, + ANCHORS_PRESET_CENTER_BOTTOM, + ANCHORS_PRESET_CENTER, + ANCHORS_PRESET_TOP_WIDE, + ANCHORS_PRESET_LEFT_WIDE, + ANCHORS_PRESET_RIGHT_WIDE, + ANCHORS_PRESET_BOTTOM_WIDE, + ANCHORS_PRESET_VCENTER_WIDE, + ANCHORS_PRESET_HCENTER_WIDE, + ANCHORS_PRESET_WIDE, + MARGINS_PRESET_TOP_LEFT, + MARGINS_PRESET_TOP_RIGHT, + MARGINS_PRESET_BOTTOM_LEFT, + MARGINS_PRESET_BOTTOM_RIGHT, + MARGINS_PRESET_CENTER_LEFT, + MARGINS_PRESET_CENTER_RIGHT, + MARGINS_PRESET_CENTER_TOP, + MARGINS_PRESET_CENTER_BOTTOM, + MARGINS_PRESET_CENTER, + MARGINS_PRESET_TOP_WIDE, + MARGINS_PRESET_LEFT_WIDE, + MARGINS_PRESET_RIGHT_WIDE, + MARGINS_PRESET_BOTTOM_WIDE, + MARGINS_PRESET_VCENTER_WIDE, + MARGINS_PRESET_HCENTER_WIDE, + MARGINS_PRESET_WIDE, ANIM_INSERT_KEY, ANIM_INSERT_KEY_EXISTING, ANIM_INSERT_POS, @@ -279,7 +310,10 @@ class CanvasItemEditor : public VBoxContainer { MenuButton *view_menu; HBoxContainer *animation_hb; MenuButton *animation_menu; - MenuButton *anchor_menu; + + MenuButton *presets_menu; + PopupMenu *anchors_and_margins_popup; + PopupMenu *anchors_popup; Button *key_loc_button; Button *key_rot_button; @@ -386,7 +420,8 @@ class CanvasItemEditor : public VBoxContainer { void _snap_other_nodes(Point2 p_value, Point2 &r_current_snap, bool (&r_snapped)[2], const Node *p_current, const CanvasItem *p_to_snap); void _set_anchors_preset(Control::LayoutPreset p_preset); - void _set_full_rect(); + void _set_margins_preset(Control::LayoutPreset p_preset); + void _set_anchors_and_margins_preset(Control::LayoutPreset p_preset); void _zoom_on_position(float p_zoom, Point2 p_position = Point2()); void _zoom_minus(); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 425390723c..32973db6ec 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -1442,6 +1442,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { case TRANSFORM_ROTATE: { Plane plane; + Vector3 axis; switch (_edit.plane) { case TRANSFORM_VIEW: @@ -1449,12 +1450,15 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { break; case TRANSFORM_X_AXIS: plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(0)); + axis = Vector3(1, 0, 0); break; case TRANSFORM_Y_AXIS: plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(1)); + axis = Vector3(0, 1, 0); break; case TRANSFORM_Z_AXIS: plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(2)); + axis = Vector3(0, 0, 1); break; } @@ -1470,6 +1474,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Vector3 x_axis = plane.normal.cross(y_axis).normalized(); float angle = Math::atan2(x_axis.dot(intersection - _edit.center), y_axis.dot(intersection - _edit.center)); + if (_edit.snap || spatial_editor->is_snap_enabled()) { float snap = spatial_editor->get_rotate_snap(); @@ -1486,11 +1491,10 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { set_message(vformat(TTR("Rotating %s degrees."), rtos(Math::rad2deg(angle)))); } - Transform r; - r.basis.rotate(plane.normal, angle); - List<Node *> &selection = editor_selection->get_selected_node_list(); + bool local_coords = spatial_editor->are_local_coords_enabled(); + for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { Spatial *sp = Object::cast_to<Spatial>(E->get()); @@ -1501,27 +1505,33 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (!se) continue; - Transform original = se->original; + Transform t; - Transform base = Transform(Basis(), _edit.center); - Transform t = base * r * base.inverse() * original; + if (local_coords) { - sp->set_global_transform(t); + Transform original_local = se->original_local; + Basis rot = Basis(axis, angle); + + t.basis = original_local.get_basis() * rot; + t.origin = original_local.origin; + + sp->set_transform(t); + + } else { + + Transform original = se->original; + Transform r; + Transform base = Transform(Basis(), _edit.center); + + r.basis.rotate(plane.normal, angle); + t = base * r * base.inverse() * original; + + sp->set_global_transform(t); + } } surface->update(); - /* - VisualServer::get_singleton()->poly_clear(indicators); - - Vector<Vector3> points; - Vector<Vector3> empty; - Vector<Color> colors; - points.push_back(intersection); - points.push_back(_edit.original.origin); - colors.push_back( Color(255,155,100) ); - colors.push_back( Color(255,155,100) ); - VisualServer::get_singleton()->poly_add_primitive(indicators,points,empty,colors,empty); - */ + } break; default: {} } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 1fb3fb2ed1..9f23df5c03 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1420,7 +1420,8 @@ ProjectManager::ProjectManager() { { int dpi_mode = EditorSettings::get_singleton()->get("interface/editor/hidpi_mode"); if (dpi_mode == 0) { - editor_set_scale(OS::get_singleton()->get_screen_dpi(0) >= 192 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x > 2000 ? 2.0 : 1.0); + const int screen = OS::get_singleton()->get_current_screen(); + editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0); } else if (dpi_mode == 1) { editor_set_scale(0.75); } else if (dpi_mode == 2) { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 47ebf49c43..658f67d6a4 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -861,7 +861,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: names.push_back(TTR("Assign")); names.push_back(TTR("Clear")); - if (owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && Object::cast_to<Node>(owner)->has_node(v)) + if (owner && owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && Object::cast_to<Node>(owner)->has_node(v)) names.push_back(TTR("Select Node")); config_action_buttons(names); |