From 8be3963aa01ea84cdef6878e5865d5a720ab077b Mon Sep 17 00:00:00 2001 From: marynate Date: Fri, 2 May 2014 19:39:12 +0800 Subject: [PATCH] Add pan mode in 2d editor --- tools/editor/icons/icon_tool_pan.png | Bin 0 -> 1555 bytes .../editor/plugins/canvas_item_editor_plugin.cpp | 15 ++++++++++++--- tools/editor/plugins/canvas_item_editor_plugin.h | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 tools/editor/icons/icon_tool_pan.png diff --git a/tools/editor/icons/icon_tool_pan.png b/tools/editor/icons/icon_tool_pan.png new file mode 100644 index 0000000000000000000000000000000000000000..5c078a7b1cf033ae4fb93c0a35039daa3fa70d52 GIT binary patch literal 1555 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+nA0*tB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxSU1_g&``n5OwZ87 z)XdCKN5ROz&`93^h|F{iO{`4Ktc=VRpg;*|TTx1yRgjAt)Gi>;Rw<*Tq`*pFzr4I$ zuiRKKzbIYb(9+TpWQLKEE>MMTab;dfVufyAu`kBtHuNWFoz#!AFNG#Ad)HBe}%?0@jth%@)C>7xhtg4GcDhpEegHnt0 zON)|$@sXws(+mtd{1$-}0$pR}Uz7=ql*AmD{N&Qy)VvZ;7h5Huj9yA+ij}#Gv8#!t ziIc0Ti=nHrp`oLri?NfjfwQBzlZmU5r5nr)YNUr!*UGslHL)bWC?r2W2bKZ?GV)9Ei!<^I z6r6+26g0v!^HTE5i#0*f1M#g(YEfocYKmJ?ey##Ie62FE*l+Gi$lnmXDddEiKF~4x zpu~ZcSYSfH6bNF%lRl6G&pfGlz#LNq%o--!mtSFEU~=|!aSW-r6*75ucd(<#vFCny zd2s@t7$#~&+~DZi)?_BQZG(W0j@ZP%%v*$54?0bV=x%Ll?Jdho%*;+noE>|FJt}vr zg5pD`d+(?3&)*aN=)lRjGmG~fpEI*!_0>~3d~0pb8()humg~>neDjT$-t^ta?ig&} z_kR7f(@O(a9LsBBopb)VzrxKZ9WkXFYO5Gb>+K|X>bw*7#{EBhV+QX6k#hlGO04GE z1qnWMEq(g1Afok&%2v)?6`{`kd`I-c)?{v8$nq+D>#~FeGJ$~{4s|F0gzdj?-}GUh zY_Hq0+i$JdMb20p3-<`tV71_Q%6EuqfzZwXm4<8!+wRN3W@szU7wZcKWClI~0Gv+T6`>k7=K>_=gXX@If@J~sR)%QlhTIGOuAz!3)_!Hi%HMtTQHYuA5~Z`Ef&m}r{@r#$^xw1HX?9C2 z`709jQ~enlT}5_Ic@@V~wtazHE}v*|uDs$-IotRDIj+=R`x>?ZY4UGcYqGES!4ny5ItNP%-W4>gTe~DWM4fXQ(a~ literal 0 HcmV?d00001 diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 01ca5a1135c..880cc9c1471 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -54,7 +54,7 @@ void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) { void CanvasItemEditor::_tool_select(int p_index) { - ToolButton *tb[TOOL_MAX]={select_button,move_button,rotate_button}; + ToolButton *tb[TOOL_MAX]={select_button,move_button,rotate_button,pan_button}; for(int i=0;iset_pressed(i==p_index); @@ -665,7 +665,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { //if (!canvas_items.size()) // return; - if (b.button_index!=BUTTON_LEFT || Input::get_singleton()->is_key_pressed(KEY_SPACE)) + if (tool==TOOL_PAN || b.button_index!=BUTTON_LEFT || Input::get_singleton()->is_key_pressed(KEY_SPACE)) return; if (!b.pressed) { @@ -962,7 +962,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { if (drag==DRAG_NONE) { - if (m.button_mask&BUTTON_MASK_MIDDLE || (m.button_mask&BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE))) { + if ( (m.button_mask&BUTTON_MASK_LEFT && tool == TOOL_PAN) || m.button_mask&BUTTON_MASK_MIDDLE || (m.button_mask&BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE))) { h_scroll->set_val( h_scroll->get_val() - m.relative_x/zoom); v_scroll->set_val( v_scroll->get_val() - m.relative_y/zoom); @@ -1406,6 +1406,7 @@ void CanvasItemEditor::_notification(int p_what) { select_button->set_icon( get_icon("ToolSelect","EditorIcons")); move_button->set_icon( get_icon("ToolMove","EditorIcons")); rotate_button->set_icon( get_icon("ToolRotate","EditorIcons")); + pan_button->set_icon( get_icon("ToolPan", "EditorIcons")); select_handle=get_icon("EditorHandle","EditorIcons"); lock_button->set_icon(get_icon("Lock","EditorIcons")); unlock_button->set_icon(get_icon("Unlock","EditorIcons")); @@ -2218,6 +2219,14 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { hb->add_child(memnew(VSeparator)); + pan_button = memnew( ToolButton ); + pan_button->set_toggle_mode(true); + hb->add_child(pan_button); + pan_button->connect("pressed",this,"_tool_select",make_binds(TOOL_PAN)); + pan_button->set_tooltip("Pan Mode"); + + hb->add_child(memnew(VSeparator)); + lock_button = memnew( ToolButton ); hb->add_child(lock_button); diff --git a/tools/editor/plugins/canvas_item_editor_plugin.h b/tools/editor/plugins/canvas_item_editor_plugin.h index 256847e8ef0..3d9b50c01c7 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.h +++ b/tools/editor/plugins/canvas_item_editor_plugin.h @@ -69,6 +69,7 @@ class CanvasItemEditor : public VBoxContainer { TOOL_SELECT, TOOL_MOVE, TOOL_ROTATE, + TOOL_PAN, TOOL_MAX }; @@ -178,6 +179,8 @@ class CanvasItemEditor : public VBoxContainer { ToolButton *move_button; ToolButton *rotate_button; + ToolButton *pan_button; + ToolButton *lock_button; ToolButton *unlock_button;