diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-10-09 12:21:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-09 12:21:57 +0200 |
commit | 3151b08c48079aa3a78007a2807b3b0ab66e4b3b (patch) | |
tree | 4756c9389a1ace65fd8118748fa25848ad190b3b /editor/plugins | |
parent | e8b9cca6147e2ea1aa0f9091460755c1e5ede3d7 (diff) | |
parent | a25d70ab3196b0571808e56e44588d95c58fa7dc (diff) |
Merge pull request #11821 from groud/margins_preset_menu
Replaces (and extends) the anchor menu to a Layout one
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 263 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.h | 73 |
2 files changed, 212 insertions, 124 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 4f6c8f89ee..3fc251d092 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -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(); |