1
0
Fork 0

Merge pull request #100456 from Sauermann/proposal-hovered-connection-highlight

Highlight hovered `GraphEdit` connection by widening the line
This commit is contained in:
Thaddeus Crews 2024-12-19 20:00:08 -06:00
commit 075567a5b3
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84
5 changed files with 11 additions and 0 deletions

View File

@ -551,6 +551,9 @@
<theme_item name="selection_stroke" data_type="color" type="Color" default="Color(1, 1, 1, 0.8)">
The outline color of the selection rectangle.
</theme_item>
<theme_item name="connection_hover_thickness" data_type="constant" type="int" default="0">
Widen the line of the connection when the mouse is hovering over it by a percentage factor. A value of [code]0[/code] disables the highlight. A value of [code]100[/code] doubles the line width.
</theme_item>
<theme_item name="port_hotzone_inner_extent" data_type="constant" type="int" default="22">
The horizontal range within which a port can be grabbed (inner side).
</theme_item>

View File

@ -1563,6 +1563,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
p_theme->set_color("activity", "GraphEdit", p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0));
p_theme->set_color("connection_hover_tint_color", "GraphEdit", p_config.dark_theme ? Color(0, 0, 0, 0.3) : Color(1, 1, 1, 0.3));
p_theme->set_constant("connection_hover_thickness", "GraphEdit", 0);
p_theme->set_color("connection_valid_target_tint_color", "GraphEdit", p_config.dark_theme ? Color(1, 1, 1, 0.4) : Color(0, 0, 0, 0.4));
p_theme->set_color("connection_rim_color", "GraphEdit", p_config.tree_panel_style->get_bg_color());

View File

@ -1457,6 +1457,10 @@ void GraphEdit::_update_connections() {
Ref<Gradient> line_gradient = memnew(Gradient);
float line_width = _get_shader_line_width();
if (conn == hovered_connection) {
line_width *= 1.0f + (theme_cache.connection_hover_thickness / 100.0f);
}
conn->_cache.line->set_width(line_width);
line_gradient->set_color(0, from_color);
line_gradient->set_color(1, to_color);
@ -2846,6 +2850,7 @@ void GraphEdit::_bind_methods() {
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_COLOR, GraphEdit, activity_color, "activity");
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, GraphEdit, connection_hover_tint_color);
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, GraphEdit, connection_hover_thickness);
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, GraphEdit, connection_valid_target_tint_color);
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, GraphEdit, connection_rim_color);
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, GraphEdit, selection_fill);

View File

@ -275,6 +275,7 @@ private:
Color activity_color;
Color connection_hover_tint_color;
int connection_hover_thickness;
Color connection_valid_target_tint_color;
Color connection_rim_color;

View File

@ -1257,6 +1257,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("selection_stroke", "GraphEdit", Color(1, 1, 1, 0.8));
theme->set_color("activity", "GraphEdit", Color(1, 1, 1));
theme->set_color("connection_hover_tint_color", "GraphEdit", Color(0, 0, 0, 0.3));
theme->set_constant("connection_hover_thickness", "GraphEdit", 0);
theme->set_color("connection_valid_target_tint_color", "GraphEdit", Color(1, 1, 1, 0.4));
theme->set_color("connection_rim_color", "GraphEdit", style_normal_color);