Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable multi-window buttons instead of hiding them when support is unavailable #84515

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/classes/EditorInterface.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@
Shows the given property on the given [param object] in the editor's Inspector dock. If [param inspector_only] is [code]true[/code], plugins will not attempt to edit [param object].
</description>
</method>
<method name="is_multi_window_enabled" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if multiple window support is enabled in the editor. Multiple window support is enabled if [i]all[/i] of these statements are true:
- [member EditorSettings.interface/multi_window/enable] is [code]true[/code].
- [member EditorSettings.interface/editor/single_window_mode] is [code]false[/code].
- [member Viewport.gui_embed_subwindows] is [code]false[/code]. This is forced to [code]true[/code] on platforms that don't support multiple windows such as Web, or when the [code]--single-window[/code] [url=$DOCS_URL/tutorials/editor/command_line_tutorial.html]command line argument[/url] is used.
</description>
</method>
<method name="is_playing_scene" qualifiers="const">
<return type="bool" />
<description>
Expand Down
4 changes: 3 additions & 1 deletion doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@
</member>
<member name="interface/editor/single_window_mode" type="bool" setter="" getter="">
If [code]true[/code], embed modal windows such as docks inside the main editor window. When single-window mode is enabled, tooltips will also be embedded inside the main editor window, which means they can't be displayed outside of the editor window.
[b]Note:[/b] To query whether the editor can use multiple windows in an editor plugin, use [method EditorInterface.is_multi_window_enabled] instead of querying the value of this editor setting.
</member>
<member name="interface/editor/ui_layout_direction" type="int" setter="" getter="">
Editor UI default layout direction.
Expand All @@ -637,8 +638,9 @@
If [code]true[/code], display OpenType features marked as [code]hidden[/code] by the font file in the [Font] editor.
</member>
<member name="interface/multi_window/enable" type="bool" setter="" getter="">
If [code]true[/code], the multi window support in editor is enabled. The following panels can become dedicated windows (made floating): Docks, Script editor, and Shader editor.
If [code]true[/code], multiple window support in editor is enabled. The following panels can become dedicated windows (i.e. made floating): Docks, Script editor, and Shader editor.
[b]Note:[/b] When [member interface/editor/single_window_mode] is [code]true[/code], the multi window support is always disabled.
[b]Note:[/b] To query whether the editor can use multiple windows in an editor plugin, use [method EditorInterface.is_multi_window_enabled] instead of querying the value of this editor setting.
</member>
<member name="interface/multi_window/maximize_window" type="bool" setter="" getter="">
If [code]true[/code], when panels are made floating they will be maximized.
Expand Down
19 changes: 11 additions & 8 deletions editor/editor_dock_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,15 +702,18 @@ EditorDockManager::EditorDockManager() {
dock_select->set_v_size_flags(Control::SIZE_EXPAND_FILL);
dock_vb->add_child(dock_select);

if (!SceneTree::get_singleton()->get_root()->is_embedding_subwindows() && !EDITOR_GET("interface/editor/single_window_mode") && EDITOR_GET("interface/multi_window/enable")) {
dock_float = memnew(Button);
dock_float->set_text(TTR("Make Floating"));
dock_float->set_focus_mode(Control::FOCUS_NONE);
dock_float->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
dock_float->connect("pressed", callable_mp(this, &EditorDockManager::_dock_make_selected_float));

dock_vb->add_child(dock_float);
dock_float = memnew(Button);
dock_float->set_text(TTR("Make Floating"));
if (!EditorNode::get_singleton()->is_multi_window_enabled()) {
dock_float->set_disabled(true);
dock_float->set_tooltip_text(EditorNode::get_singleton()->get_multiwindow_support_tooltip_text());
} else {
dock_float->set_tooltip_text(TTR("Make this dock floating."));
}
dock_float->set_focus_mode(Control::FOCUS_NONE);
dock_float->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
dock_float->connect("pressed", callable_mp(this, &EditorDockManager::_dock_make_selected_float));
dock_vb->add_child(dock_float);

dock_select_popup->reset_size();
}
5 changes: 5 additions & 0 deletions editor/editor_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ bool EditorInterface::is_distraction_free_mode_enabled() const {
return EditorNode::get_singleton()->is_distraction_free_mode_enabled();
}

bool EditorInterface::is_multi_window_enabled() const {
return EditorNode::get_singleton()->is_multi_window_enabled();
}

float EditorInterface::get_editor_scale() const {
return EDSCALE;
}
Expand Down Expand Up @@ -445,6 +449,7 @@ void EditorInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_main_screen_editor", "name"), &EditorInterface::set_main_screen_editor);
ClassDB::bind_method(D_METHOD("set_distraction_free_mode", "enter"), &EditorInterface::set_distraction_free_mode);
ClassDB::bind_method(D_METHOD("is_distraction_free_mode_enabled"), &EditorInterface::is_distraction_free_mode_enabled);
ClassDB::bind_method(D_METHOD("is_multi_window_enabled"), &EditorInterface::is_multi_window_enabled);

ClassDB::bind_method(D_METHOD("get_editor_scale"), &EditorInterface::get_editor_scale);

Expand Down
1 change: 1 addition & 0 deletions editor/editor_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class EditorInterface : public Object {
void set_main_screen_editor(const String &p_name);
void set_distraction_free_mode(bool p_enter);
bool is_distraction_free_mode_enabled() const;
bool is_multi_window_enabled() const;

float get_editor_scale() const;

Expand Down
18 changes: 18 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3711,6 +3711,10 @@ bool EditorNode::is_scene_open(const String &p_path) {
return false;
}

bool EditorNode::is_multi_window_enabled() const {
return !SceneTree::get_singleton()->get_root()->is_embedding_subwindows() && !EDITOR_GET("interface/editor/single_window_mode") && EDITOR_GET("interface/multi_window/enable");
}

void EditorNode::fix_dependencies(const String &p_for_file) {
dependency_fixer->edit(p_for_file);
}
Expand Down Expand Up @@ -4122,6 +4126,20 @@ void EditorNode::request_instantiate_scenes(const Vector<String> &p_files) {
SceneTreeDock::get_singleton()->instantiate_scenes(p_files);
}

String EditorNode::get_multiwindow_support_tooltip_text() const {
if (SceneTree::get_singleton()->get_root()->is_embedding_subwindows()) {
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_SUBWINDOWS)) {
return TTR("Multi-window support is not available because the `--single-window` command line argument was used to start the editor.");
} else {
return TTR("Multi-window support is not available because the current platform doesn't support multiple windows.");
}
} else if (EDITOR_GET("interface/editor/single_window_mode")) {
return TTR("Multi-window support is not available because Interface > Editor > Single Window Mode is enabled in the editor settings.");
}

return TTR("Multi-window support is not available because Interface > Multi Window > Enable is disabled in the editor settings.");
}

