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

Fix some VisualShader features for high DPI displays/custom UI scales #93903

Merged
merged 1 commit into from
Jul 4, 2024
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
5 changes: 3 additions & 2 deletions editor/plugins/visual_shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ void VSRerouteNode::_notification(int p_what) {
connect(SceneStringName(mouse_exited), callable_mp(this, &VSRerouteNode::_on_mouse_exited));
} break;
case NOTIFICATION_DRAW: {
Vector2 offset = Vector2(0, -16);
Vector2 offset = Vector2(0, -16 * EDSCALE);
Color drag_bg_color = get_theme_color(SNAME("drag_background"), SNAME("VSRerouteNode"));
draw_circle(get_size() * 0.5 + offset, 16, Color(drag_bg_color, selected ? 1 : icon_opacity));
draw_circle(get_size() * 0.5 + offset, 16 * EDSCALE, Color(drag_bg_color, selected ? 1 : icon_opacity), true, -1, true);

Ref<Texture2D> icon = get_editor_theme_icon(SNAME("ToolMove"));
Point2 icon_offset = -icon->get_size() * 0.5 + get_size() * 0.5 + offset;
Expand All @@ -154,6 +154,7 @@ VSRerouteNode::VSRerouteNode() {
title_lbl->hide();

const Size2 size = Size2(32, 32) * EDSCALE;
print_line("VSRerouteNode size: " + size);

Control *slot_area = memnew(Control);
slot_area->set_custom_minimum_size(size);
Expand Down
4 changes: 2 additions & 2 deletions editor/themes/editor_theme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
// GraphFrame's title Label.
p_theme->set_type_variation("GraphFrameTitleLabel", "Label");
p_theme->set_stylebox(CoreStringName(normal), "GraphFrameTitleLabel", memnew(StyleBoxEmpty));
p_theme->set_font_size(SceneStringName(font_size), "GraphFrameTitleLabel", 22);
p_theme->set_font_size(SceneStringName(font_size), "GraphFrameTitleLabel", 22 * EDSCALE);
p_theme->set_color(SceneStringName(font_color), "GraphFrameTitleLabel", Color(1, 1, 1));
p_theme->set_color("font_shadow_color", "GraphFrameTitleLabel", Color(0, 0, 0, 0));
p_theme->set_color("font_outline_color", "GraphFrameTitleLabel", Color(1, 1, 1));
Expand All @@ -1680,7 +1680,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
{
Ref<StyleBox> vs_reroute_panel_style = make_empty_stylebox();
Ref<StyleBox> vs_reroute_titlebar_style = vs_reroute_panel_style->duplicate();
vs_reroute_titlebar_style->set_content_margin_all(16);
vs_reroute_titlebar_style->set_content_margin_all(16 * EDSCALE);
p_theme->set_stylebox(SceneStringName(panel), "VSRerouteNode", vs_reroute_panel_style);
p_theme->set_stylebox("panel_selected", "VSRerouteNode", vs_reroute_panel_style);
p_theme->set_stylebox("titlebar", "VSRerouteNode", vs_reroute_titlebar_style);
Expand Down
4 changes: 3 additions & 1 deletion scene/gui/graph_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,9 @@ Rect2 GraphEdit::_compute_shrinked_frame_rect(const GraphFrame *p_frame) {
return Rect2(p_frame->get_position_offset(), Size2());
}

min_point -= Size2(autoshrink_margin, autoshrink_margin);
const Size2 titlebar_size = p_frame->get_titlebar_size();

min_point -= Size2(autoshrink_margin, MAX(autoshrink_margin, titlebar_size.y));
max_point += Size2(autoshrink_margin, autoshrink_margin);

return Rect2(min_point, max_point - min_point);
Expand Down
4 changes: 4 additions & 0 deletions scene/gui/graph_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ HBoxContainer *GraphFrame::get_titlebar_hbox() {
return titlebar_hbox;
}

Size2 GraphFrame::get_titlebar_size() const {
return titlebar_hbox->get_size() + theme_cache.titlebar->get_minimum_size();
}

void GraphFrame::set_drag_margin(int p_margin) {
drag_margin = p_margin;
}
Expand Down
1 change: 1 addition & 0 deletions scene/gui/graph_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class GraphFrame : public GraphElement {
int get_autoshrink_margin() const;

HBoxContainer *get_titlebar_hbox();
Size2 get_titlebar_size() const;

void set_drag_margin(int p_margin);
int get_drag_margin() const;
Expand Down
Loading