mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 20:23:53 +00:00
Merge pull request #61541 from Geometror/graphedit-connections-improvements
This commit is contained in:
commit
3df8296d8d
@ -202,6 +202,9 @@
|
||||
<member name="connection_lines_antialiased" type="bool" setter="set_connection_lines_antialiased" getter="is_connection_lines_antialiased" default="true">
|
||||
If [code]true[/code], the lines between nodes will use antialiasing.
|
||||
</member>
|
||||
<member name="connection_lines_curvature" type="float" setter="set_connection_lines_curvature" getter="get_connection_lines_curvature" default="0.5">
|
||||
The curvature of the lines between the nodes. 0 results in straight lines.
|
||||
</member>
|
||||
<member name="connection_lines_thickness" type="float" setter="set_connection_lines_thickness" getter="get_connection_lines_thickness" default="2.0">
|
||||
The thickness of the lines between the nodes.
|
||||
</member>
|
||||
@ -372,10 +375,6 @@
|
||||
<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="bezier_len_neg" data_type="constant" type="int" default="160">
|
||||
</theme_item>
|
||||
<theme_item name="bezier_len_pos" data_type="constant" type="int" default="80">
|
||||
</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>
|
||||
|
@ -681,6 +681,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
||||
|
||||
// Visual editors
|
||||
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/visual_editors/minimap_opacity", 0.85, "0.0,1.0,0.01")
|
||||
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "editors/visual_editors/lines_curvature", 0.5, "0.0,1.0,0.01")
|
||||
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "editors/visual_editors/visualshader/port_preview_size", 160, "100,400,0.01")
|
||||
|
||||
/* Run */
|
||||
|
@ -1446,8 +1446,6 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
|
||||
theme->set_icon("snap", "GraphEdit", theme->get_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
|
||||
theme->set_icon("minimap", "GraphEdit", theme->get_icon(SNAME("GridMinimap"), SNAME("EditorIcons")));
|
||||
theme->set_icon("layout", "GraphEdit", theme->get_icon(SNAME("GridLayout"), SNAME("EditorIcons")));
|
||||
theme->set_constant("bezier_len_pos", "GraphEdit", 80 * EDSCALE);
|
||||
theme->set_constant("bezier_len_neg", "GraphEdit", 160 * EDSCALE);
|
||||
|
||||
// GraphEditMinimap
|
||||
Ref<StyleBoxFlat> style_minimap_bg = make_flat_stylebox(dark_color_1, 0, 0, 0, 0);
|
||||
|
@ -264,6 +264,8 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
|
||||
|
||||
float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity");
|
||||
graph->set_minimap_opacity(graph_minimap_opacity);
|
||||
float graph_lines_curvature = EditorSettings::get_singleton()->get("editors/visual_editors/lines_curvature");
|
||||
graph->set_connection_lines_curvature(graph_lines_curvature);
|
||||
}
|
||||
|
||||
void AnimationNodeBlendTreeEditor::_file_opened(const String &p_file) {
|
||||
@ -969,6 +971,8 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
|
||||
graph->connect("connection_from_empty", callable_mp(this, &AnimationNodeBlendTreeEditor::_connection_from_empty));
|
||||
float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity");
|
||||
graph->set_minimap_opacity(graph_minimap_opacity);
|
||||
float graph_lines_curvature = EditorSettings::get_singleton()->get("editors/visual_editors/lines_curvature");
|
||||
graph->set_connection_lines_curvature(graph_lines_curvature);
|
||||
|
||||
VSeparator *vs = memnew(VSeparator);
|
||||
graph->get_zoom_hbox()->add_child(vs);
|
||||
|
@ -1745,6 +1745,8 @@ void VisualShaderEditor::_update_graph() {
|
||||
|
||||
float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity");
|
||||
graph->set_minimap_opacity(graph_minimap_opacity);
|
||||
float graph_lines_curvature = EditorSettings::get_singleton()->get("editors/visual_editors/lines_curvature");
|
||||
graph->set_connection_lines_curvature(graph_lines_curvature);
|
||||
}
|
||||
|
||||
VisualShader::Type VisualShaderEditor::get_current_shader_type() const {
|
||||
@ -4675,6 +4677,8 @@ VisualShaderEditor::VisualShaderEditor() {
|
||||
graph->set_drag_forwarding(this);
|
||||
float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity");
|
||||
graph->set_minimap_opacity(graph_minimap_opacity);
|
||||
float graph_lines_curvature = EditorSettings::get_singleton()->get("editors/visual_editors/lines_curvature");
|
||||
graph->set_connection_lines_curvature(graph_lines_curvature);
|
||||
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SCALAR);
|
||||
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SCALAR_INT);
|
||||
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_BOOLEAN);
|
||||
|
@ -980,6 +980,9 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
|
||||
float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity");
|
||||
graph->set_minimap_opacity(graph_minimap_opacity);
|
||||
|
||||
float graph_lines_curvature = EditorSettings::get_singleton()->get("editors/visual_editors/lines_curvature");
|
||||
graph->set_connection_lines_curvature(graph_lines_curvature);
|
||||
|
||||
// Use default_func instead of default_func for now I think that should be good stop gap solution to ensure not breaking anything.
|
||||
graph->call_deferred(SNAME("set_scroll_ofs"), script->get_scroll() * EDSCALE);
|
||||
updating_graph = false;
|
||||
@ -4593,6 +4596,8 @@ VisualScriptEditor::VisualScriptEditor() {
|
||||
graph->set_drag_forwarding(this);
|
||||
float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity");
|
||||
graph->set_minimap_opacity(graph_minimap_opacity);
|
||||
float graph_lines_curvature = EditorSettings::get_singleton()->get("editors/visual_editors/lines_curvature");
|
||||
graph->set_connection_lines_curvature(graph_lines_curvature);
|
||||
graph->hide();
|
||||
graph->connect("scroll_offset_changed", callable_mp(this, &VisualScriptEditor::_graph_ofs_changed));
|
||||
|
||||
|
@ -857,13 +857,23 @@ PackedVector2Array GraphEdit::get_connection_line(const Vector2 &p_from, const V
|
||||
return ret;
|
||||
}
|
||||
|
||||
float x_diff = (p_to.x - p_from.x);
|
||||
float cp_offset = x_diff * lines_curvature;
|
||||
if (x_diff < 0) {
|
||||
cp_offset *= -1;
|
||||
}
|
||||
|
||||
Curve2D curve;
|
||||
Vector<Color> colors;
|
||||
curve.add_point(p_from);
|
||||
curve.set_point_out(0, Vector2(60, 0));
|
||||
curve.set_point_out(0, Vector2(cp_offset, 0));
|
||||
curve.add_point(p_to);
|
||||
curve.set_point_in(1, Vector2(-60, 0));
|
||||
return curve.tessellate();
|
||||
curve.set_point_in(1, Vector2(-cp_offset, 0));
|
||||
|
||||
if (lines_curvature > 0) {
|
||||
return curve.tessellate(5, 2.0);
|
||||
} else {
|
||||
return curve.tessellate(1);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphEdit::_draw_connection_line(CanvasItem *p_where, const Vector2 &p_from, const Vector2 &p_to, const Color &p_color, const Color &p_to_color, float p_width, float p_zoom) {
|
||||
@ -1684,6 +1694,15 @@ void GraphEdit::_minimap_toggled() {
|
||||
}
|
||||
}
|
||||
|
||||
void GraphEdit::set_connection_lines_curvature(float p_curvature) {
|
||||
lines_curvature = p_curvature;
|
||||
update();
|
||||
}
|
||||
|
||||
float GraphEdit::get_connection_lines_curvature() const {
|
||||
return lines_curvature;
|
||||
}
|
||||
|
||||
void GraphEdit::set_connection_lines_thickness(float p_thickness) {
|
||||
lines_thickness = p_thickness;
|
||||
update();
|
||||
@ -2262,6 +2281,9 @@ void GraphEdit::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_use_snap", "enable"), &GraphEdit::set_use_snap);
|
||||
ClassDB::bind_method(D_METHOD("is_using_snap"), &GraphEdit::is_using_snap);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_connection_lines_curvature", "curvature"), &GraphEdit::set_connection_lines_curvature);
|
||||
ClassDB::bind_method(D_METHOD("get_connection_lines_curvature"), &GraphEdit::get_connection_lines_curvature);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_connection_lines_thickness", "pixels"), &GraphEdit::set_connection_lines_thickness);
|
||||
ClassDB::bind_method(D_METHOD("get_connection_lines_thickness"), &GraphEdit::get_connection_lines_thickness);
|
||||
|
||||
@ -2298,6 +2320,7 @@ void GraphEdit::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "panning_scheme", PROPERTY_HINT_ENUM, "Scroll Zooms,Scroll Pans"), "set_panning_scheme", "get_panning_scheme");
|
||||
|
||||
ADD_GROUP("Connection Lines", "connection_lines");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "connection_lines_curvature"), "set_connection_lines_curvature", "get_connection_lines_curvature");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "connection_lines_thickness"), "set_connection_lines_thickness", "get_connection_lines_thickness");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "connection_lines_antialiased"), "set_connection_lines_antialiased", "is_connection_lines_antialiased");
|
||||
|
||||
|
@ -178,6 +178,7 @@ private:
|
||||
List<Connection> connections;
|
||||
|
||||
float lines_thickness = 2.0f;
|
||||
float lines_curvature = 0.5f;
|
||||
bool lines_antialiased = true;
|
||||
|
||||
PackedVector2Array get_connection_line(const Vector2 &p_from, const Vector2 &p_to);
|
||||
@ -344,6 +345,9 @@ public:
|
||||
int get_snap() const;
|
||||
void set_snap(int p_snap);
|
||||
|
||||
void set_connection_lines_curvature(float p_curvature);
|
||||
float get_connection_lines_curvature() const;
|
||||
|
||||
void set_connection_lines_thickness(float p_thickness);
|
||||
float get_connection_lines_thickness() const;
|
||||
|
||||
|
@ -1004,8 +1004,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
|
||||
theme->set_color("selection_fill", "GraphEdit", Color(1, 1, 1, 0.3));
|
||||
theme->set_color("selection_stroke", "GraphEdit", Color(1, 1, 1, 0.8));
|
||||
theme->set_color("activity", "GraphEdit", Color(1, 1, 1));
|
||||
theme->set_constant("bezier_len_pos", "GraphEdit", 80 * scale);
|
||||
theme->set_constant("bezier_len_neg", "GraphEdit", 160 * scale);
|
||||
|
||||
// Visual Node Ports
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user