1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Clean up/refactor GraphNode and make it more flexible

Split GraphNode into GraphElement and GraphNode, add custom
titlebar, and adjust theming.
This commit is contained in:
Hendrik Brucker
2023-08-09 18:31:15 +02:00
parent 08c578c54c
commit 5afe78bd9c
26 changed files with 1600 additions and 1537 deletions

View File

@@ -699,40 +699,43 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("icon_max_width", "PopupMenu", 0);
// GraphNode
Ref<StyleBoxFlat> graphnode_normal = make_flat_stylebox(style_normal_color, 18, 42, 18, 12);
graphnode_normal->set_border_width(SIDE_TOP, 30);
Ref<StyleBoxFlat> graphnode_normal = make_flat_stylebox(style_normal_color, 18, 12, 18, 12);
graphnode_normal->set_border_color(Color(0.325, 0.325, 0.325, 0.6));
Ref<StyleBoxFlat> graphnode_selected = graphnode_normal->duplicate();
graphnode_selected->set_border_color(Color(0.625, 0.625, 0.625, 0.6));
Ref<StyleBoxFlat> graphnode_comment_normal = make_flat_stylebox(style_pressed_color, 18, 42, 18, 12, 3, true, 2);
graphnode_comment_normal->set_border_color(style_pressed_color);
Ref<StyleBoxFlat> graphnode_comment_selected = graphnode_comment_normal->duplicate();
graphnode_comment_selected->set_border_color(style_hover_color);
Ref<StyleBoxFlat> graphnode_breakpoint = make_flat_stylebox(style_pressed_color, 18, 42, 18, 12, 6, true, 4);
graphnode_breakpoint->set_border_color(Color(0.9, 0.29, 0.3));
Ref<StyleBoxFlat> graphnode_position = make_flat_stylebox(style_pressed_color, 18, 42, 18, 12, 6, true, 4);
graphnode_position->set_border_color(Color(0.98, 0.89, 0.27));
Ref<StyleBoxFlat> graphn_sb_titlebar = make_flat_stylebox(style_normal_color.lightened(0.3), 4, 4, 4, 4);
Ref<StyleBoxFlat> graphn_sb_titlebar_selected = graphnode_normal->duplicate();
graphn_sb_titlebar_selected->set_bg_color(Color(1.0, 0.625, 0.625, 0.6));
Ref<StyleBoxEmpty> graphnode_slot = make_empty_stylebox(0, 0, 0, 0);
theme->set_stylebox("frame", "GraphNode", graphnode_normal);
theme->set_stylebox("selected_frame", "GraphNode", graphnode_selected);
theme->set_stylebox("breakpoint", "GraphNode", graphnode_breakpoint);
theme->set_stylebox("position", "GraphNode", graphnode_position);
theme->set_stylebox("panel", "GraphNode", graphnode_normal);
theme->set_stylebox("panel_selected", "GraphNode", graphnode_selected);
theme->set_stylebox("titlebar", "GraphNode", graphn_sb_titlebar);
theme->set_stylebox("titlebar_selected", "GraphNode", graphn_sb_titlebar_selected);
theme->set_stylebox("slot", "GraphNode", graphnode_slot);
theme->set_icon("port", "GraphNode", icons["graph_port"]);
theme->set_icon("close", "GraphNode", icons["close"]);
theme->set_icon("resizer", "GraphNode", icons["resizer_se"]);
theme->set_font("title_font", "GraphNode", Ref<Font>());
theme->set_color("title_color", "GraphNode", control_font_color);
theme->set_color("close_color", "GraphNode", control_font_color);
theme->set_color("resizer_color", "GraphNode", control_font_color);
theme->set_constant("separation", "GraphNode", Math::round(2 * scale));
theme->set_constant("title_offset", "GraphNode", Math::round(26 * scale));
theme->set_constant("title_h_offset", "GraphNode", 0);
theme->set_constant("close_offset", "GraphNode", Math::round(22 * scale));
theme->set_constant("close_h_offset", "GraphNode", Math::round(12 * scale));
theme->set_constant("port_offset", "GraphNode", 0);
theme->set_constant("port_h_offset", "GraphNode", 0);
// GraphNodes's title Label.
theme->set_type_variation("GraphNodeTitleLabel", "Label");
theme->set_stylebox("normal", "GraphNodeTitleLabel", make_empty_stylebox(0, 0, 0, 0));
theme->set_font("font", "GraphNodeTitleLabel", Ref<Font>());
theme->set_font_size("font_size", "GraphNodeTitleLabel", -1);
theme->set_color("font_color", "GraphNodeTitleLabel", control_font_color);
theme->set_color("font_shadow_color", "GraphNodeTitleLabel", Color(0, 0, 0, 0));
theme->set_color("font_outline_color", "GraphNodeTitleLabel", control_font_color);
theme->set_constant("shadow_offset_x", "GraphNodeTitleLabel", Math::round(1 * scale));
theme->set_constant("shadow_offset_y", "GraphNodeTitleLabel", Math::round(1 * scale));
theme->set_constant("outline_size", "GraphNodeTitleLabel", 0);
theme->set_constant("shadow_outline_size", "GraphNodeTitleLabel", Math::round(1 * scale));
theme->set_constant("line_spacing", "GraphNodeTitleLabel", Math::round(3 * scale));
// Tree