mirror of
				https://github.com/godotengine/godot.git
				synced 2025-11-03 23:21:15 +00:00 
			
		
		
		
	Enable granular control of touchscreen related settings
This commit is contained in:
		
							parent
							
								
									b0c399ec8c
								
							
						
					
					
						commit
						61e41facc7
					
				
					 7 changed files with 64 additions and 14 deletions
				
			
		| 
						 | 
					@ -510,10 +510,6 @@
 | 
				
			||||||
		<member name="interface/theme/custom_theme" type="String" setter="" getter="">
 | 
							<member name="interface/theme/custom_theme" type="String" setter="" getter="">
 | 
				
			||||||
			The custom theme resource to use for the editor. Must be a Godot theme resource in [code].tres[/code] or [code].res[/code] format.
 | 
								The custom theme resource to use for the editor. Must be a Godot theme resource in [code].tres[/code] or [code].res[/code] format.
 | 
				
			||||||
		</member>
 | 
							</member>
 | 
				
			||||||
		<member name="interface/theme/enable_touchscreen_touch_area" type="bool" setter="" getter="">
 | 
					 | 
				
			||||||
			If [code]true[/code], increases the touch area for the UI elements to improve usability on touchscreen devices.
 | 
					 | 
				
			||||||
			[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
 | 
					 | 
				
			||||||
		</member>
 | 
					 | 
				
			||||||
		<member name="interface/theme/highlight_tabs" type="bool" setter="" getter="">
 | 
							<member name="interface/theme/highlight_tabs" type="bool" setter="" getter="">
 | 
				
			||||||
			If [code]true[/code], makes the background of selected tabs more contrasted in the editor theme (brighter on dark themes, darker on light themes).
 | 
								If [code]true[/code], makes the background of selected tabs more contrasted in the editor theme (brighter on dark themes, darker on light themes).
 | 
				
			||||||
		</member>
 | 
							</member>
 | 
				
			||||||
| 
						 | 
					@ -532,6 +528,18 @@
 | 
				
			||||||
		<member name="interface/theme/use_graph_node_headers" type="bool" setter="" getter="">
 | 
							<member name="interface/theme/use_graph_node_headers" type="bool" setter="" getter="">
 | 
				
			||||||
			If [code]true[/code], use colored header backgrounds for individual [GraphNode]s in the visual script and visual shader editors. This can improve usability when frequently using these editors at low zoom levels.
 | 
								If [code]true[/code], use colored header backgrounds for individual [GraphNode]s in the visual script and visual shader editors. This can improve usability when frequently using these editors at low zoom levels.
 | 
				
			||||||
		</member>
 | 
							</member>
 | 
				
			||||||
 | 
							<member name="interface/touchscreen/enable_long_press_as_right_click" type="bool" setter="" getter="">
 | 
				
			||||||
 | 
								If [code]true[/code], long press on touchscreen is treated as right click.
 | 
				
			||||||
 | 
								[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
 | 
				
			||||||
 | 
							</member>
 | 
				
			||||||
 | 
							<member name="interface/touchscreen/enable_pan_and_scale_gestures" type="bool" setter="" getter="">
 | 
				
			||||||
 | 
								If [code]true[/code], enable two finger pan and scale gestures on touchscreen devices.
 | 
				
			||||||
 | 
								[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
 | 
				
			||||||
 | 
							</member>
 | 
				
			||||||
 | 
							<member name="interface/touchscreen/increase_scrollbar_touch_area" type="bool" setter="" getter="">
 | 
				
			||||||
 | 
								If [code]true[/code], increases the scrollbar touch area to improve usability on touchscreen devices.
 | 
				
			||||||
 | 
								[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
 | 
				
			||||||
 | 
							</member>
 | 
				
			||||||
		<member name="network/debug/remote_host" type="String" setter="" getter="">
 | 
							<member name="network/debug/remote_host" type="String" setter="" getter="">
 | 
				
			||||||
			The address to listen to when starting the remote debugger. This can be set to [code]0.0.0.0[/code] to allow external clients to connect to the remote debugger (instead of restricting the remote debugger to connections from [code]localhost[/code]).
 | 
								The address to listen to when starting the remote debugger. This can be set to [code]0.0.0.0[/code] to allow external clients to connect to the remote debugger (instead of restricting the remote debugger to connections from [code]localhost[/code]).
 | 
				
			||||||
		</member>
 | 
							</member>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -348,7 +348,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
 | 
				
			||||||
	// Theme
 | 
						// Theme
 | 
				
			||||||
	_initial_set("interface/theme/preset", "Default");
 | 
						_initial_set("interface/theme/preset", "Default");
 | 
				
			||||||
	hints["interface/theme/preset"] = PropertyInfo(Variant::STRING, "interface/theme/preset", PROPERTY_HINT_ENUM, "Default,Alien,Arc,Godot 2,Grey,Light,Solarized (Dark),Solarized (Light),Custom", PROPERTY_USAGE_DEFAULT);
 | 
						hints["interface/theme/preset"] = PropertyInfo(Variant::STRING, "interface/theme/preset", PROPERTY_HINT_ENUM, "Default,Alien,Arc,Godot 2,Grey,Light,Solarized (Dark),Solarized (Light),Custom", PROPERTY_USAGE_DEFAULT);
 | 
				
			||||||
	_initial_set("interface/theme/enable_touchscreen_touch_area", OS::get_singleton()->has_touchscreen_ui_hint());
 | 
					 | 
				
			||||||
	_initial_set("interface/theme/icon_and_font_color", 0);
 | 
						_initial_set("interface/theme/icon_and_font_color", 0);
 | 
				
			||||||
	hints["interface/theme/icon_and_font_color"] = PropertyInfo(Variant::INT, "interface/theme/icon_and_font_color", PROPERTY_HINT_ENUM, "Auto,Dark,Light", PROPERTY_USAGE_DEFAULT);
 | 
						hints["interface/theme/icon_and_font_color"] = PropertyInfo(Variant::INT, "interface/theme/icon_and_font_color", PROPERTY_HINT_ENUM, "Auto,Dark,Light", PROPERTY_USAGE_DEFAULT);
 | 
				
			||||||
	_initial_set("interface/theme/base_color", Color(0.2, 0.23, 0.31));
 | 
						_initial_set("interface/theme/base_color", Color(0.2, 0.23, 0.31));
 | 
				
			||||||
| 
						 | 
					@ -368,6 +367,14 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
 | 
				
			||||||
	_initial_set("interface/theme/custom_theme", "");
 | 
						_initial_set("interface/theme/custom_theme", "");
 | 
				
			||||||
	hints["interface/theme/custom_theme"] = PropertyInfo(Variant::STRING, "interface/theme/custom_theme", PROPERTY_HINT_GLOBAL_FILE, "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
 | 
						hints["interface/theme/custom_theme"] = PropertyInfo(Variant::STRING, "interface/theme/custom_theme", PROPERTY_HINT_GLOBAL_FILE, "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Touchscreen
 | 
				
			||||||
 | 
						bool has_touchscreen_ui = OS::get_singleton()->has_touchscreen_ui_hint();
 | 
				
			||||||
 | 
						_initial_set("interface/touchscreen/increase_scrollbar_touch_area", has_touchscreen_ui);
 | 
				
			||||||
 | 
						_initial_set("interface/touchscreen/enable_long_press_as_right_click", has_touchscreen_ui);
 | 
				
			||||||
 | 
						set_restart_if_changed("interface/touchscreen/enable_long_press_as_right_click", true);
 | 
				
			||||||
 | 
						_initial_set("interface/touchscreen/enable_pan_and_scale_gestures", has_touchscreen_ui);
 | 
				
			||||||
 | 
						set_restart_if_changed("interface/touchscreen/enable_pan_and_scale_gestures", true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Scene tabs
 | 
						// Scene tabs
 | 
				
			||||||
	_initial_set("interface/scene_tabs/show_thumbnail_on_hover", true);
 | 
						_initial_set("interface/scene_tabs/show_thumbnail_on_hover", true);
 | 
				
			||||||
	_initial_set("interface/scene_tabs/resize_if_many_tabs", true);
 | 
						_initial_set("interface/scene_tabs/resize_if_many_tabs", true);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -305,7 +305,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	String preset = EDITOR_GET("interface/theme/preset");
 | 
						String preset = EDITOR_GET("interface/theme/preset");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool enable_touchscreen_touch_area = EDITOR_GET("interface/theme/enable_touchscreen_touch_area");
 | 
						bool increase_scrollbar_touch_area = EDITOR_GET("interface/touchscreen/increase_scrollbar_touch_area");
 | 
				
			||||||
	bool highlight_tabs = EDITOR_GET("interface/theme/highlight_tabs");
 | 
						bool highlight_tabs = EDITOR_GET("interface/theme/highlight_tabs");
 | 
				
			||||||
	int border_size = EDITOR_GET("interface/theme/border_size");
 | 
						int border_size = EDITOR_GET("interface/theme/border_size");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1050,7 +1050,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
 | 
				
			||||||
	// HScrollBar
 | 
						// HScrollBar
 | 
				
			||||||
	Ref<Texture> empty_icon = memnew(ImageTexture);
 | 
						Ref<Texture> empty_icon = memnew(ImageTexture);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (enable_touchscreen_touch_area) {
 | 
						if (increase_scrollbar_touch_area) {
 | 
				
			||||||
		theme->set_stylebox("scroll", "HScrollBar", make_line_stylebox(separator_color, 50));
 | 
							theme->set_stylebox("scroll", "HScrollBar", make_line_stylebox(separator_color, 50));
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
 | 
							theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
 | 
				
			||||||
| 
						 | 
					@ -1068,7 +1068,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
 | 
				
			||||||
	theme->set_icon("decrement_pressed", "HScrollBar", empty_icon);
 | 
						theme->set_icon("decrement_pressed", "HScrollBar", empty_icon);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// VScrollBar
 | 
						// VScrollBar
 | 
				
			||||||
	if (enable_touchscreen_touch_area) {
 | 
						if (increase_scrollbar_touch_area) {
 | 
				
			||||||
		theme->set_stylebox("scroll", "VScrollBar", make_line_stylebox(separator_color, 50, 1, 1, true));
 | 
							theme->set_stylebox("scroll", "VScrollBar", make_line_stylebox(separator_color, 50, 1, 1, true));
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
 | 
							theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,6 +40,7 @@ import android.util.Log
 | 
				
			||||||
import android.widget.Toast
 | 
					import android.widget.Toast
 | 
				
			||||||
import androidx.window.layout.WindowMetricsCalculator
 | 
					import androidx.window.layout.WindowMetricsCalculator
 | 
				
			||||||
import org.godotengine.godot.FullScreenGodotApp
 | 
					import org.godotengine.godot.FullScreenGodotApp
 | 
				
			||||||
 | 
					import org.godotengine.godot.GodotLib
 | 
				
			||||||
import org.godotengine.godot.utils.PermissionsUtil
 | 
					import org.godotengine.godot.utils.PermissionsUtil
 | 
				
			||||||
import org.godotengine.godot.utils.ProcessPhoenix
 | 
					import org.godotengine.godot.utils.ProcessPhoenix
 | 
				
			||||||
import java.util.*
 | 
					import java.util.*
 | 
				
			||||||
| 
						 | 
					@ -90,11 +91,19 @@ open class GodotEditor : FullScreenGodotApp() {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		super.onCreate(savedInstanceState)
 | 
							super.onCreate(savedInstanceState)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						override fun onGodotSetupCompleted() {
 | 
				
			||||||
 | 
							super.onGodotSetupCompleted()
 | 
				
			||||||
 | 
							val longPressEnabled = enableLongPressGestures()
 | 
				
			||||||
 | 
							val panScaleEnabled = enablePanAndScaleGestures()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							runOnUiThread {
 | 
				
			||||||
			// Enable long press, panning and scaling gestures
 | 
								// Enable long press, panning and scaling gestures
 | 
				
			||||||
			godotFragment?.renderView?.inputHandler?.apply {
 | 
								godotFragment?.renderView?.inputHandler?.apply {
 | 
				
			||||||
			enableLongPress(enableLongPressGestures())
 | 
									enableLongPress(longPressEnabled)
 | 
				
			||||||
			enablePanningAndScalingGestures(enablePanAndScaleGestures())
 | 
									enablePanningAndScalingGestures(panScaleEnabled)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -210,12 +219,14 @@ open class GodotEditor : FullScreenGodotApp() {
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Enable long press gestures for the Godot Android editor.
 | 
						 * Enable long press gestures for the Godot Android editor.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	protected open fun enableLongPressGestures() = true
 | 
						protected open fun enableLongPressGestures() =
 | 
				
			||||||
 | 
							java.lang.Boolean.parseBoolean(GodotLib.getEditorSetting("interface/touchscreen/enable_long_press_as_right_click"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Enable pan and scale gestures for the Godot Android editor.
 | 
						 * Enable pan and scale gestures for the Godot Android editor.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	protected open fun enablePanAndScaleGestures() = true
 | 
						protected open fun enablePanAndScaleGestures() =
 | 
				
			||||||
 | 
							java.lang.Boolean.parseBoolean(GodotLib.getEditorSetting("interface/touchscreen/enable_pan_and_scale_gestures"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
 | 
						override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
 | 
				
			||||||
		super.onActivityResult(requestCode, resultCode, data)
 | 
							super.onActivityResult(requestCode, resultCode, data)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -179,6 +179,13 @@ public class GodotLib {
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public static native String getGlobal(String p_key);
 | 
						public static native String getGlobal(String p_key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Used to access Godot's editor settings.
 | 
				
			||||||
 | 
						 * @param settingKey Setting key
 | 
				
			||||||
 | 
						 * @return String value of the setting
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public static native String getEditorSetting(String settingKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Invoke method |p_method| on the Godot object specified by |p_id|
 | 
						 * Invoke method |p_method| on the Godot object specified by |p_id|
 | 
				
			||||||
	 * @param p_id Id of the Godot object to invoke
 | 
						 * @param p_id Id of the Godot object to invoke
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,6 +53,10 @@
 | 
				
			||||||
#include <android/input.h>
 | 
					#include <android/input.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef TOOLS_ENABLED
 | 
				
			||||||
 | 
					#include "editor/editor_settings.h"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static JavaClassWrapper *java_class_wrapper = nullptr;
 | 
					static JavaClassWrapper *java_class_wrapper = nullptr;
 | 
				
			||||||
static OS_Android *os_android = nullptr;
 | 
					static OS_Android *os_android = nullptr;
 | 
				
			||||||
static AndroidInputHandler *input_handler = nullptr;
 | 
					static AndroidInputHandler *input_handler = nullptr;
 | 
				
			||||||
| 
						 | 
					@ -449,6 +453,18 @@ JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *
 | 
				
			||||||
	return env->NewStringUTF(ProjectSettings::get_singleton()->get(js).operator String().utf8().get_data());
 | 
						return env->NewStringUTF(ProjectSettings::get_singleton()->get(js).operator String().utf8().get_data());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getEditorSetting(JNIEnv *env, jclass clazz, jstring p_setting_key) {
 | 
				
			||||||
 | 
						String editor_setting = "";
 | 
				
			||||||
 | 
					#ifdef TOOLS_ENABLED
 | 
				
			||||||
 | 
						String godot_setting_key = jstring_to_string(p_setting_key, env);
 | 
				
			||||||
 | 
						editor_setting = EDITOR_GET(godot_setting_key).operator String();
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
						WARN_PRINT("Access to the Editor Settings in only available on Editor builds");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return env->NewStringUTF(editor_setting.utf8().get_data());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
 | 
					JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params) {
 | 
				
			||||||
	Object *obj = ObjectDB::get_instance(ID);
 | 
						Object *obj = ObjectDB::get_instance(ID);
 | 
				
			||||||
	ERR_FAIL_NULL(obj);
 | 
						ERR_FAIL_NULL(obj);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,6 +61,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env
 | 
				
			||||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz);
 | 
					JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jclass clazz);
 | 
				
			||||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz);
 | 
					JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv *env, jclass clazz);
 | 
				
			||||||
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jclass clazz, jstring path);
 | 
					JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jclass clazz, jstring path);
 | 
				
			||||||
 | 
					JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getEditorSetting(JNIEnv *env, jclass clazz, jstring p_setting_key);
 | 
				
			||||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params);
 | 
					JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params);
 | 
				
			||||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params);
 | 
					JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jclass clazz, jlong ID, jstring method, jobjectArray params);
 | 
				
			||||||
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHeight(JNIEnv *env, jclass clazz, jint p_height);
 | 
					JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHeight(JNIEnv *env, jclass clazz, jint p_height);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue