beautiful visual menu to change anchors
will you dare to try it? :) because, I'd check previous commit msgs if I were you..
BIN
tools/editor/icons/icon_anchor.png
Normal file
After Width: | Height: | Size: 428 B |
BIN
tools/editor/icons/icon_control_align_bottom_center.png
Normal file
After Width: | Height: | Size: 174 B |
BIN
tools/editor/icons/icon_control_align_bottom_left.png
Normal file
After Width: | Height: | Size: 172 B |
BIN
tools/editor/icons/icon_control_align_bottom_right.png
Normal file
After Width: | Height: | Size: 174 B |
BIN
tools/editor/icons/icon_control_align_bottom_wide.png
Normal file
After Width: | Height: | Size: 174 B |
BIN
tools/editor/icons/icon_control_align_center.png
Normal file
After Width: | Height: | Size: 181 B |
BIN
tools/editor/icons/icon_control_align_center_left.png
Normal file
After Width: | Height: | Size: 172 B |
BIN
tools/editor/icons/icon_control_align_center_right.png
Normal file
After Width: | Height: | Size: 171 B |
BIN
tools/editor/icons/icon_control_align_left_center.png
Normal file
After Width: | Height: | Size: 183 B |
BIN
tools/editor/icons/icon_control_align_left_wide.png
Normal file
After Width: | Height: | Size: 166 B |
BIN
tools/editor/icons/icon_control_align_right_center.png
Normal file
After Width: | Height: | Size: 181 B |
BIN
tools/editor/icons/icon_control_align_right_wide.png
Normal file
After Width: | Height: | Size: 167 B |
BIN
tools/editor/icons/icon_control_align_top_center.png
Normal file
After Width: | Height: | Size: 181 B |
BIN
tools/editor/icons/icon_control_align_top_left.png
Normal file
After Width: | Height: | Size: 176 B |
BIN
tools/editor/icons/icon_control_align_top_right.png
Normal file
After Width: | Height: | Size: 183 B |
BIN
tools/editor/icons/icon_control_align_top_wide.png
Normal file
After Width: | Height: | Size: 179 B |
BIN
tools/editor/icons/icon_control_align_wide.png
Normal file
After Width: | Height: | Size: 165 B |
BIN
tools/editor/icons/icon_control_hcenter_wide.png
Normal file
After Width: | Height: | Size: 182 B |
BIN
tools/editor/icons/icon_control_vcenter_wide.png
Normal file
After Width: | Height: | Size: 171 B |
|
@ -1910,12 +1910,20 @@ void CanvasItemEditor::_notification(int p_what) {
|
|||
|
||||
List<Node*> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
bool all_control=true;
|
||||
bool has_control=false;
|
||||
|
||||
for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
|
||||
|
||||
CanvasItem *canvas_item = E->get()->cast_to<CanvasItem>();
|
||||
if (!canvas_item || !canvas_item->is_visible())
|
||||
continue;
|
||||
|
||||
if (canvas_item->cast_to<Control>())
|
||||
has_control=true;
|
||||
else
|
||||
all_control=false;
|
||||
|
||||
CanvasItemEditorSelectedItem *se=editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
|
||||
if (!se)
|
||||
continue;
|
||||
|
@ -1932,6 +1940,13 @@ void CanvasItemEditor::_notification(int p_what) {
|
|||
|
||||
}
|
||||
|
||||
bool show_anchor = all_control && has_control;
|
||||
if (show_anchor != !anchor_menu->is_hidden()) {
|
||||
if (show_anchor)
|
||||
anchor_menu->show();
|
||||
else
|
||||
anchor_menu->hide();
|
||||
}
|
||||
|
||||
for(Map<ObjectID,BoneList>::Element *E=bone_list.front();E;E=E->next()) {
|
||||
|
||||
|
@ -1974,6 +1989,32 @@ 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->add_icon_override("Align Top Left");
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (p_what==NOTIFICATION_READY) {
|
||||
|
@ -2179,6 +2220,27 @@ void CanvasItemEditor::_update_scroll(float) {
|
|||
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_set_anchor(Control::AnchorType p_left,Control::AnchorType p_top,Control::AnchorType p_right,Control::AnchorType p_bottom) {
|
||||
List<Node*> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
undo_redo->create_action("Change Anchors");
|
||||
for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
|
||||
|
||||
Control *c = E->get()->cast_to<Control>();
|
||||
|
||||
undo_redo->add_do_method(c,"set_anchor",MARGIN_LEFT,p_left);
|
||||
undo_redo->add_do_method(c,"set_anchor",MARGIN_TOP,p_top);
|
||||
undo_redo->add_do_method(c,"set_anchor",MARGIN_RIGHT,p_right);
|
||||
undo_redo->add_do_method(c,"set_anchor",MARGIN_BOTTOM,p_bottom);
|
||||
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->commit_action();
|
||||
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_popup_callback(int p_op) {
|
||||
|
||||
|
@ -2381,6 +2443,56 @@ void CanvasItemEditor::_popup_callback(int p_op) {
|
|||
case SPACE_VERTICAL: {
|
||||
//space_selected_items< proj_vector2_y, compare_items_y >();
|
||||
} break;
|
||||
case ANCHOR_ALIGN_TOP_LEFT: {
|
||||
_set_anchor(ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_BEGIN);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_TOP_RIGHT: {
|
||||
_set_anchor(ANCHOR_END,ANCHOR_BEGIN,ANCHOR_END,ANCHOR_BEGIN);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_BOTTOM_LEFT: {
|
||||
_set_anchor(ANCHOR_BEGIN,ANCHOR_END,ANCHOR_BEGIN,ANCHOR_END);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_BOTTOM_RIGHT: {
|
||||
_set_anchor(ANCHOR_END,ANCHOR_END,ANCHOR_END,ANCHOR_END);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_CENTER_LEFT: {
|
||||
_set_anchor(ANCHOR_BEGIN,ANCHOR_CENTER,ANCHOR_BEGIN,ANCHOR_CENTER);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_CENTER_RIGHT: {
|
||||
|
||||
_set_anchor(ANCHOR_END,ANCHOR_CENTER,ANCHOR_END,ANCHOR_CENTER);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_CENTER_TOP: {
|
||||
_set_anchor(ANCHOR_CENTER,ANCHOR_BEGIN,ANCHOR_CENTER,ANCHOR_BEGIN);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_CENTER_BOTTOM: {
|
||||
_set_anchor(ANCHOR_CENTER,ANCHOR_END,ANCHOR_CENTER,ANCHOR_END);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_CENTER: {
|
||||
_set_anchor(ANCHOR_CENTER,ANCHOR_CENTER,ANCHOR_CENTER,ANCHOR_CENTER);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_TOP_WIDE: {
|
||||
_set_anchor(ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_END,ANCHOR_BEGIN);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_LEFT_WIDE: {
|
||||
_set_anchor(ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_END);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_RIGHT_WIDE: {
|
||||
_set_anchor(ANCHOR_END,ANCHOR_BEGIN,ANCHOR_END,ANCHOR_END);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_BOTTOM_WIDE: {
|
||||
_set_anchor(ANCHOR_BEGIN,ANCHOR_END,ANCHOR_END,ANCHOR_END);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_VCENTER_WIDE: {
|
||||
_set_anchor(ANCHOR_CENTER,ANCHOR_BEGIN,ANCHOR_CENTER,ANCHOR_END);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_HCENTER_WIDE: {
|
||||
_set_anchor(ANCHOR_BEGIN,ANCHOR_CENTER,ANCHOR_END,ANCHOR_CENTER);
|
||||
} break;
|
||||
case ANCHOR_ALIGN_WIDE: {
|
||||
_set_anchor(ANCHOR_BEGIN,ANCHOR_BEGIN,ANCHOR_END,ANCHOR_END);
|
||||
} break;
|
||||
|
||||
case ANIM_INSERT_KEY:
|
||||
case ANIM_INSERT_KEY_EXISTING: {
|
||||
|
||||
|
@ -2999,6 +3111,14 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
|
|||
p->add_item("Center Selection", VIEW_CENTER_TO_SELECTION, KEY_F);
|
||||
p->add_item("Frame Selection", VIEW_FRAME_TO_SELECTION, KEY_MASK_CMD|KEY_F);
|
||||
|
||||
anchor_menu = memnew( MenuButton );
|
||||
anchor_menu->set_text("Anchor");
|
||||
hb->add_child(anchor_menu);
|
||||
anchor_menu->get_popup()->connect("item_pressed", this,"_popup_callback");
|
||||
anchor_menu->hide();
|
||||
|
||||
//p = anchor_menu->get_popup();
|
||||
|
||||
|
||||
|
||||
animation_hb = memnew( HBoxContainer );
|
||||
|
|
|
@ -90,6 +90,23 @@ class CanvasItemEditor : public VBoxContainer {
|
|||
UNGROUP_SELECTED,
|
||||
ALIGN_HORIZONTAL,
|
||||
ALIGN_VERTICAL,
|
||||
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,
|
||||
|
||||
SPACE_HORIZONTAL,
|
||||
SPACE_VERTICAL,
|
||||
EXPAND_TO_PARENT,
|
||||
|
@ -225,6 +242,7 @@ class CanvasItemEditor : public VBoxContainer {
|
|||
MenuButton *view_menu;
|
||||
HBoxContainer *animation_hb;
|
||||
MenuButton *animation_menu;
|
||||
MenuButton *anchor_menu;
|
||||
|
||||
Button *key_loc_button;
|
||||
Button *key_rot_button;
|
||||
|
@ -305,6 +323,8 @@ class CanvasItemEditor : public VBoxContainer {
|
|||
void _viewport_input_event(const InputEvent& p_event);
|
||||
void _viewport_draw();
|
||||
|
||||
void _set_anchor(Control::AnchorType p_left,Control::AnchorType p_top,Control::AnchorType p_right,Control::AnchorType p_bottom);
|
||||
|
||||
HSplitContainer *palette_split;
|
||||
VSplitContainer *bottom_split;
|
||||
|
||||
|
|