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 Sep 15, 2024
1 parent 5675c76 commit 62041d7
Show file tree
Hide file tree
Showing 28 changed files with 785 additions and 71 deletions.
6 changes: 4 additions & 2 deletions doc/classes/DisplayServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,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 amd Windows, this always returns (0, 0) since the window buttons are not displayed by the OS when [constant WINDOW_FLAG_EXTEND_TO_TITLE] flag is set.
</description>
</method>
<method name="window_get_size" qualifiers="const">
Expand Down Expand Up @@ -1866,7 +1867,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 and 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 @@ -2087,7 +2088,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 only 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 Window theme.
</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 @@ -658,7 +658,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] Only supported 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
3 changes: 2 additions & 1 deletion doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,8 @@
</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 only on macOS, Linux and Windows and when [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 Window theme.
</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
75 changes: 72 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 only on macOS 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 only on macOS and Windows.
[b]Note:[/b] This flag has no effect in embedded windows.
[b]Note:[/b] On Windows, the window buttons (minimize, maximize and close) are not displayed.
</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,18 @@
</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 button modulation color, when the button is hovered.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="decoration_button_normal_modulate" data_type="color" type="Color" default="Color(0.875, 0.875, 0.875, 1)">
Window button modulation color.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="decoration_button_pressed_modulate" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
Window button modulation color, when the button is pressed.
[b]Note:[/b] Used only when extend to title is active.
</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 +929,25 @@
<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 button.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="maximize_v_offset" data_type="constant" type="int" default="20">
Vertical position offset of the maximize/restore button.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="minimize_h_offset" data_type="constant" type="int" default="54">
Horizontal position offset of the minimize button.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="minimize_v_offset" data_type="constant" type="int" default="20">
Vertical position offset of the minimize button.
[b]Note:[/b] Used only when extend to title is active.
</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 +969,46 @@
<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 button.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="maximize_disabled" data_type="icon" type="Texture2D">
The icon for the maximize button when disabled (window not resizable).
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="maximize_pressed" data_type="icon" type="Texture2D">
The icon for the maximize button when it's being pressed.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="minimize" data_type="icon" type="Texture2D">
The icon for the minimize button.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="minimize_pressed" data_type="icon" type="Texture2D">
The icon for the minimize button when it's being pressed.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="restore" data_type="icon" type="Texture2D">
The icon for the restore button.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="restore_pressed" data_type="icon" type="Texture2D">
The icon for the restore button when it's being pressed.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="decoration_button_hover" data_type="style" type="StyleBox">
The background style used of the window buttons when the mouse pointer is hovering them.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="decoration_button_normal" data_type="style" type="StyleBox">
The background style used of the window buttons.
[b]Note:[/b] Used only when extend to title is active.
</theme_item>
<theme_item name="decoration_button_pressed" data_type="style" type="StyleBox">
The background style used of the window buttons when they are being pressed.
[b]Note:[/b] Used only when extend to title is active.
</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
24 changes: 17 additions & 7 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,18 +1266,23 @@ 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;
}

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));

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 Expand Up @@ -5411,6 +5416,11 @@ void EditorNode::_save_window_settings_to_config(Ref<ConfigFile> p_layout, const
break;
}

// Saving the extend to title to set the correct window flag on startup
// otherwise the window size will be corrected to a "normal" window causing
// it to move up.
p_layout->set_value(p_section, "extend_to_title", w->get_flag(Window::FLAG_EXTEND_TO_TITLE));