void EditorNode::_inherit_request(String p_file) {
current_menu_option = FILE_NEW_INHERITED_SCENE;
_dialog_action(p_file);
Expand Down
3 changes: 3 additions & 0 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,8 @@ class EditorNode : public Node {

bool is_resource_read_only(Ref<Resource> p_resource, bool p_foreign_resources_are_writable = false);

String get_multiwindow_support_tooltip_text() const;

bool is_changing_scene() const;

VBoxContainer *get_main_screen_control();
Expand Down Expand Up @@ -807,6 +809,7 @@ class EditorNode : public Node {
List<AdditiveNodeEntry> &p_addition_list);

bool is_scene_open(const String &p_path);
bool is_multi_window_enabled() const;

void setup_color_picker(ColorPicker *p_picker);

Expand Down
17 changes: 9 additions & 8 deletions editor/plugins/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4074,18 +4074,19 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
script_forward->set_disabled(true);
script_forward->set_tooltip_text(TTR("Go to next edited document."));

if (p_wrapper->is_window_available()) {
menu_hb->add_child(memnew(VSeparator));
menu_hb->add_child(memnew(VSeparator));

make_floating = memnew(ScreenSelect);
make_floating->set_flat(true);
make_floating = memnew(ScreenSelect);
make_floating->set_flat(true);
make_floating->connect("request_open_in_screen", callable_mp(window_wrapper, &WindowWrapper::enable_window_on_screen).bind(true));
if (!make_floating->is_disabled()) {
// Override default ScreenSelect tooltip if multi-window support is available.
make_floating->set_tooltip_text(TTR("Make the script editor floating."));
Calinou marked this conversation as resolved.
Show resolved Hide resolved
make_floating->connect("request_open_in_screen", callable_mp(window_wrapper, &WindowWrapper::enable_window_on_screen).bind(true));

menu_hb->add_child(make_floating);
p_wrapper->connect("window_visibility_changed", callable_mp(this, &ScriptEditor::_window_changed));
}

menu_hb->add_child(make_floating);
p_wrapper->connect("window_visibility_changed", callable_mp(this, &ScriptEditor::_window_changed));

tab_container->connect("tab_changed", callable_mp(this, &ScriptEditor::_tab_changed));

erase_tab_confirm = memnew(ConfirmationDialog);
Expand Down
23 changes: 12 additions & 11 deletions editor/plugins/shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,20 +643,21 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
file_menu->get_popup()->set_item_disabled(file_menu->get_popup()->get_item_index(i), true);
}

if (window_wrapper->is_window_available()) {
Control *padding = memnew(Control);
padding->set_h_size_flags(Control::SIZE_EXPAND_FILL);
menu_hb->add_child(padding);

make_floating = memnew(ScreenSelect);
make_floating->set_flat(true);
Control *padding = memnew(Control);
padding->set_h_size_flags(Control::SIZE_EXPAND_FILL);
menu_hb->add_child(padding);

make_floating = memnew(ScreenSelect);
make_floating->set_flat(true);
make_floating->connect("request_open_in_screen", callable_mp(window_wrapper, &WindowWrapper::enable_window_on_screen).bind(true));
if (!make_floating->is_disabled()) {
// Override default ScreenSelect tooltip if multi-window support is available.
make_floating->set_tooltip_text(TTR("Make the shader editor floating."));
make_floating->connect("request_open_in_screen", callable_mp(window_wrapper, &WindowWrapper::enable_window_on_screen).bind(true));

menu_hb->add_child(make_floating);
window_wrapper->connect("window_visibility_changed", callable_mp(this, &ShaderEditorPlugin::_window_changed));
}

menu_hb->add_child(make_floating);
window_wrapper->connect("window_visibility_changed", callable_mp(this, &ShaderEditorPlugin::_window_changed));

shader_list = memnew(ItemList);
shader_list->set_auto_translate(false);
shader_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
Expand Down
14 changes: 11 additions & 3 deletions editor/window_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void WindowWrapper::set_margins_enabled(bool p_enabled) {
}

WindowWrapper::WindowWrapper() {
if (SceneTree::get_singleton()->get_root()->is_embedding_subwindows() || EDITOR_GET("interface/editor/single_window_mode") || !EDITOR_GET("interface/multi_window/enable")) {
if (!EditorNode::get_singleton()->is_multi_window_enabled()) {
return;
}

Expand Down Expand Up @@ -375,7 +375,9 @@ void ScreenSelect::_build_advanced_menu() {
}

void ScreenSelect::_emit_screen_signal(int p_screen_idx) {
emit_signal("request_open_in_screen", p_screen_idx);
if (!is_disabled()) {
emit_signal("request_open_in_screen", p_screen_idx);
}
}

void ScreenSelect::_bind_methods() {
Expand Down Expand Up @@ -436,13 +438,19 @@ void ScreenSelect::pressed() {
}

ScreenSelect::ScreenSelect() {
set_tooltip_text(TTR("Make this panel floating.\nRight click to open the screen selector."));
set_button_mask(MouseButtonMask::RIGHT);
set_flat(true);
set_toggle_mode(true);
set_focus_mode(FOCUS_NONE);
set_action_mode(ACTION_MODE_BUTTON_PRESS);

if (!EditorNode::get_singleton()->is_multi_window_enabled()) {
set_disabled(true);
set_tooltip_text(EditorNode::get_singleton()->get_multiwindow_support_tooltip_text());
} else {
set_tooltip_text(TTR("Make this panel floating.\nRight-click to open the screen selector."));
}

// Create the popup.
const Size2 borders = Size2(4, 4) * EDSCALE;

Expand Down
Loading