Skip to content

Commit 0a875ab

Browse files
committed
Highlight hovered GraphEdit connection by widening the line
This change causes the connections to be additionally highlighted by widening the line with a configurable factor.
1 parent 4364ed6 commit 0a875ab

File tree

5 files changed

+11
-0
lines changed

5 files changed

+11
-0
lines changed

doc/classes/GraphEdit.xml

+3
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,9 @@
551551
<theme_item name="selection_stroke" data_type="color" type="Color" default="Color(1, 1, 1, 0.8)">
552552
The outline color of the selection rectangle.
553553
</theme_item>
554+
<theme_item name="connection_hover_thickness" data_type="constant" type="int" default="0">
555+
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.
556+
</theme_item>
554557
<theme_item name="port_hotzone_inner_extent" data_type="constant" type="int" default="22">
555558
The horizontal range within which a port can be grabbed (inner side).
556559
</theme_item>

editor/themes/editor_theme_manager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
15631563
p_theme->set_color("activity", "GraphEdit", p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0));
15641564

15651565
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));
1566+
p_theme->set_constant("connection_hover_thickness", "GraphEdit", 0);
15661567
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));
15671568
p_theme->set_color("connection_rim_color", "GraphEdit", p_config.tree_panel_style->get_bg_color());
15681569

scene/gui/graph_edit.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,10 @@ void GraphEdit::_update_connections() {
14531453
Ref<Gradient> line_gradient = memnew(Gradient);
14541454

14551455
float line_width = _get_shader_line_width();
1456+
if (conn == hovered_connection) {
1457+
line_width *= 1.0f + (theme_cache.connection_hover_thickness / 100.0f);
1458+
}
1459+
14561460
conn->_cache.line->set_width(line_width);
14571461
line_gradient->set_color(0, from_color);
14581462
line_gradient->set_color(1, to_color);
@@ -2842,6 +2846,7 @@ void GraphEdit::_bind_methods() {
28422846

28432847
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_COLOR, GraphEdit, activity_color, "activity");
28442848
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, GraphEdit, connection_hover_tint_color);
2849+
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, GraphEdit, connection_hover_thickness);
28452850
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, GraphEdit, connection_valid_target_tint_color);
28462851
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, GraphEdit, connection_rim_color);
28472852
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, GraphEdit, selection_fill);

scene/gui/graph_edit.h

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ class GraphEdit : public Control {
275275

276276
Color activity_color;
277277
Color connection_hover_tint_color;
278+
int connection_hover_thickness;
278279
Color connection_valid_target_tint_color;
279280
Color connection_rim_color;
280281

scene/theme/default_theme.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
12571257
theme->set_color("selection_stroke", "GraphEdit", Color(1, 1, 1, 0.8));
12581258
theme->set_color("activity", "GraphEdit", Color(1, 1, 1));
12591259
theme->set_color("connection_hover_tint_color", "GraphEdit", Color(0, 0, 0, 0.3));
1260+
theme->set_constant("connection_hover_thickness", "GraphEdit", 0);
12601261
theme->set_color("connection_valid_target_tint_color", "GraphEdit", Color(1, 1, 1, 0.4));
12611262
theme->set_color("connection_rim_color", "GraphEdit", style_normal_color);
12621263

0 commit comments

Comments
 (0)