Merge pull request #50961 from YeldhamDev/embed_windows_fixes

Multiple cosmetic fixes for embedded windows
This commit is contained in:
Rémi Verschelde 2021-07-28 18:24:07 +02:00 committed by GitHub
commit 60eb508fbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 99 additions and 92 deletions

View file

@ -105,4 +105,9 @@
</signals>
<constants>
</constants>
<theme_items>
<theme_item name="panel" type="StyleBox">
Panel that fills up the background of the window.
</theme_item>
</theme_items>
</class>

View file

@ -469,11 +469,11 @@
</theme_item>
<theme_item name="close_h_ofs" type="int" default="18">
</theme_item>
<theme_item name="close_highlight" type="Texture2D">
<theme_item name="close_pressed" type="Texture2D">
</theme_item>
<theme_item name="close_v_ofs" type="int" default="18">
</theme_item>
<theme_item name="panel" type="StyleBox">
<theme_item name="embedded_border" type="StyleBox">
</theme_item>
<theme_item name="resize_margin" type="int" default="4">
</theme_item>
@ -494,7 +494,5 @@
<theme_item name="title_outline_size" type="int" default="0">
The size of the title outline.
</theme_item>
<theme_item name="window_panel" type="StyleBox">
</theme_item>
</theme_items>
</class>

View file

@ -1086,17 +1086,16 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
style_window_title->set_corner_radius(CORNER_TOP_RIGHT, 0);
// Prevent visible line between window title and body.
style_window_title->set_expand_margin_size(SIDE_BOTTOM, 2 * EDSCALE);
theme->set_stylebox("panel", "Window", style_window_title);
Ref<StyleBoxFlat> style_window = style_popup->duplicate();
style_window->set_border_color(base_color);
style_window->set_border_width(SIDE_TOP, 24 * EDSCALE);
style_window->set_expand_margin_size(SIDE_TOP, 24 * EDSCALE);
theme->set_stylebox("panel_window", "Window", style_window);
theme->set_stylebox("embedded_border", "Window", style_window);
theme->set_color("title_color", "Window", font_color);
theme->set_icon("close", "Window", theme->get_icon("GuiClose", "EditorIcons"));
theme->set_icon("close_highlight", "Window", theme->get_icon("GuiClose", "EditorIcons"));
theme->set_icon("close_pressed", "Window", theme->get_icon("GuiClose", "EditorIcons"));
theme->set_constant("close_h_ofs", "Window", 22 * EDSCALE);
theme->set_constant("close_v_ofs", "Window", 20 * EDSCALE);
theme->set_constant("title_height", "Window", 24 * EDSCALE);
@ -1112,6 +1111,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("panel", "ProjectSettingsEditor", style_complex_window);
theme->set_stylebox("panel", "EditorAbout", style_complex_window);
// AcceptDialog
theme->set_stylebox("panel", "AcceptDialog", style_window_title);
// HScrollBar
Ref<Texture2D> empty_icon = memnew(ImageTexture);

View file

@ -72,13 +72,10 @@ void AcceptDialog::_notification(int p_what) {
parent_visible = nullptr;
}
}
} break;
case NOTIFICATION_THEME_CHANGED: {
bg->add_theme_style_override("panel", bg->get_theme_stylebox(SNAME("panel"), SNAME("AcceptDialog")));
} break;
case NOTIFICATION_EXIT_TREE: {
if (parent_visible) {
parent_visible->disconnect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));

View file

@ -249,7 +249,7 @@ void Viewport::_sub_window_update(Window *p_window) {
Rect2i r = Rect2i(p_window->get_position(), sw.window->get_size());
if (!p_window->get_flag(Window::FLAG_BORDERLESS)) {
Ref<StyleBox> panel = p_window->get_theme_stylebox(SNAME("panel_window"));
Ref<StyleBox> panel = p_window->get_theme_stylebox(SNAME("embedded_border"));
panel->draw(sw.canvas_item, r);
// Draw the title bar text.
@ -273,9 +273,8 @@ void Viewport::_sub_window_update(Window *p_window) {
}
title_text.draw(sw.canvas_item, r.position + Point2(x, y), title_color);
bool hl = gui.subwindow_focused == sw.window && gui.subwindow_drag == SUB_WINDOW_DRAG_CLOSE && gui.subwindow_drag_close_inside;
Ref<Texture2D> close_icon = p_window->get_theme_icon(hl ? "close_highlight" : "close");
bool pressed = gui.subwindow_focused == sw.window && gui.subwindow_drag == SUB_WINDOW_DRAG_CLOSE && gui.subwindow_drag_close_inside;
Ref<Texture2D> close_icon = p_window->get_theme_icon(pressed ? "close_pressed" : "close");
close_icon->draw(sw.canvas_item, r.position + Vector2(r.size.width - close_h_ofs, -close_v_ofs));
}

View file

@ -700,7 +700,8 @@ Viewport *Window::_get_embedder() const {
}
void Window::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
bool embedded = false;
{
embedder = _get_embedder();
@ -753,19 +754,16 @@ void Window::_notification(int p_what) {
emit_signal(SceneStringNames::get_singleton()->visibility_changed);
RS::get_singleton()->viewport_set_active(get_viewport_rid(), true);
}
}
if (p_what == NOTIFICATION_READY) {
} break;
case NOTIFICATION_READY: {
if (wrap_controls) {
_update_child_controls();
}
}
if (p_what == NOTIFICATION_TRANSLATION_CHANGED) {
} break;
case NOTIFICATION_TRANSLATION_CHANGED: {
child_controls_changed();
}
if (p_what == NOTIFICATION_EXIT_TREE) {
} break;
case NOTIFICATION_EXIT_TREE: {
if (transient) {
_clear_transient();
}
@ -787,6 +785,7 @@ void Window::_notification(int p_what) {
}
RS::get_singleton()->viewport_set_active(get_viewport_rid(), false);
} break;
}
}

View file

@ -571,10 +571,9 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
empty.instantiate();
theme->set_stylebox("bg", "ScrollContainer", empty);
// WindowDialog
// Window
theme->set_stylebox("panel", "Window", default_style);
theme->set_stylebox("window_panel", "Window", sb_expand(make_stylebox(popup_window_png, 10, 26, 10, 8), 8, 24, 8, 6));
theme->set_stylebox("embedded_border", "Window", sb_expand(make_stylebox(popup_window_png, 10, 26, 10, 8), 8, 24, 8, 6));
theme->set_constant("scaleborder_size", "Window", 4 * scale);
theme->set_font("title_font", "Window", large_font);
@ -588,10 +587,14 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("resize_margin", "Window", 4 * scale);
theme->set_icon("close", "Window", make_icon(close_png));
theme->set_icon("close_highlight", "Window", make_icon(close_hl_png));
theme->set_icon("close_pressed", "Window", make_icon(close_hl_png));
theme->set_constant("close_h_ofs", "Window", 18 * scale);
theme->set_constant("close_v_ofs", "Window", 18 * scale);
// AcceptDialog
theme->set_stylebox("panel", "AcceptDialog", make_stylebox(dialog_bg_png, 0, 0, 0, 0));
// File Dialog
theme->set_icon("parent_folder", "FileDialog", make_icon(icon_parent_folder_png));

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 903 B

After

Width:  |  Height:  |  Size: 921 B

File diff suppressed because one or more lines are too long