summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-07-04 23:27:03 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-07-04 23:27:03 +0200
commit5c84398c155e04808aad2fb9eb9088077d7367dd (patch)
treee215b85eb3a9010fdf18029cbfeef709e1f41495
parent4d984b63697d840f2c823608d2c46740fb44651a (diff)
parentb8717945910393f2ecfa9b8db8ac5fdb7c5f1419 (diff)
downloadredot-engine-5c84398c155e04808aad2fb9eb9088077d7367dd.tar.gz
Merge pull request #93903 from Geometror/vs-fix-frame-edscale
Fix some VisualShader features for high DPI displays/custom UI scales
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp5
-rw-r--r--editor/themes/editor_theme_manager.cpp4
-rw-r--r--scene/gui/graph_edit.cpp4
-rw-r--r--scene/gui/graph_frame.cpp4
-rw-r--r--scene/gui/graph_frame.h1
5 files changed, 13 insertions, 5 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 607c446e1b..2f36198b23 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -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);
diff --git a/editor/themes/editor_theme_manager.cpp b/editor/themes/editor_theme_manager.cpp
index 9f0865d950..03752656c0 100644
--- a/editor/themes/editor_theme_manager.cpp
+++ b/editor/themes/editor_theme_manager.cpp
@@ -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);
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 33756dc1fd..429fb2e64f 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -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);
diff --git a/scene/gui/graph_frame.cpp b/scene/gui/graph_frame.cpp
index 8cd7dbbeb5..e85d007262 100644
--- a/scene/gui/graph_frame.cpp
+++ b/scene/gui/graph_frame.cpp
@@ -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;
}
diff --git a/scene/gui/graph_frame.h b/scene/gui/graph_frame.h
index 21346586c8..2af09cf872 100644
--- a/scene/gui/graph_frame.h
+++ b/scene/gui/graph_frame.h
@@ -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;