Merge pull request #368 from marynate/PR-2d-editor-ux

Add pan mode to 2d editor
This commit is contained in:
reduz 2014-05-20 22:55:22 -03:00
commit 27ee218e3d
3 changed files with 15 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -54,7 +54,7 @@ void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) {
void CanvasItemEditor::_tool_select(int p_index) { 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;i<TOOL_MAX;i++) { for(int i=0;i<TOOL_MAX;i++) {
tb[i]->set_pressed(i==p_index); tb[i]->set_pressed(i==p_index);
@ -665,7 +665,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
//if (!canvas_items.size()) //if (!canvas_items.size())
// return; // 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; return;
if (!b.pressed) { if (!b.pressed) {
@ -962,7 +962,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) {
if (drag==DRAG_NONE) { 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); h_scroll->set_val( h_scroll->get_val() - m.relative_x/zoom);
v_scroll->set_val( v_scroll->get_val() - m.relative_y/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")); select_button->set_icon( get_icon("ToolSelect","EditorIcons"));
move_button->set_icon( get_icon("ToolMove","EditorIcons")); move_button->set_icon( get_icon("ToolMove","EditorIcons"));
rotate_button->set_icon( get_icon("ToolRotate","EditorIcons")); rotate_button->set_icon( get_icon("ToolRotate","EditorIcons"));
pan_button->set_icon( get_icon("ToolPan", "EditorIcons"));
select_handle=get_icon("EditorHandle","EditorIcons"); select_handle=get_icon("EditorHandle","EditorIcons");
lock_button->set_icon(get_icon("Lock","EditorIcons")); lock_button->set_icon(get_icon("Lock","EditorIcons"));
unlock_button->set_icon(get_icon("Unlock","EditorIcons")); unlock_button->set_icon(get_icon("Unlock","EditorIcons"));
@ -2218,6 +2219,14 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
hb->add_child(memnew(VSeparator)); 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 ); lock_button = memnew( ToolButton );
hb->add_child(lock_button); hb->add_child(lock_button);

View file

@ -69,6 +69,7 @@ class CanvasItemEditor : public VBoxContainer {
TOOL_SELECT, TOOL_SELECT,
TOOL_MOVE, TOOL_MOVE,
TOOL_ROTATE, TOOL_ROTATE,
TOOL_PAN,
TOOL_MAX TOOL_MAX
}; };
@ -178,6 +179,8 @@ class CanvasItemEditor : public VBoxContainer {
ToolButton *move_button; ToolButton *move_button;
ToolButton *rotate_button; ToolButton *rotate_button;
ToolButton *pan_button;
ToolButton *lock_button; ToolButton *lock_button;
ToolButton *unlock_button; ToolButton *unlock_button;