Skip to content

Commit bd47e4f

Browse files
Add Tablet/Trackpad nav preset
This commit adds a new navigation preset called `Tablet/Trackpad` which enables "Emulate 3 Button Mouse" to more quickly set up good default keys for tablet users. It also adds support for mouse buttons 4 and 5 in the navigation settings which will be helpful if users want to customize 3D navigation further for specific pens/mice.
1 parent 1f47e4c commit bd47e4f

5 files changed

+49
-12
lines changed

doc/classes/EditorSettings.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,13 @@
360360
If [code]true[/code], invert the vertical mouse axis when panning, orbiting, or using freelook mode in the 3D editor.
361361
</member>
362362
<member name="editors/3d/navigation/navigation_scheme" type="int" setter="" getter="">
363-
The navigation scheme preset to use in the 3D editor. Changing this setting will affect the mouse button and modifier controls used to navigate the 3D editor viewport.
363+
The navigation scheme preset to use in the 3D editor. Changing this setting will affect the mouse button and modifier keys used to navigate the 3D editor viewport.
364364
All schemes can use [kbd]Mouse wheel[/kbd] to zoom.
365365
- [b]Godot:[/b] [kbd]Middle mouse button[/kbd] to orbit. [kbd]Shift + Middle mouse button[/kbd] to pan. [kbd]Ctrl + Middle mouse button[/kbd] to zoom.
366366
- [b]Maya:[/b] [kbd]Alt + Left mouse button[/kbd] to orbit. [kbd]Middle mouse button[/kbd] to pan, [kbd]Shift + Middle mouse button[/kbd] to pan 10 times faster. [kbd]Alt + Right mouse button[/kbd] to zoom.
367367
- [b]Modo:[/b] [kbd]Alt + Left mouse button[/kbd] to orbit. [kbd]Alt + Shift + Left mouse button[/kbd] to pan. [kbd]Ctrl + Alt + Left mouse button[/kbd] to zoom.
368-
See also [member editors/3d/navigation/orbit_mouse_button], [member editors/3d/navigation/pan_mouse_button], [member editors/3d/navigation/zoom_mouse_button], and [member editors/3d/freelook/freelook_navigation_scheme].
368+
- [b]Tablet/Trackpad:[/b] [kbd]Alt[/kbd] to orbit. [kbd]Shift[/kbd] to pan. [kbd]Ctrl[/kbd] to zoom. Enables 3-button mouse emulation mode.
369+
See also [member editors/3d/navigation/orbit_mouse_button], [member editors/3d/navigation/pan_mouse_button], [member editors/3d/navigation/zoom_mouse_button], [member editors/3d/freelook/freelook_navigation_scheme], and [member editors/3d/navigation/emulate_3_button_mouse].
369370
[b]Note:[/b] On certain window managers on Linux, the [kbd]Alt[/kbd] key will be intercepted by the window manager when clicking a mouse button at the same time. This means Godot will not see the modifier key as being pressed.
370371
</member>
371372
<member name="editors/3d/navigation/orbit_mouse_button" type="int" setter="" getter="">

editor/editor_settings.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
816816
// 3D: Navigation
817817
_initial_set("editors/3d/navigation/invert_x_axis", false, true);
818818
_initial_set("editors/3d/navigation/invert_y_axis", false, true);
819-
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/navigation_scheme", 0, "Godot,Maya,Modo,Custom")
820-
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/orbit_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse")
821-
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/pan_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse")
822-
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/zoom_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse")
819+
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/navigation_scheme", 0, "Godot:0,Maya:1,Modo:2,Tablet/Trackpad:4,Custom:3")
820+
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/orbit_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse,Mouse Button 4,Mouse Button 5")
821+
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/pan_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse,Mouse Button 4,Mouse Button 5")
822+
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/zoom_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse,Mouse Button 4,Mouse Button 5")
823823
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/zoom_style", 0, "Vertical,Horizontal")
824824

825825
_initial_set("editors/3d/navigation/emulate_numpad", false, true);

editor/editor_settings_dialog.cpp

