Skip to content

Commit

Permalink
Editor without title bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilderin committed Oct 20, 2024
1 parent f032af7 commit 77b4852
Show file tree
Hide file tree
Showing 29 changed files with 841 additions and 73 deletions.
6 changes: 4 additions & 2 deletions doc/classes/DisplayServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,7 @@
<param index="0" name="window_id" type="int" default="0" />
<description>
Returns left margins ([code]x[/code]), right margins ([code]y[/code]) and height ([code]z[/code]) of the title that are safe to use (contains no buttons or other elements) when [constant WINDOW_FLAG_EXTEND_TO_TITLE] flag is set.
[b]Note:[/b] On Linux and Windows, this method always returns [constant Vector2.ZERO], since the decoration buttons are not displayed by the OS when the [constant WINDOW_FLAG_EXTEND_TO_TITLE] flag is set.
</description>
</method>
<method name="window_get_size" qualifiers="const">
Expand Down Expand Up @@ -1873,7 +1874,7 @@
Display server supports text-to-speech. See [code]tts_*[/code] methods. [b]Windows, macOS, Linux (X11/Wayland), Android, iOS, Web[/b]
</constant>
<constant name="FEATURE_EXTEND_TO_TITLE" value="20" enum="Feature">
Display server supports expanding window content to the title. See [constant WINDOW_FLAG_EXTEND_TO_TITLE]. [b]macOS[/b]
Display server supports expanding window content to the title. See [constant WINDOW_FLAG_EXTEND_TO_TITLE]. [b]macOS, Linux, Windows[/b]
</constant>
<constant name="FEATURE_SCREEN_CAPTURE" value="21" enum="Feature">
Display server supports reading screen pixels. See [method screen_get_pixel].
Expand Down Expand Up @@ -2094,7 +2095,8 @@
Window content is expanded to the full size of the window. Unlike borderless window, the frame is left intact and can be used to resize the window, title bar is transparent, but have minimize/maximize/close buttons.
Use [method window_set_window_buttons_offset] to adjust minimize/maximize/close buttons offset.
Use [method window_get_safe_title_margins] to determine area under the title bar that is not covered by decorations.
[b]Note:[/b] This flag is implemented only on macOS.
[b]Note:[/b] This flag is implemented on macOS, Linux, and Windows.
[b]Note:[/b] On Linux and Windows, the decoration buttons (Minimize, Maximize and Close) are rendered by Godot and use the theme of the Window.
</constant>
<constant name="WINDOW_FLAG_MOUSE_PASSTHROUGH" value="7" enum="WindowFlags">
All mouse events are passed to the underlying window of the same application.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@
</member>
<member name="interface/editor/expand_to_title" type="bool" setter="" getter="">
Expanding main editor window content to the title, if supported by [DisplayServer]. See [constant DisplayServer.WINDOW_FLAG_EXTEND_TO_TITLE].
Specific to the macOS platform.
[b]Note:[/b] This setting is implemented on macOS, Linux, and Windows.
</member>
<member name="interface/editor/font_allow_msdf" type="bool" setter="" getter="">
If set to [code]true[/code], MSDF font rendering will be used for the visual shader graph editor. You may need to set this to [code]false[/code] when using a custom main font, as some fonts will look broken due to the use of self-intersecting outlines in their font data. Downloading the font from the font maker's official website as opposed to a service like Google Fonts can help resolve this issue.
Expand Down
4 changes: 3 additions & 1 deletion doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,9 @@
</member>
<member name="display/window/size/extend_to_title" type="bool" setter="" getter="" default="false">
Main window content is expanded to the full size of the window. Unlike a borderless window, the frame is left intact and can be used to resize the window, and the title bar is transparent, but has minimize/maximize/close buttons.
[b]Note:[/b] This setting is implemented only on macOS.
[b]Note:[/b] This setting is implemented on macOS, Linux, and Windows.
[b]Note:[/b] This setting only works if [member display/window/subwindows/embed_subwindows] is [code]false[/code].
[b]Note:[/b] On Linux and Windows, the decoration buttons (Minimize, Maximize and Close) are rendered by Godot and use the theme of the Window.
</member>
<member name="display/window/size/initial_position" type="Vector2i" setter="" getter="" default="Vector2i(0, 0)">
Main window initial position (in virtual desktop coordinates), this setting is used only if [member display/window/size/initial_position_type] is set to "Absolute" ([code]0[/code]).
Expand Down
58 changes: 55 additions & 3 deletions doc/classes/Window.xml
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@
</member>
<member name="extend_to_title" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], the [Window] contents is expanded to the full size of the window, window title bar is transparent.
[b]Note:[/b] This property is implemented only on macOS.
[b]Note:[/b] This property is implemented on macOS, Linux, and Windows.
[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">
Expand Down Expand Up @@ -835,8 +835,9 @@
</constant>
<constant name="FLAG_EXTEND_TO_TITLE" value="6" enum="Flags">
Window content is expanded to the full size of the window. Unlike borderless window, the frame is left intact and can be used to resize the window, title bar is transparent, but have minimize/maximize/close buttons. Set with [member extend_to_title].
[b]Note:[/b] This flag is implemented only on macOS.
[b]Note:[/b] This flag is implemented on macOS, Linux, and Windows.
[b]Note:[/b] This flag has no effect in embedded windows.
[b]Note:[/b] On Linux and Windows, the decoration buttons (Minimize, Maximize and Close) are rendered by Godot and use the Window theme.
</constant>
<constant name="FLAG_MOUSE_PASSTHROUGH" value="7" enum="Flags">
All mouse events are passed to the underlying window of the same application.
Expand Down Expand Up @@ -907,6 +908,15 @@
</constant>
</constants>
<theme_items>
<theme_item name="decoration_button_hover_modulate" data_type="color" type="Color" default="Color(0.95, 0.95, 0.95, 1)">
Window decoration buttons modulation color, when the buttons are hovered, [member extend_to_title] is true and the buttons are rendered by Godot.
</theme_item>
<theme_item name="decoration_button_normal_modulate" data_type="color" type="Color" default="Color(0.875, 0.875, 0.875, 1)">
Window decoration buttons modulation color, when [member extend_to_title] is true and the buttons are rendered by Godot.
</theme_item>
<theme_item name="decoration_button_pressed_modulate" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
Window decoration buttons modulation color, when the buttons are pressed, [member extend_to_title] is true and the buttons are rendered by Godot.
</theme_item>
<theme_item name="title_color" data_type="color" type="Color" default="Color(0.875, 0.875, 0.875, 1)">
The color of the title's text.
</theme_item>
Expand All @@ -916,9 +926,21 @@
<theme_item name="close_h_offset" data_type="constant" type="int" default="18">
Horizontal position offset of the close button.
</theme_item>
<theme_item name="close_v_offset" data_type="constant" type="int" default="24">
<theme_item name="close_v_offset" data_type="constant" type="int" default="20">
Vertical position offset of the close button.
</theme_item>
<theme_item name="maximize_h_offset" data_type="constant" type="int" default="36">
Horizontal position offset of the maximize/restore decoration button, when [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="maximize_v_offset" data_type="constant" type="int" default="20">
Vertical position offset of the maximize/restore decoration button, when [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="minimize_h_offset" data_type="constant" type="int" default="54">
Horizontal position offset of the minimize decoration button, when [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="minimize_v_offset" data_type="constant" type="int" default="20">
Vertical position offset of the minimize decoration button, when [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="resize_margin" data_type="constant" type="int" default="4">
Defines the outside margin at which the window border can be grabbed with mouse and resized.
</theme_item>
Expand All @@ -940,6 +962,36 @@
<theme_item name="close_pressed" data_type="icon" type="Texture2D">
The icon for the close button when it's being pressed.
</theme_item>
<theme_item name="maximize" data_type="icon" type="Texture2D">
The icon for the maximize decoration button, when [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="maximize_disabled" data_type="icon" type="Texture2D">
The icon for the maximize decoration button when disabled (window not resizable), [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="maximize_pressed" data_type="icon" type="Texture2D">
The icon for the maximize decoration button when it's being pressed, [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="minimize" data_type="icon" type="Texture2D">
The icon for the minimize decoration button, when [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="minimize_pressed" data_type="icon" type="Texture2D">
The icon for the minimize decoration button when it's being pressed, [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="restore" data_type="icon" type="Texture2D">
The icon for the restore decoration button, when [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="restore_pressed" data_type="icon" type="Texture2D">
The icon for the restore decoration button when it's being pressed, [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="decoration_button_hover" data_type="style" type="StyleBox">
The background style used of the window decoration buttons when the mouse pointer is hovering them, [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="decoration_button_normal" data_type="style" type="StyleBox">
The background style used of the window decoration buttons when [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="decoration_button_pressed" data_type="style" type="StyleBox">
The background style used of the window decoration buttons when they are being pressed, [member extend_to_title] is true and the button is rendered by Godot.
</theme_item>
<theme_item name="embedded_border" data_type="style" type="StyleBox">
The background style used when the [Window] is embedded. Note that this is drawn only under the window's content, excluding the title. For proper borders and title bar style, you can use [code]expand_margin_*[/code] properties of [StyleBoxFlat].
[b]Note:[/b] The content background will not be visible unless [member transparent] is enabled.
Expand Down
26 changes: 18 additions & 8 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ void EditorNode::_update_theme(bool p_skip_creation) {
}

_update_renderer_color();
_titlebar_resized();
}

editor_dock_manager->update_tab_styles();
Expand Down Expand Up @@ -650,7 +651,7 @@ void EditorNode::_notification(int p_what) {

Window *window = get_window();
if (window) {
// Handle macOS fullscreen and extend-to-title changes.
// Handle fullscreen and extend-to-title changes.
window->connect("titlebar_changed", callable_mp(this, &EditorNode::_titlebar_resized));
}

Expand Down Expand Up @@ -1239,18 +1240,27 @@ void EditorNode::_viewport_resized() {
}

void EditorNode::_titlebar_resized() {
DisplayServer::get_singleton()->window_set_window_buttons_offset(Vector2i(title_bar->get_global_position().y + title_bar->get_size().y / 2, title_bar->get_global_position().y + title_bar->get_size().y / 2), DisplayServer::MAIN_WINDOW_ID);
const Vector3i &margin = DisplayServer::get_singleton()->window_get_safe_title_margins(DisplayServer::MAIN_WINDOW_ID);
Window *w = get_window();
if (!w) {
return;
}

// On Windows and Linux, we will let the window button in the corner, same as the
// default OS buttons.
#ifdef MACOS_ENABLED
w->set_window_buttons_offset(Vector2i(title_bar->get_global_position().y + title_bar->get_size().y / 2, title_bar->get_global_position().y + title_bar->get_size().y / 2));
#endif

const Vector2i &left_margin = w->get_safe_title_margins_left();
const Vector2i &right_margin = w->get_safe_title_margins_right();
if (left_menu_spacer) {
int w = (gui_base->is_layout_rtl()) ? margin.y : margin.x;
left_menu_spacer->set_custom_minimum_size(Size2(w, 0));
left_menu_spacer->set_custom_minimum_size(Size2(left_margin.x, 0));
}
if (right_menu_spacer) {
int w = (gui_base->is_layout_rtl()) ? margin.x : margin.y;
right_menu_spacer->set_custom_minimum_size(Size2(w, 0));
right_menu_spacer->set_custom_minimum_size(Size2(right_margin.x, 0));
}
if (title_bar) {
title_bar->set_custom_minimum_size(Size2(0, margin.z - title_bar->get_global_position().y));
title_bar->set_custom_minimum_size(Size2(0, MAX(left_margin.y, right_margin.y) - title_bar->get_global_position().y));
}
}

Expand Down
1 change: 1 addition & 0 deletions editor/icons/WindowClose.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions editor/icons/WindowMaximize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions editor/icons/WindowMinimize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions editor/icons/WindowRestore.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 16 additions & 9 deletions editor/project_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,20 +1053,27 @@ void ProjectManager::_files_dropped(PackedStringArray p_files) {
}

void ProjectManager::_titlebar_resized() {
DisplayServer::get_singleton()->window_set_window_buttons_offset(Vector2i(title_bar->get_global_position().y + title_bar->get_size().y / 2, title_bar->get_global_position().y + title_bar->get_size().y / 2), DisplayServer::MAIN_WINDOW_ID);
const Vector3i &margin = DisplayServer::get_singleton()->window_get_safe_title_margins(DisplayServer::MAIN_WINDOW_ID);
Window *w = get_window();
if (!w) {
return;
}

// On Windows and Linux, we will let the window button in the corner, same as the
// default OS buttons.
#ifdef MACOS_ENABLED
w->set_window_buttons_offset(Vector2i(title_bar->get_global_position().y + title_bar->get_size().y / 2, title_bar->get_global_position().y + title_bar->get_size().y / 2));
#endif

const Vector2i &left_margin = w->get_safe_title_margins_left();
const Vector2i &right_margin = w->get_safe_title_margins_right();
if (left_menu_spacer) {
int w = (root_container->is_layout_rtl()) ? margin.y : margin.x;
left_menu_spacer->set_custom_minimum_size(Size2(w, 0));
right_spacer->set_custom_minimum_size(Size2(w, 0));
left_menu_spacer->set_custom_minimum_size(Size2(left_margin.x, 0));
}
if (right_menu_spacer) {
int w = (root_container->is_layout_rtl()) ? margin.x : margin.y;
right_menu_spacer->set_custom_minimum_size(Size2(w, 0));
left_spacer->set_custom_minimum_size(Size2(w, 0));
right_menu_spacer->set_custom_minimum_size(Size2(right_margin.x, 0));
}
if (title_bar) {
title_bar->set_custom_minimum_size(Size2(0, margin.z - title_bar->get_global_position().y));
title_bar->set_custom_minimum_size(Size2(0, MAX(left_margin.y, right_margin.y) - title_bar->get_global_position().y));
}
}

Expand Down
Loading

0 comments on commit 77b4852

Please sign in to comment.