Allow to change 2D pan hotkey

This commit is contained in:
Tomasz Chabora 2019-06-05 22:35:07 +02:00
parent 197b65f32a
commit f472f0491c
3 changed files with 13 additions and 4 deletions

View File

@ -569,7 +569,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("editors/2d/bone_outline_size", 2); _initial_set("editors/2d/bone_outline_size", 2);
_initial_set("editors/2d/viewport_border_color", Color(0.4, 0.4, 1.0, 0.4)); _initial_set("editors/2d/viewport_border_color", Color(0.4, 0.4, 1.0, 0.4));
_initial_set("editors/2d/warped_mouse_panning", true); _initial_set("editors/2d/warped_mouse_panning", true);
_initial_set("editors/2d/simple_spacebar_panning", false); _initial_set("editors/2d/simple_panning", false);
_initial_set("editors/2d/scroll_to_pan", false); _initial_set("editors/2d/scroll_to_pan", false);
_initial_set("editors/2d/pan_speed", 20); _initial_set("editors/2d/pan_speed", 20);

View File

@ -1081,7 +1081,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
if (b->is_pressed() && if (b->is_pressed() &&
(b->get_button_index() == BUTTON_MIDDLE || (b->get_button_index() == BUTTON_MIDDLE ||
(b->get_button_index() == BUTTON_LEFT && tool == TOOL_PAN) || (b->get_button_index() == BUTTON_LEFT && tool == TOOL_PAN) ||
(b->get_button_index() == BUTTON_LEFT && !EditorSettings::get_singleton()->get("editors/2d/simple_spacebar_panning") && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) { (b->get_button_index() == BUTTON_LEFT && !EditorSettings::get_singleton()->get("editors/2d/simple_panning") && pan_pressed))) {
// Pan the viewport // Pan the viewport
panning = true; panning = true;
} }
@ -1097,7 +1097,9 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event; Ref<InputEventKey> k = p_event;
if (k.is_valid()) { if (k.is_valid()) {
if (k->get_scancode() == KEY_SPACE && (EditorSettings::get_singleton()->get("editors/2d/simple_spacebar_panning") || drag_type != DRAG_NONE)) { bool is_pan_key = pan_view_shortcut.is_valid() && pan_view_shortcut->is_shortcut(p_event);
if (is_pan_key && (EditorSettings::get_singleton()->get("editors/2d/simple_panning") || drag_type != DRAG_NONE)) {
if (!panning) { if (!panning) {
if (k->is_pressed() && !k->is_echo()) { if (k->is_pressed() && !k->is_echo()) {
//Pan the viewport //Pan the viewport
@ -1110,6 +1112,9 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event) {
} }
} }
} }
if (is_pan_key)
pan_pressed = k->is_pressed();
} }
Ref<InputEventMouseMotion> m = p_event; Ref<InputEventMouseMotion> m = p_event;
@ -2214,7 +2219,7 @@ bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) {
void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
bool accepted = false; bool accepted = false;
if (EditorSettings::get_singleton()->get("editors/2d/simple_spacebar_panning") || !Input::get_singleton()->is_key_pressed(KEY_SPACE)) { if (EditorSettings::get_singleton()->get("editors/2d/simple_panning") || !pan_pressed) {
if ((accepted = _gui_input_rulers_and_guides(p_event))) { if ((accepted = _gui_input_rulers_and_guides(p_event))) {
//printf("Rulers and guides\n"); //printf("Rulers and guides\n");
} else if ((accepted = editor->get_editor_plugins_over()->forward_gui_input(p_event))) { } else if ((accepted = editor->get_editor_plugins_over()->forward_gui_input(p_event))) {
@ -4780,6 +4785,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
dragged_guide_pos = Point2(); dragged_guide_pos = Point2();
dragged_guide_index = -1; dragged_guide_index = -1;
panning = false; panning = false;
pan_pressed = false;
bone_last_frame = 0; bone_last_frame = 0;
@ -5129,6 +5135,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
multiply_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/multiply_grid_step", TTR("Multiply grid step by 2"), KEY_KP_MULTIPLY); multiply_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/multiply_grid_step", TTR("Multiply grid step by 2"), KEY_KP_MULTIPLY);
divide_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/divide_grid_step", TTR("Divide grid step by 2"), KEY_KP_DIVIDE); divide_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/divide_grid_step", TTR("Divide grid step by 2"), KEY_KP_DIVIDE);
pan_view_shortcut = ED_SHORTCUT("canvas_item_editor/pan_view", TTR("Pan View"), KEY_SPACE);
skeleton_menu->get_popup()->set_item_checked(skeleton_menu->get_popup()->get_item_index(SKELETON_SHOW_BONES), true); skeleton_menu->get_popup()->set_item_checked(skeleton_menu->get_popup()->get_item_index(SKELETON_SHOW_BONES), true);
singleton = this; singleton = this;

View File

@ -265,6 +265,7 @@ private:
bool key_rot; bool key_rot;
bool key_scale; bool key_scale;
bool panning; bool panning;
bool pan_pressed;
MenuOption last_option; MenuOption last_option;
@ -383,6 +384,7 @@ private:
Ref<ShortCut> set_pivot_shortcut; Ref<ShortCut> set_pivot_shortcut;
Ref<ShortCut> multiply_grid_step_shortcut; Ref<ShortCut> multiply_grid_step_shortcut;
Ref<ShortCut> divide_grid_step_shortcut; Ref<ShortCut> divide_grid_step_shortcut;
Ref<ShortCut> pan_view_shortcut;
bool _is_node_locked(const Node *p_node); bool _is_node_locked(const Node *p_node);
bool _is_node_movable(const Node *p_node, bool p_popup_warning = false); bool _is_node_movable(const Node *p_node, bool p_popup_warning = false);