[Window] Allow to override viewport and project settings and force use of native window.
This commit is contained in:
parent
a07dd0d6a5
commit
cfdb968848
3 changed files with 29 additions and 0 deletions
|
@ -590,6 +590,9 @@
|
|||
[b]Note:[/b] This property is implemented only on macOS.
|
||||
[b]Note:[/b] This property only works with native windows.
|
||||
</member>
|
||||
<member name="force_native" type="bool" setter="set_force_native" getter="get_force_native" default="false">
|
||||
If [code]true[/code], native window will be used regardless of parent viewport and project settings.
|
||||
</member>
|
||||
<member name="initial_position" type="int" setter="set_initial_position" getter="get_initial_position" enum="Window.WindowInitialPosition" default="0">
|
||||
Specifies the initial type of position for the [Window]. See [enum WindowInitialPosition] constants.
|
||||
</member>
|
||||
|
|
|
@ -1209,8 +1209,26 @@ void Window::_update_window_callbacks() {
|
|||
DisplayServer::get_singleton()->window_set_drop_files_callback(callable_mp(this, &Window::_window_drop_files), window_id);
|
||||
}
|
||||
|
||||
void Window::set_force_native(bool p_force_native) {
|
||||
if (force_native == p_force_native) {
|
||||
return;
|
||||
}
|
||||
force_native = p_force_native;
|
||||
if (is_visible()) {
|
||||
WARN_PRINT("Can't change \"force_native\" while a window is displayed. Consider hiding window before changing this value.");
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::get_force_native() const {
|
||||
return force_native;
|
||||
}
|
||||
|
||||
Viewport *Window::get_embedder() const {
|
||||
ERR_READ_THREAD_GUARD_V(nullptr);
|
||||
if (force_native && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_SUBWINDOWS)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Viewport *vp = get_parent_viewport();
|
||||
|
||||
while (vp) {
|
||||
|
@ -2802,6 +2820,9 @@ void Window::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method(D_METHOD("get_contents_minimum_size"), &Window::get_contents_minimum_size);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_force_native", "force_native"), &Window::set_force_native);
|
||||
ClassDB::bind_method(D_METHOD("get_force_native"), &Window::get_force_native);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_content_scale_size", "size"), &Window::set_content_scale_size);
|
||||
ClassDB::bind_method(D_METHOD("get_content_scale_size"), &Window::get_content_scale_size);
|
||||
|
||||
|
@ -2926,6 +2947,7 @@ void Window::_bind_methods() {
|
|||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "popup_window"), "set_flag", "get_flag", FLAG_POPUP);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "extend_to_title"), "set_flag", "get_flag", FLAG_EXTEND_TO_TITLE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "mouse_passthrough"), "set_flag", "get_flag", FLAG_MOUSE_PASSTHROUGH);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "force_native"), "set_force_native", "get_force_native");
|
||||
|
||||
ADD_GROUP("Limits", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "min_size", PROPERTY_HINT_NONE, "suffix:px"), "set_min_size", "get_min_size");
|
||||
|
|
|
@ -122,6 +122,7 @@ private:
|
|||
bool visible = true;
|
||||
bool focused = false;
|
||||
WindowInitialPosition initial_position = WINDOW_INITIAL_POSITION_ABSOLUTE;
|
||||
bool force_native = false;
|
||||
|
||||
bool use_font_oversampling = false;
|
||||
bool transient = false;
|
||||
|
@ -273,6 +274,9 @@ public:
|
|||
void set_initial_position(WindowInitialPosition p_initial_position);
|
||||
WindowInitialPosition get_initial_position() const;
|
||||
|
||||
void set_force_native(bool p_force_native);
|
||||
bool get_force_native() const;
|
||||
|
||||
void set_current_screen(int p_screen);
|
||||
int get_current_screen() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue