made changing pivot simpler in 2D nodes (just press v with mouse over position)
This commit is contained in:
parent
4b35654a02
commit
8945670bc0
|
@ -149,11 +149,11 @@ void AnimatedSprite::_notification(int p_what) {
|
|||
|
||||
Size2i s;
|
||||
s = texture->get_size();
|
||||
Point2i ofs=offset;
|
||||
Point2 ofs=offset;
|
||||
if (centered)
|
||||
ofs-=s/2;
|
||||
|
||||
Rect2i dst_rect(ofs,s);
|
||||
Rect2 dst_rect(ofs,s);
|
||||
|
||||
if (hflip)
|
||||
dst_rect.size.x=-dst_rect.size.x;
|
||||
|
@ -284,7 +284,7 @@ Rect2 AnimatedSprite::get_item_rect() const {
|
|||
return Node2D::get_item_rect();
|
||||
Size2i s = t->get_size();
|
||||
|
||||
Point2i ofs=offset;
|
||||
Point2 ofs=offset;
|
||||
if (centered)
|
||||
ofs-=s/2;
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ void Sprite::_notification(int p_what) {
|
|||
|
||||
}
|
||||
|
||||
Point2i ofs=offset;
|
||||
Point2 ofs=offset;
|
||||
if (centered)
|
||||
ofs-=s/2;
|
||||
|
||||
|
@ -265,7 +265,7 @@ Rect2 Sprite::get_item_rect() const {
|
|||
s=s/Point2(hframes,vframes);
|
||||
}
|
||||
|
||||
Point2i ofs=offset;
|
||||
Point2 ofs=offset;
|
||||
if (centered)
|
||||
ofs-=s/2;
|
||||
|
||||
|
@ -413,11 +413,11 @@ void ViewportSprite::_notification(int p_what) {
|
|||
|
||||
src_rect.size=s;
|
||||
|
||||
Point2i ofs=offset;
|
||||
Point2 ofs=offset;
|
||||
if (centered)
|
||||
ofs-=s/2;
|
||||
|
||||
Rect2i dst_rect(ofs,s);
|
||||
Rect2 dst_rect(ofs,s);
|
||||
texture->draw_rect_region(ci,dst_rect,src_rect,modulate);
|
||||
|
||||
} break;
|
||||
|
@ -505,7 +505,7 @@ Rect2 ViewportSprite::get_item_rect() const {
|
|||
Size2i s;
|
||||
|
||||
s = texture->get_size();
|
||||
Point2i ofs=offset;
|
||||
Point2 ofs=offset;
|
||||
if (centered)
|
||||
ofs-=s/2;
|
||||
|
||||
|
|
|
@ -1108,6 +1108,9 @@ void SceneTree::_bind_methods() {
|
|||
ADD_SIGNAL( MethodInfo("node_removed",PropertyInfo( Variant::OBJECT, "node") ) );
|
||||
ADD_SIGNAL( MethodInfo("screen_resized") );
|
||||
|
||||
ADD_SIGNAL( MethodInfo("idle_frame"));
|
||||
ADD_SIGNAL( MethodInfo("fixed_frame"));
|
||||
|
||||
BIND_CONSTANT( GROUP_CALL_DEFAULT );
|
||||
BIND_CONSTANT( GROUP_CALL_REVERSE );
|
||||
BIND_CONSTANT( GROUP_CALL_REALTIME );
|
||||
|
@ -1166,8 +1169,7 @@ SceneTree::SceneTree() {
|
|||
edited_scene_root=NULL;
|
||||
#endif
|
||||
|
||||
ADD_SIGNAL( MethodInfo("idle_frame"));
|
||||
ADD_SIGNAL( MethodInfo("fixed_frame"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -150,8 +150,46 @@ void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) {
|
|||
_tool_select(TOOL_MOVE);
|
||||
if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_E)
|
||||
_tool_select(TOOL_ROTATE);
|
||||
if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_V && drag==DRAG_ALL && can_move_pivot)
|
||||
drag=DRAG_PIVOT;
|
||||
if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_V && drag==DRAG_NONE && can_move_pivot) {
|
||||
if (p_ev.key.mod.shift) {
|
||||
//move drag pivot
|
||||
drag=DRAG_PIVOT;
|
||||
} else if (!Input::get_singleton()->is_mouse_button_pressed(0)) {
|
||||
|
||||
List<Node*> &selection = editor_selection->get_selected_node_list();
|
||||
|
||||
Vector2 mouse_pos = viewport->get_local_mouse_pos();
|
||||
if (selection.size() && viewport->get_rect().has_point(mouse_pos)) {
|
||||
//just in case, make it work if over viewport
|
||||
mouse_pos=transform.affine_inverse().xform(mouse_pos);
|
||||
mouse_pos=snap_point(mouse_pos);
|
||||
|
||||
undo_redo->create_action("Move Pivot");
|
||||
|
||||
for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
|
||||
|
||||
Node2D *n2d = E->get()->cast_to<Node2D>();
|
||||
|
||||
if (n2d && n2d->edit_has_pivot()) {
|
||||
|
||||
Vector2 offset = n2d->edit_get_pivot();
|
||||
Vector2 gpos = n2d->get_global_pos();
|
||||
|
||||
|
||||
undo_redo->add_do_method(n2d,"set_global_pos",mouse_pos);
|
||||
undo_redo->add_do_method(n2d,"edit_set_pivot",offset+(gpos-mouse_pos));
|
||||
undo_redo->add_undo_method(n2d,"set_global_pos",gpos);
|
||||
undo_redo->add_undo_method(n2d,"edit_set_pivot",offset);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1685,7 +1723,7 @@ void CanvasItemEditor::_viewport_draw() {
|
|||
viewport->draw_line(endpoints[i],endpoints[(i+1)%4],c,2);
|
||||
}
|
||||
|
||||
if (single && (tool==TOOL_SELECT || tool == TOOL_MOVE)) { //kind of sucks
|
||||
if (single && (tool==TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_ROTATE)) { //kind of sucks
|
||||
|
||||
if (canvas_item->cast_to<Node2D>()) {
|
||||
|
||||
|
@ -2854,7 +2892,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
|
|||
hb->add_child(select_button);
|
||||
select_button->connect("pressed",this,"_tool_select",make_binds(TOOL_SELECT));
|
||||
select_button->set_pressed(true);
|
||||
select_button->set_tooltip("Select Mode (Q)\n"+keycode_get_string(KEY_MASK_CMD)+"Drag: Rotate\nAlt+Drag: Move\nPress 'v' to Move Pivot (while moving)");
|
||||
select_button->set_tooltip("Select Mode (Q)\n"+keycode_get_string(KEY_MASK_CMD)+"Drag: Rotate\nAlt+Drag: Move\nPress 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).");
|
||||
|
||||
move_button = memnew( ToolButton );
|
||||
move_button->set_toggle_mode(true);
|
||||
|
|
Loading…
Reference in New Issue