Add settings to pan canvas item editor instead of zoom with mouse/touchpad scrolling.
This feature is mainly designed for developers who uses touchpad instead of mouse, and want to scroll instead of zoom. Every macOS developers will like it since it feels intuitive. 2 new settings are added to `2d_editor`: 1. `scroll_to_pan`: turn on to use mouse/touchpad scroll to pan canvas item editor view instead of zoom 2. `pan_speed`: use this value to change scroll speed
This commit is contained in:
parent
29c7118f32
commit
e3f10f3e93
2 changed files with 65 additions and 18 deletions
|
@ -596,6 +596,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
||||||
set("2d_editor/keep_margins_when_changing_anchors", false);
|
set("2d_editor/keep_margins_when_changing_anchors", false);
|
||||||
|
|
||||||
set("2d_editor/warped_mouse_panning", true);
|
set("2d_editor/warped_mouse_panning", true);
|
||||||
|
set("2d_editor/scroll_to_pan", false);
|
||||||
|
set("2d_editor/pan_speed", 20);
|
||||||
|
|
||||||
set("game_window_placement/rect", 0);
|
set("game_window_placement/rect", 0);
|
||||||
hints["game_window_placement/rect"] = PropertyInfo(Variant::INT, "game_window_placement/rect", PROPERTY_HINT_ENUM, "Default,Centered,Custom Position,Force Maximized,Force Full Screen");
|
hints["game_window_placement/rect"] = PropertyInfo(Variant::INT, "game_window_placement/rect", PROPERTY_HINT_ENUM, "Default,Centered,Custom Position,Force Maximized,Force Full Screen");
|
||||||
|
|
|
@ -1037,6 +1037,13 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
|
||||||
|
|
||||||
if (b.button_index == BUTTON_WHEEL_DOWN) {
|
if (b.button_index == BUTTON_WHEEL_DOWN) {
|
||||||
|
|
||||||
|
if (bool(EditorSettings::get_singleton()->get("2d_editor/scroll_to_pan"))) {
|
||||||
|
|
||||||
|
v_scroll->set_val(v_scroll->get_val() + int(EditorSettings::get_singleton()->get("2d_editor/pan_speed")) / zoom * b.factor);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
if (zoom < MIN_ZOOM)
|
if (zoom < MIN_ZOOM)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1048,6 +1055,9 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
|
||||||
h_scroll->set_val(h_scroll->get_val() + ofs.x);
|
h_scroll->set_val(h_scroll->get_val() + ofs.x);
|
||||||
v_scroll->set_val(v_scroll->get_val() + ofs.y);
|
v_scroll->set_val(v_scroll->get_val() + ofs.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
_update_scroll(0);
|
_update_scroll(0);
|
||||||
viewport->update();
|
viewport->update();
|
||||||
return;
|
return;
|
||||||
|
@ -1055,6 +1065,13 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
|
||||||
|
|
||||||
if (b.button_index == BUTTON_WHEEL_UP) {
|
if (b.button_index == BUTTON_WHEEL_UP) {
|
||||||
|
|
||||||
|
if (bool(EditorSettings::get_singleton()->get("2d_editor/scroll_to_pan"))) {
|
||||||
|
|
||||||
|
v_scroll->set_val(v_scroll->get_val() - int(EditorSettings::get_singleton()->get("2d_editor/pan_speed")) / zoom * b.factor);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
if (zoom > MAX_ZOOM)
|
if (zoom > MAX_ZOOM)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1067,11 +1084,39 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
|
||||||
v_scroll->set_val(v_scroll->get_val() + ofs.y);
|
v_scroll->set_val(v_scroll->get_val() + ofs.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
_update_scroll(0);
|
_update_scroll(0);
|
||||||
viewport->update();
|
viewport->update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (b.button_index == BUTTON_WHEEL_LEFT) {
|
||||||
|
|
||||||
|
if (bool(EditorSettings::get_singleton()->get("2d_editor/scroll_to_pan"))) {
|
||||||
|
|
||||||
|
h_scroll->set_val(h_scroll->get_val() - int(EditorSettings::get_singleton()->get("2d_editor/pan_speed")) / zoom * b.factor);
|
||||||
|
|
||||||
|
_update_scroll(0);
|
||||||
|
viewport->update();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.button_index == BUTTON_WHEEL_RIGHT) {
|
||||||
|
|
||||||
|
if (bool(EditorSettings::get_singleton()->get("2d_editor/scroll_to_pan"))) {
|
||||||
|
|
||||||
|
h_scroll->set_val(h_scroll->get_val() + int(EditorSettings::get_singleton()->get("2d_editor/pan_speed")) / zoom * b.factor);
|
||||||
|
|
||||||
|
_update_scroll(0);
|
||||||
|
viewport->update();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (b.button_index == BUTTON_RIGHT) {
|
if (b.button_index == BUTTON_RIGHT) {
|
||||||
|
|
||||||
if (b.pressed && (tool == TOOL_SELECT && b.mod.alt)) {
|
if (b.pressed && (tool == TOOL_SELECT && b.mod.alt)) {
|
||||||
|
|
Loading…
Reference in a new issue