Merge pull request #93903 from Geometror/vs-fix-frame-edscale

Fix some VisualShader features for high DPI displays/custom UI scales
This commit is contained in:
Rémi Verschelde 2024-07-04 23:27:03 +02:00
commit 5c84398c15
No known key found for this signature in database
GPG key ID: C3336907360768E1
5 changed files with 13 additions and 5 deletions

View file

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

View file

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

View file

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

View file

@ -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;
}

View file

@ -89,6 +89,7 @@ public:
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;