+23-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void EditorSettingsDialog::_settings_property_edited(const String &p_name) {
7777
EditorSettings::get_singleton()->set_manually("text_editor/theme/color_theme", "Custom");
7878
} else if (full_name.begins_with("editors/visual_editors/connection_colors") || full_name.begins_with("editors/visual_editors/category_colors")) {
7979
EditorSettings::get_singleton()->set_manually("editors/visual_editors/color_theme", "Custom");
80-
} else if (full_name == "editors/3d/navigation/orbit_mouse_button" || full_name == "editors/3d/navigation/pan_mouse_button" || full_name == "editors/3d/navigation/zoom_mouse_button") {
80+
} else if (full_name == "editors/3d/navigation/orbit_mouse_button" || full_name == "editors/3d/navigation/pan_mouse_button" || full_name == "editors/3d/navigation/zoom_mouse_button" || full_name == "editors/3d/navigation/emulate_3_button_mouse") {
8181
EditorSettings::get_singleton()->set_manually("editors/3d/navigation/navigation_scheme", (int)Node3DEditorViewport::NAVIGATION_CUSTOM);
8282
} else if (full_name == "editors/3d/navigation/navigation_scheme") {
8383
update_navigation_preset();
@@ -89,6 +89,7 @@ void EditorSettingsDialog::update_navigation_preset() {
8989
Node3DEditorViewport::ViewportNavMouseButton set_orbit_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
9090
Node3DEditorViewport::ViewportNavMouseButton set_pan_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
9191
Node3DEditorViewport::ViewportNavMouseButton set_zoom_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
92+
bool set_3_button_mouse = false;
9293
Ref<InputEventKey> orbit_mod_key_1;
9394
Ref<InputEventKey> orbit_mod_key_2;
9495
Ref<InputEventKey> pan_mod_key_1;
@@ -102,6 +103,7 @@ void EditorSettingsDialog::update_navigation_preset() {
102103
set_orbit_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
103104
set_pan_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
104105
set_zoom_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
106+
set_3_button_mouse = false;
105107
orbit_mod_key_1 = InputEventKey::create_reference(Key::NONE);
106108
orbit_mod_key_2 = InputEventKey::create_reference(Key::NONE);
107109
pan_mod_key_1 = InputEventKey::create_reference(Key::SHIFT);
@@ -113,6 +115,7 @@ void EditorSettingsDialog::update_navigation_preset() {
113115
set_orbit_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
114116
set_pan_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
115117
set_zoom_mouse_button = Node3DEditorViewport::NAVIGATION_RIGHT_MOUSE;
118+
set_3_button_mouse = false;
116119
orbit_mod_key_1 = InputEventKey::create_reference(Key::ALT);
117120
orbit_mod_key_2 = InputEventKey::create_reference(Key::NONE);
118121
pan_mod_key_1 = InputEventKey::create_reference(Key::NONE);
@@ -124,18 +127,32 @@ void EditorSettingsDialog::update_navigation_preset() {
124127
set_orbit_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
125128
set_pan_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
126129
set_zoom_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
130+
set_3_button_mouse = false;
127131
orbit_mod_key_1 = InputEventKey::create_reference(Key::ALT);
128132
orbit_mod_key_2 = InputEventKey::create_reference(Key::NONE);
129133
pan_mod_key_1 = InputEventKey::create_reference(Key::SHIFT);
130134
pan_mod_key_2 = InputEventKey::create_reference(Key::ALT);
131135
zoom_mod_key_1 = InputEventKey::create_reference(Key::ALT);
132136
zoom_mod_key_2 = InputEventKey::create_reference(Key::CTRL);
137+
} else if (nav_scheme == Node3DEditorViewport::NAVIGATION_TABLET) {
138+
set_preset = true;
139+
set_orbit_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
140+
set_pan_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
141+
set_zoom_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
142+
set_3_button_mouse = true;
143+
orbit_mod_key_1 = InputEventKey::create_reference(Key::ALT);
144+
orbit_mod_key_2 = InputEventKey::create_reference(Key::NONE);
145+
pan_mod_key_1 = InputEventKey::create_reference(Key::SHIFT);
146+
pan_mod_key_2 = InputEventKey::create_reference(Key::NONE);
147+
zoom_mod_key_1 = InputEventKey::create_reference(Key::CTRL);
148+
zoom_mod_key_2 = InputEventKey::create_reference(Key::NONE);
133149
}
134150
// Set settings to the desired preset values.
135151
if (set_preset) {
136152
EditorSettings::get_singleton()->set_manually("editors/3d/navigation/orbit_mouse_button", (int)set_orbit_mouse_button);
137153
EditorSettings::get_singleton()->set_manually("editors/3d/navigation/pan_mouse_button", (int)set_pan_mouse_button);
138154
EditorSettings::get_singleton()->set_manually("editors/3d/navigation/zoom_mouse_button", (int)set_zoom_mouse_button);
155+
EditorSettings::get_singleton()->set_manually("editors/3d/navigation/emulate_3_button_mouse", set_3_button_mouse);
139156
_set_shortcut_input("spatial_editor/viewport_orbit_modifier_1", orbit_mod_key_1);
140157
_set_shortcut_input("spatial_editor/viewport_orbit_modifier_2", orbit_mod_key_2);
141158
_set_shortcut_input("spatial_editor/viewport_pan_modifier_1", pan_mod_key_1);
@@ -775,7 +792,11 @@ PropertyInfo EditorSettingsDialog::_create_mouse_shortcut_property_info(const St
775792
hint_string += _get_shortcut_button_string(p_shortcut_1_name) + _get_shortcut_button_string(p_shortcut_2_name);
776793
hint_string += "Middle Mouse,";
777794
hint_string += _get_shortcut_button_string(p_shortcut_1_name) + _get_shortcut_button_string(p_shortcut_2_name);
778-
hint_string += "Right Mouse";
795+
hint_string += "Right Mouse,";
796+
hint_string += _get_shortcut_button_string(p_shortcut_1_name) + _get_shortcut_button_string(p_shortcut_2_name);
797+
hint_string += "Mouse Button 4,";
798+
hint_string += _get_shortcut_button_string(p_shortcut_1_name) + _get_shortcut_button_string(p_shortcut_2_name);
799+
hint_string += "Mouse Button 5";
779800

780801
return PropertyInfo(Variant::INT, p_property_name, PROPERTY_HINT_ENUM, hint_string);
781802
}

editor/plugins/node_3d_editor_plugin.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,18 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
21252125
nav_mode = change_nav_from_shortcut;
21262126
}
21272127

2128+
} else if (m->get_button_mask().has_flag(MouseButtonMask::MB_XBUTTON1)) {
2129+
NavigationMode change_nav_from_shortcut = _get_nav_mode_from_shortcut_check(NAVIGATION_MOUSE_4, shortcut_check_sets, false);
2130+
if (change_nav_from_shortcut != NAVIGATION_NONE) {
2131+
nav_mode = change_nav_from_shortcut;
2132+
}
2133+
2134+
} else if (m->get_button_mask().has_flag(MouseButtonMask::MB_XBUTTON2)) {
2135+
NavigationMode change_nav_from_shortcut = _get_nav_mode_from_shortcut_check(NAVIGATION_MOUSE_5, shortcut_check_sets, false);
2136+
if (change_nav_from_shortcut != NAVIGATION_NONE) {
2137+
nav_mode = change_nav_from_shortcut;
2138+
}
2139+
21282140
} else if (EDITOR_GET("editors/3d/navigation/emulate_3_button_mouse")) {
21292141
// Handle trackpad (no external mouse) use case
21302142
NavigationMode change_nav_from_shortcut = _get_nav_mode_from_shortcut_check(NAVIGATION_LEFT_MOUSE, shortcut_check_sets, true);

editor/plugins/node_3d_editor_plugin.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ class Node3DEditorViewport : public Control {
190190
};
191191

192192
enum NavigationScheme {
193-
NAVIGATION_GODOT,
194-
NAVIGATION_MAYA,
195-
NAVIGATION_MODO,
196-
NAVIGATION_CUSTOM,
193+
NAVIGATION_GODOT = 0,
194+
NAVIGATION_MAYA = 1,
195+
NAVIGATION_MODO = 2,
196+
NAVIGATION_CUSTOM = 3,
197+
NAVIGATION_TABLET = 4,
197198
};
198199

199200
enum FreelookNavigationScheme {
@@ -206,6 +207,8 @@ class Node3DEditorViewport : public Control {
206207
NAVIGATION_LEFT_MOUSE,
207208
NAVIGATION_MIDDLE_MOUSE,
208209
NAVIGATION_RIGHT_MOUSE,
210+
NAVIGATION_MOUSE_4,
211+
NAVIGATION_MOUSE_5,
209212
};
210213

211214
private:

0 commit comments

Comments
 (0)