Skip to content

Commit 7092230

Browse files
committed
Merge pull request godotengine#89907 from bruvzg/nat_dlg_ftr_flags
[DisplayServer] Add separate feature flags for different native dialog types.
2 parents df6f4ce + dc01658 commit 7092230

File tree

11 files changed

+33
-9
lines changed

11 files changed

+33
-9
lines changed

doc/classes/DisplayServer.xml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<param index="3" name="callback" type="Callable" />
104104
<description>
105105
Shows a text input dialog which uses the operating system's native look-and-feel. [param callback] should accept a single [String] parameter which contains the text field's contents.
106-
[b]Note:[/b] This method is implemented only on macOS and Windows.
106+
[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_INPUT] feature. Supported platforms include macOS and Windows.
107107
</description>
108108
</method>
109109
<method name="dialog_show">
@@ -114,7 +114,7 @@
114114
<param index="3" name="callback" type="Callable" />
115115
<description>
116116
Shows a text dialog which uses the operating system's native look-and-feel. [param callback] should accept a single [int] parameter which corresponds to the index of the pressed button.
117-
[b]Note:[/b] This method is implemented only on macOS and Windows.
117+
[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG] feature. Supported platforms include macOS and Windows.
118118
</description>
119119
</method>
120120
<method name="enable_for_stealing_focus">
@@ -138,7 +138,7 @@
138138
Displays OS native dialog for selecting files or directories in the file system.
139139
Each filter string in the [param filters] array should be formatted like this: [code]*.txt,*.doc;Text Files[/code]. The description text of the filter is optional and can be omitted. See also [member FileDialog.filters].
140140
Callbacks have the following arguments: [code]status: bool, selected_paths: PackedStringArray, selected_filter_index: int[/code].
141-
[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG] feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS.
141+
[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_FILE] feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS.
142142
[b]Note:[/b] [param current_directory] might be ignored.
143143
[b]Note:[/b] On Linux, [param show_hidden] is ignored.
144144
[b]Note:[/b] On macOS, native file dialogs have no title.
@@ -164,7 +164,7 @@
164164
- [code]"values"[/code] - [PackedStringArray] of values. If empty, boolean option (check box) is used.
165165
- [code]"default"[/code] - default selected option index ([int]) or default boolean value ([bool]).
166166
Callbacks have the following arguments: [code]status: bool, selected_paths: PackedStringArray, selected_filter_index: int, selected_option: Dictionary[/code].
167-
[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG] feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS.
167+
[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_FILE] feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS.
168168
[b]Note:[/b] [param current_directory] might be ignored.
169169
[b]Note:[/b] On Linux (X11), [param show_hidden] is ignored.
170170
[b]Note:[/b] On macOS, native file dialogs have no title.
@@ -1784,7 +1784,7 @@
17841784
Display server supports setting the mouse cursor shape to a custom image. [b]Windows, macOS, Linux (X11/Wayland), Web[/b]
17851785
</constant>
17861786
<constant name="FEATURE_NATIVE_DIALOG" value="9" enum="Feature">
1787-
Display server supports spawning dialogs using the operating system's native look-and-feel. [b]Windows, macOS, Linux (X11/Wayland)[/b]
1787+
Display server supports spawning text dialogs using the operating system's native look-and-feel. See [method dialog_show]. [b]Windows, macOS[/b]
17881788
</constant>
17891789
<constant name="FEATURE_IME" value="10" enum="Feature">
17901790
Display server supports [url=https://en.wikipedia.org/wiki/Input_method]Input Method Editor[/url], which is commonly used for inputting Chinese/Japanese/Korean text. This is handled by the operating system, rather than by Godot. [b]Windows, macOS, Linux (X11)[/b]
@@ -1825,6 +1825,12 @@
18251825
<constant name="FEATURE_NATIVE_HELP" value="23" enum="Feature">
18261826
Display server supports native help system search callbacks. See [method help_set_search_callbacks].
18271827
</constant>
1828+
<constant name="FEATURE_NATIVE_DIALOG_INPUT" value="24" enum="Feature">
1829+
Display server supports spawning text input dialogs using the operating system's native look-and-feel. See [method dialog_input_text]. [b]Windows, macOS[/b]
1830+
</constant>
1831+
<constant name="FEATURE_NATIVE_DIALOG_FILE" value="25" enum="Feature">
1832+
Display server supports spawning dialogs for selecting files or directories using the operating system's native look-and-feel. See [method file_dialog_show] and [method file_dialog_with_options_show]. [b]Windows, macOS, Linux (X11/Wayland)[/b]
1833+
</constant>
18281834
<constant name="MOUSE_MODE_VISIBLE" value="0" enum="MouseMode">
18291835
Makes the mouse cursor visible if it is hidden.
18301836
</constant>

platform/android/display_server_android.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ bool DisplayServerAndroid::has_feature(Feature p_feature) const {
7171
case FEATURE_MOUSE:
7272
//case FEATURE_MOUSE_WARP:
7373
//case FEATURE_NATIVE_DIALOG:
74+
//case FEATURE_NATIVE_DIALOG_INPUT:
75+
//case FEATURE_NATIVE_DIALOG_FILE:
7476
//case FEATURE_NATIVE_ICON:
7577
//case FEATURE_WINDOW_TRANSPARENCY:
7678
case FEATURE_CLIPBOARD:

platform/ios/display_server_ios.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@
328328
// case FEATURE_MOUSE:
329329
// case FEATURE_MOUSE_WARP:
330330
// case FEATURE_NATIVE_DIALOG:
331+
// case FEATURE_NATIVE_DIALOG_INPUT:
332+
// case FEATURE_NATIVE_DIALOG_FILE:
331333
// case FEATURE_NATIVE_ICON:
332334
// case FEATURE_WINDOW_TRANSPARENCY:
333335
case FEATURE_CLIPBOARD:

platform/linuxbsd/wayland/display_server_wayland.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,10 @@ bool DisplayServerWayland::has_feature(Feature p_feature) const {
210210
return true;
211211
} break;
212212

213+
//case FEATURE_NATIVE_DIALOG:
214+
//case FEATURE_NATIVE_DIALOG_INPUT:
213215
#ifdef DBUS_ENABLED
214-
case FEATURE_NATIVE_DIALOG: {
216+
case FEATURE_NATIVE_DIALOG_FILE: {
215217
return true;
216218
} break;
217219
#endif

platform/linuxbsd/x11/display_server_x11.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ bool DisplayServerX11::has_feature(Feature p_feature) const {
128128
//case FEATURE_HIDPI:
129129
case FEATURE_ICON:
130130
#ifdef DBUS_ENABLED
131-
case FEATURE_NATIVE_DIALOG:
131+
case FEATURE_NATIVE_DIALOG_FILE:
132132
#endif
133+
//case FEATURE_NATIVE_DIALOG:
134+
//case FEATURE_NATIVE_DIALOG_INPUT:
133135
//case FEATURE_NATIVE_ICON:
134136
case FEATURE_SWAP_BUFFERS:
135137
#ifdef DBUS_ENABLED

platform/macos/display_server_macos.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@
755755
case FEATURE_CURSOR_SHAPE:
756756
case FEATURE_CUSTOM_CURSOR_SHAPE:
757757
case FEATURE_NATIVE_DIALOG:
758+
case FEATURE_NATIVE_DIALOG_INPUT:
759+
case FEATURE_NATIVE_DIALOG_FILE:
758760
case FEATURE_IME:
759761
case FEATURE_WINDOW_TRANSPARENCY:
760762
case FEATURE_HIDPI:

platform/web/display_server_web.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,8 @@ bool DisplayServerWeb::has_feature(Feature p_feature) const {
11281128
return true;
11291129
//case FEATURE_MOUSE_WARP:
11301130
//case FEATURE_NATIVE_DIALOG:
1131+
//case FEATURE_NATIVE_DIALOG_INPUT:
1132+
//case FEATURE_NATIVE_DIALOG_FILE:
11311133
//case FEATURE_NATIVE_ICON:
11321134
//case FEATURE_WINDOW_TRANSPARENCY:
11331135
//case FEATURE_KEEP_SCREEN_ON:

platform/windows/display_server_windows.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ bool DisplayServerWindows::has_feature(Feature p_feature) const {
114114
case FEATURE_ICON:
115115
case FEATURE_NATIVE_ICON:
116116
case FEATURE_NATIVE_DIALOG:
117+
case FEATURE_NATIVE_DIALOG_INPUT:
118+
case FEATURE_NATIVE_DIALOG_FILE:
117119
case FEATURE_SWAP_BUFFERS:
118120
case FEATURE_KEEP_SCREEN_ON:
119121
case FEATURE_TEXT_TO_SPEECH:

scene/gui/file_dialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void FileDialog::popup(const Rect2i &p_rect) {
6868
}
6969
#endif
7070

71-
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG) && (use_native_dialog || OS::get_singleton()->is_sandboxed())) {
71+
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE) && (use_native_dialog || OS::get_singleton()->is_sandboxed())) {
7272
String root;
7373
if (access == ACCESS_RESOURCES) {
7474
root = ProjectSettings::get_singleton()->get_resource_path();
@@ -91,7 +91,7 @@ void FileDialog::set_visible(bool p_visible) {
9191
}
9292
#endif
9393

94-
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG) && (use_native_dialog || OS::get_singleton()->is_sandboxed())) {
94+
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE) && (use_native_dialog || OS::get_singleton()->is_sandboxed())) {
9595
if (p_visible) {
9696
String root;
9797
if (access == ACCESS_RESOURCES) {

servers/display_server.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,8 @@ void DisplayServer::_bind_methods() {
10141014
BIND_ENUM_CONSTANT(FEATURE_SCREEN_CAPTURE);
10151015
BIND_ENUM_CONSTANT(FEATURE_STATUS_INDICATOR);
10161016
BIND_ENUM_CONSTANT(FEATURE_NATIVE_HELP);
1017+
BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG_INPUT);
1018+
BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG_FILE);
10171019

10181020
BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
10191021
BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);

0 commit comments

Comments
 (0)