Add simple spacebar panning setting for 2D editor

This commit is contained in:
Ricardo Maes 2017-10-09 21:30:13 -03:00 committed by Rémi Verschelde
parent ddc7793bba
commit 77f21b63e9
2 changed files with 12 additions and 1 deletions

View File

@ -424,6 +424,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("editors/2d/bone_ik_color", Color(0.9, 0.9, 0.45, 0.9));
_initial_set("editors/2d/keep_margins_when_changing_anchors", false);
_initial_set("editors/2d/warped_mouse_panning", true);
_initial_set("editors/2d/simple_spacebar_panning", false);
_initial_set("editors/2d/scroll_to_pan", false);
_initial_set("editors/2d/pan_speed", 20);

View File

@ -1858,7 +1858,17 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
}
if (drag == DRAG_NONE) {
if (((m->get_button_mask() & BUTTON_MASK_LEFT) && tool == TOOL_PAN) || (m->get_button_mask() & BUTTON_MASK_MIDDLE) || ((m->get_button_mask() & BUTTON_MASK_LEFT) && Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
bool space_pressed = Input::get_singleton()->is_key_pressed(KEY_SPACE);
bool simple_panning = EditorSettings::get_singleton()->get("editors/2d/simple_spacebar_panning");
int button = m->get_button_mask();
// Check if any of the panning triggers are activated
bool panning_tool = (button & BUTTON_MASK_LEFT) && tool == TOOL_PAN;
bool panning_middle_button = button & BUTTON_MASK_MIDDLE;
bool panning_spacebar = (button & BUTTON_MASK_LEFT) && space_pressed;
bool panning_spacebar_simple = space_pressed && simple_panning;
if (panning_tool || panning_middle_button || panning_spacebar || panning_spacebar_simple) {
// Pan the viewport
Point2i relative;
if (bool(EditorSettings::get_singleton()->get("editors/2d/warped_mouse_panning"))) {