p_layout->set_value(p_section, "position", w->get_position());
}
}
Expand Down
1 change: 1 addition & 0 deletions editor/icons/GuiMaximize.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/GuiMinimize.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/GuiRestore.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 12 additions & 9 deletions editor/project_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,20 +1020,23 @@ 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;
}

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));

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
44 changes: 37 additions & 7 deletions editor/themes/editor_theme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,19 +1271,49 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
// Window and dialogs.
{
// Window.

p_theme->set_stylebox("embedded_border", "Window", p_config.window_style);
p_theme->set_stylebox("embedded_unfocused_border", "Window", p_config.window_style);

p_theme->set_font("title_font", "Window", p_theme->get_font(SNAME("title"), EditorStringName(EditorFonts)));
p_theme->set_color("title_color", "Window", p_config.font_color);
p_theme->set_icon("close", "Window", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
p_theme->set_icon("close_pressed", "Window", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
p_theme->set_constant("close_h_offset", "Window", 22 * EDSCALE);
p_theme->set_constant("close_v_offset", "Window", 20 * EDSCALE);
p_theme->set_constant("title_height", "Window", 24 * EDSCALE);
p_theme->set_constant("resize_margin", "Window", 4 * EDSCALE);
p_theme->set_font("title_font", "Window", p_theme->get_font(SNAME("title"), EditorStringName(EditorFonts)));
p_theme->set_font_size("title_font_size", "Window", p_theme->get_font_size(SNAME("title_size"), EditorStringName(EditorFonts)));
p_theme->set_constant("resize_margin", "Window", 4 * EDSCALE);

Ref<StyleBoxFlat> decoration_button_normal = p_config.button_style->duplicate();
decoration_button_normal->set_content_margin_all(0);
decoration_button_normal->set_corner_radius_all(0);
p_theme->set_stylebox("decoration_button_normal", "Window", decoration_button_normal);

Ref<StyleBoxFlat> decoration_button_hover = p_config.button_style_hover->duplicate();
decoration_button_hover->set_content_margin_all(0);
decoration_button_hover->set_corner_radius_all(0);
p_theme->set_stylebox("decoration_button_hover", "Window", decoration_button_hover);

Ref<StyleBoxFlat> decoration_button_pressed = p_config.button_style_pressed->duplicate();
decoration_button_pressed->set_content_margin_all(0);
decoration_button_pressed->set_corner_radius_all(0);
p_theme->set_stylebox("decoration_button_pressed", "Window", decoration_button_pressed);

p_theme->set_color("decoration_button_normal_modulate", "Window", p_config.font_color);
p_theme->set_color("decoration_button_hover_modulate", "Window", p_config.font_hover_color);
p_theme->set_color("decoration_button_pressed_modulate", "Window", p_config.font_pressed_color);

p_theme->set_icon("minimize", "Window", p_theme->get_icon(SNAME("GuiMinimize"), EditorStringName(EditorIcons)));
p_theme->set_icon("minimize_pressed", "Window", p_theme->get_icon(SNAME("GuiMinimize"), EditorStringName(EditorIcons)));
p_theme->set_constant("minimize_h_offset", "Window", 108 * EDSCALE);
p_theme->set_constant("minimize_v_offset", "Window", 36 * EDSCALE);
p_theme->set_icon("maximize", "Window", p_theme->get_icon(SNAME("GuiMaximize"), EditorStringName(EditorIcons)));
p_theme->set_icon("maximize_pressed", "Window", p_theme->get_icon(SNAME("GuiMaximize"), EditorStringName(EditorIcons)));
p_theme->set_icon("maximize_disabled", "Window", p_theme->get_icon(SNAME("GuiMaximize"), EditorStringName(EditorIcons)));
p_theme->set_icon("restore", "Window", p_theme->get_icon(SNAME("GuiRestore"), EditorStringName(EditorIcons)));
p_theme->set_icon("restore_pressed", "Window", p_theme->get_icon(SNAME("GuiRestore"), EditorStringName(EditorIcons)));
p_theme->set_constant("maximize_h_offset", "Window", 72 * EDSCALE);
p_theme->set_constant("maximize_v_offset", "Window", 36 * EDSCALE);
p_theme->set_icon("close", "Window", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
p_theme->set_icon("close_pressed", "Window", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
p_theme->set_constant("close_h_offset", "Window", 36 * EDSCALE);
p_theme->set_constant("close_v_offset", "Window", 36 * EDSCALE);

// AcceptDialog.
p_theme->set_stylebox(SceneStringName(panel), "AcceptDialog", p_config.dialog_style);
Expand Down
4 changes: 4 additions & 0 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2807,6 +2807,10 @@ Error Main::setup2(bool p_show_boot_logo) {
init_use_custom_pos = true;
init_custom_pos = config->get_value("EditorWindow", "position", Vector2i(0, 0));
}

if (config->get_value("EditorWindow", "extend_to_title", false)) {
window_flags |= DisplayServer::WINDOW_FLAG_EXTEND_TO_TITLE_BIT;
}
}
}

Expand Down
Loading

0 comments on commit 62041d7

Please sign in to comment.