summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
authormarynate <mary.w.nate@gmail.com>2014-05-02 19:39:12 +0800
committermarynate <mary.w.nate@gmail.com>2014-05-21 09:47:47 +0800
commit8be3963aa01ea84cdef6878e5865d5a720ab077b (patch)
tree8be7b06cf376871924924b735fa18ba985a97b20 /tools/editor
parenta364bc437138d359b3105a8370911f0aab2385db (diff)
Add pan mode in 2d editor
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/icons/icon_tool_pan.pngbin0 -> 1555 bytes
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp15
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.h3
3 files changed, 15 insertions, 3 deletions
diff --git a/tools/editor/icons/icon_tool_pan.png b/tools/editor/icons/icon_tool_pan.png
new file mode 100644
index 0000000000..5c078a7b1c
--- /dev/null
+++ b/tools/editor/icons/icon_tool_pan.png
Binary files differ
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index 01ca5a1135..880cc9c147 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;i<TOOL_MAX;i++) {
tb[i]->set_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 256847e8ef..3d9b50c01c 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;