| 
									
										
										
										
											2023-01-05 13:25:55 +01:00
										 |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*  graph_edit.h                                                          */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*                         This file is part of:                          */ | 
					
						
							|  |  |  | /*                             GODOT ENGINE                               */ | 
					
						
							|  |  |  | /*                        https://godotengine.org                         */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | 
					
						
							|  |  |  | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining  */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the        */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including    */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,    */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to     */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to  */ | 
					
						
							|  |  |  | /* the following conditions:                                              */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be         */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.        */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							| 
									
										
										
										
											2018-01-05 00:50:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | #ifndef GRAPH_EDIT_H
 | 
					
						
							|  |  |  | #define GRAPH_EDIT_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-18 22:10:48 -03:00
										 |  |  | #include "scene/gui/box_container.h"
 | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | #include "scene/gui/button.h"
 | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | #include "scene/gui/graph_node.h"
 | 
					
						
							| 
									
										
										
										
											2021-06-16 16:14:25 +03:00
										 |  |  | #include "scene/gui/label.h"
 | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | #include "scene/gui/scroll_bar.h"
 | 
					
						
							| 
									
										
										
										
											2016-08-04 00:05:35 -03:00
										 |  |  | #include "scene/gui/spin_box.h"
 | 
					
						
							| 
									
										
										
										
											2016-02-08 16:28:12 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | class GraphEdit; | 
					
						
							| 
									
										
										
										
											2021-09-28 18:00:16 +02:00
										 |  |  | class ViewPanner; | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | class GraphEditFilter : public Control { | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	GDCLASS(GraphEditFilter, Control); | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	friend class GraphEdit; | 
					
						
							| 
									
										
										
										
											2020-11-06 22:16:45 +03:00
										 |  |  | 	friend class GraphEditMinimap; | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	GraphEdit *ge = nullptr; | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual bool has_point(const Point2 &p_point) const override; | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	GraphEditFilter(GraphEdit *p_edit); | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-06 22:16:45 +03:00
										 |  |  | class GraphEditMinimap : public Control { | 
					
						
							|  |  |  | 	GDCLASS(GraphEditMinimap, Control); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	friend class GraphEdit; | 
					
						
							|  |  |  | 	friend class GraphEditFilter; | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	GraphEdit *ge = nullptr; | 
					
						
							| 
									
										
										
										
											2020-11-06 22:16:45 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	GraphEditMinimap(GraphEdit *p_edit); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-07 11:14:57 -03:00
										 |  |  | 	virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-06 22:16:45 +03:00
										 |  |  | 	void update_minimap(); | 
					
						
							|  |  |  | 	Rect2 get_camera_rect(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	Vector2 minimap_padding; | 
					
						
							|  |  |  | 	Vector2 minimap_offset; | 
					
						
							|  |  |  | 	Vector2 graph_proportions; | 
					
						
							|  |  |  | 	Vector2 graph_padding; | 
					
						
							|  |  |  | 	Vector2 camera_position; | 
					
						
							|  |  |  | 	Vector2 camera_size; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool is_pressing; | 
					
						
							|  |  |  | 	bool is_resizing; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Vector2 _get_render_size(); | 
					
						
							|  |  |  | 	Vector2 _get_graph_offset(); | 
					
						
							|  |  |  | 	Vector2 _get_graph_size(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Vector2 _convert_from_graph_position(const Vector2 &p_position); | 
					
						
							|  |  |  | 	Vector2 _convert_to_graph_position(const Vector2 &p_position); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-22 12:37:22 -03:00
										 |  |  | 	virtual void gui_input(const Ref<InputEvent> &p_ev) override; | 
					
						
							| 
									
										
										
										
											2020-11-06 22:16:45 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _adjust_graph_scroll(const Vector2 &p_offset); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | class GraphEdit : public Control { | 
					
						
							| 
									
										
										
										
											2017-01-02 23:03:46 -03:00
										 |  |  | 	GDCLASS(GraphEdit, Control); | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	struct Connection { | 
					
						
							|  |  |  | 		StringName from; | 
					
						
							|  |  |  | 		StringName to; | 
					
						
							| 
									
										
										
										
											2021-02-09 18:24:36 +01:00
										 |  |  | 		int from_port = 0; | 
					
						
							|  |  |  | 		int to_port = 0; | 
					
						
							|  |  |  | 		float activity = 0.0; | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2016-02-08 16:28:12 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-28 18:00:16 +02:00
										 |  |  | 	// Should be in sync with ControlScheme in ViewPanner.
 | 
					
						
							|  |  |  | 	enum PanningScheme { | 
					
						
							|  |  |  | 		SCROLL_ZOOMS, | 
					
						
							|  |  |  | 		SCROLL_PANS, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	Label *zoom_label = nullptr; | 
					
						
							|  |  |  | 	Button *zoom_minus = nullptr; | 
					
						
							|  |  |  | 	Button *zoom_reset = nullptr; | 
					
						
							|  |  |  | 	Button *zoom_plus = nullptr; | 
					
						
							| 
									
										
										
										
											2016-02-08 16:28:12 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	Button *snap_button = nullptr; | 
					
						
							|  |  |  | 	SpinBox *snap_amount = nullptr; | 
					
						
							| 
									
										
										
										
											2016-08-04 00:05:35 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	Button *minimap_button = nullptr; | 
					
						
							| 
									
										
										
										
											2020-11-06 22:16:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	Button *layout_button = nullptr; | 
					
						
							| 
									
										
										
										
											2021-08-11 00:44:19 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	HScrollBar *h_scroll = nullptr; | 
					
						
							|  |  |  | 	VScrollBar *v_scroll = nullptr; | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 15:48:58 +02:00
										 |  |  | 	float port_hotzone_inner_extent = 0.0; | 
					
						
							|  |  |  | 	float port_hotzone_outer_extent = 0.0; | 
					
						
							| 
									
										
										
										
											2018-05-12 20:34:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-28 18:00:16 +02:00
										 |  |  | 	Ref<ViewPanner> panner; | 
					
						
							| 
									
										
										
										
											2022-01-19 19:59:12 +01:00
										 |  |  | 	bool warped_panning = true; | 
					
						
							| 
									
										
										
										
											2023-01-19 17:50:51 +01:00
										 |  |  | 	void _pan_callback(Vector2 p_scroll_vec, Ref<InputEvent> p_event); | 
					
						
							|  |  |  | 	void _zoom_callback(float p_zoom_factor, Vector2 p_origin, Ref<InputEvent> p_event); | 
					
						
							| 
									
										
										
										
											2021-09-28 18:00:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-04 06:31:53 +01:00
										 |  |  | 	bool arrange_nodes_button_hidden = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-09 18:24:36 +01:00
										 |  |  | 	bool connecting = false; | 
					
						
							| 
									
										
										
										
											2022-08-12 13:06:08 +02:00
										 |  |  | 	StringName connecting_from; | 
					
						
							| 
									
										
										
										
											2021-02-09 18:24:36 +01:00
										 |  |  | 	bool connecting_out = false; | 
					
						
							|  |  |  | 	int connecting_index = 0; | 
					
						
							|  |  |  | 	int connecting_type = 0; | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	Color connecting_color; | 
					
						
							| 
									
										
										
										
											2021-02-09 18:24:36 +01:00
										 |  |  | 	bool connecting_target = false; | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	Vector2 connecting_to; | 
					
						
							| 
									
										
										
										
											2022-08-12 13:06:08 +02:00
										 |  |  | 	StringName connecting_target_to; | 
					
						
							| 
									
										
										
										
											2022-05-02 16:28:25 +02:00
										 |  |  | 	int connecting_target_index = 0; | 
					
						
							| 
									
										
										
										
											2021-02-09 18:24:36 +01:00
										 |  |  | 	bool just_disconnected = false; | 
					
						
							|  |  |  | 	bool connecting_valid = false; | 
					
						
							| 
									
										
										
										
											2020-07-04 08:00:17 +03:00
										 |  |  | 	Vector2 click_pos; | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-28 18:00:16 +02:00
										 |  |  | 	PanningScheme panning_scheme = SCROLL_ZOOMS; | 
					
						
							| 
									
										
										
										
											2021-02-09 18:24:36 +01:00
										 |  |  | 	bool dragging = false; | 
					
						
							|  |  |  | 	bool just_selected = false; | 
					
						
							|  |  |  | 	bool moving_selection = false; | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	Vector2 drag_accum; | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-09 18:24:36 +01:00
										 |  |  | 	float zoom = 1.0; | 
					
						
							| 
									
										
										
										
											2021-06-16 16:14:25 +03:00
										 |  |  | 	float zoom_step = 1.2; | 
					
						
							| 
									
										
										
										
											2022-05-02 16:28:25 +02:00
										 |  |  | 	// Proper values set in constructor.
 | 
					
						
							|  |  |  | 	float zoom_min = 0.0; | 
					
						
							|  |  |  | 	float zoom_max = 0.0; | 
					
						
							| 
									
										
										
										
											2021-06-16 16:14:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void _zoom_minus(); | 
					
						
							|  |  |  | 	void _zoom_reset(); | 
					
						
							|  |  |  | 	void _zoom_plus(); | 
					
						
							|  |  |  | 	void _update_zoom_label(); | 
					
						
							| 
									
										
										
										
											2016-01-18 20:32:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-09 18:24:36 +01:00
										 |  |  | 	bool box_selecting = false; | 
					
						
							|  |  |  | 	bool box_selection_mode_additive = false; | 
					
						
							| 
									
										
										
										
											2015-07-24 21:59:48 -03:00
										 |  |  | 	Point2 box_selecting_from; | 
					
						
							|  |  |  | 	Point2 box_selecting_to; | 
					
						
							|  |  |  | 	Rect2 box_selecting_rect; | 
					
						
							| 
									
										
										
										
											2021-03-25 20:08:38 +09:00
										 |  |  | 	List<GraphNode *> previous_selected; | 
					
						
							| 
									
										
										
										
											2015-07-24 21:59:48 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-09 18:24:36 +01:00
										 |  |  | 	bool setting_scroll_ofs = false; | 
					
						
							|  |  |  | 	bool right_disconnects = false; | 
					
						
							|  |  |  | 	bool updating = false; | 
					
						
							|  |  |  | 	bool awaiting_scroll_offset_update = false; | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	List<Connection> connections; | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-18 16:13:28 +03:00
										 |  |  | 	float lines_thickness = 2.0f; | 
					
						
							| 
									
										
										
										
											2022-05-30 15:38:13 +02:00
										 |  |  | 	float lines_curvature = 0.5f; | 
					
						
							| 
									
										
										
										
											2020-12-18 16:13:28 +03:00
										 |  |  | 	bool lines_antialiased = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-19 19:11:02 +02:00
										 |  |  | 	PackedVector2Array get_connection_line(const Vector2 &p_from, const Vector2 &p_to); | 
					
						
							| 
									
										
										
										
											2021-08-22 11:08:37 +02:00
										 |  |  | 	void _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); | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-24 10:57:17 -04:00
										 |  |  | 	void _graph_node_selected(Node *p_gn); | 
					
						
							|  |  |  | 	void _graph_node_deselected(Node *p_gn); | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	void _graph_node_raised(Node *p_gn); | 
					
						
							|  |  |  | 	void _graph_node_moved(Node *p_gn); | 
					
						
							| 
									
										
										
										
											2021-02-10 21:18:34 +07:00
										 |  |  | 	void _graph_node_slot_updated(int p_index, Node *p_gn); | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	void _update_scroll(); | 
					
						
							|  |  |  | 	void _scroll_moved(double); | 
					
						
							| 
									
										
										
										
											2021-08-22 12:37:22 -03:00
										 |  |  | 	virtual void gui_input(const Ref<InputEvent> &p_ev) override; | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	Control *connections_layer = nullptr; | 
					
						
							|  |  |  | 	GraphEditFilter *top_layer = nullptr; | 
					
						
							|  |  |  | 	GraphEditMinimap *minimap = nullptr; | 
					
						
							| 
									
										
										
										
											2017-05-20 12:38:03 -03:00
										 |  |  | 	void _top_layer_input(const Ref<InputEvent> &p_ev); | 
					
						
							| 
									
										
										
										
											2018-05-12 20:34:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-09 16:29:51 +03:00
										 |  |  | 	bool is_in_input_hotzone(GraphNode *p_node, int p_port, const Vector2 &p_mouse_pos, const Vector2i &p_port_size); | 
					
						
							|  |  |  | 	bool is_in_output_hotzone(GraphNode *p_node, int p_port, const Vector2 &p_mouse_pos, const Vector2i &p_port_size); | 
					
						
							| 
									
										
										
										
											2021-08-23 20:04:18 +08:00
										 |  |  | 	bool is_in_port_hotzone(const Vector2 &pos, const Vector2 &p_mouse_pos, const Vector2i &p_port_size, bool p_left); | 
					
						
							| 
									
										
										
										
											2018-05-12 20:34:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	void _top_layer_draw(); | 
					
						
							| 
									
										
										
										
											2016-08-30 23:44:14 -03:00
										 |  |  | 	void _connections_layer_draw(); | 
					
						
							| 
									
										
										
										
											2020-11-06 22:16:45 +03:00
										 |  |  | 	void _minimap_draw(); | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	void _update_scroll_offset(); | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-05 20:35:08 +02:00
										 |  |  | 	TypedArray<Dictionary> _get_connection_list() const; | 
					
						
							| 
									
										
										
										
											2015-01-08 00:41:34 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-02 16:28:25 +02:00
										 |  |  | 	bool lines_on_bg = false; | 
					
						
							| 
									
										
										
										
											2016-08-23 10:15:47 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-02 19:11:05 -03:00
										 |  |  | 	struct ConnType { | 
					
						
							|  |  |  | 		union { | 
					
						
							|  |  |  | 			struct { | 
					
						
							|  |  |  | 				uint32_t type_a; | 
					
						
							|  |  |  | 				uint32_t type_b; | 
					
						
							|  |  |  | 			}; | 
					
						
							| 
									
										
										
										
											2021-02-09 18:24:36 +01:00
										 |  |  | 			uint64_t key = 0; | 
					
						
							| 
									
										
										
										
											2016-08-02 19:11:05 -03:00
										 |  |  | 		}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-19 17:00:06 +02:00
										 |  |  | 		static uint32_t hash(const ConnType &p_conn) { | 
					
						
							|  |  |  | 			return hash_one_uint64(p_conn.key); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		bool operator==(const ConnType &p_type) const { | 
					
						
							|  |  |  | 			return key == p_type.key; | 
					
						
							| 
									
										
										
										
											2016-08-02 19:11:05 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ConnType(uint32_t a = 0, uint32_t b = 0) { | 
					
						
							|  |  |  | 			type_a = a; | 
					
						
							|  |  |  | 			type_b = b; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-19 17:00:06 +02:00
										 |  |  | 	HashSet<ConnType, ConnType> valid_connection_types; | 
					
						
							|  |  |  | 	HashSet<int> valid_left_disconnect_types; | 
					
						
							|  |  |  | 	HashSet<int> valid_right_disconnect_types; | 
					
						
							| 
									
										
										
										
											2016-08-02 19:11:05 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 15:06:57 +02:00
										 |  |  | 	HBoxContainer *zoom_hb = nullptr; | 
					
						
							| 
									
										
										
										
											2018-06-18 22:10:48 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	friend class GraphEditFilter; | 
					
						
							|  |  |  | 	bool _filter_input(const Point2 &p_point); | 
					
						
							| 
									
										
										
										
											2016-08-04 00:05:35 -03:00
										 |  |  | 	void _snap_toggled(); | 
					
						
							|  |  |  | 	void _snap_value_changed(double); | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-06 22:16:45 +03:00
										 |  |  | 	friend class GraphEditMinimap; | 
					
						
							|  |  |  | 	void _minimap_toggled(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 15:48:58 +02:00
										 |  |  | 	bool _check_clickable_control(Control *p_control, const Vector2 &r_mouse_pos, const Vector2 &p_offset); | 
					
						
							| 
									
										
										
										
											2018-08-20 13:38:18 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-11 00:44:19 +05:30
										 |  |  | 	bool arranging_graph = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum SET_OPERATIONS { | 
					
						
							|  |  |  | 		IS_EQUAL, | 
					
						
							|  |  |  | 		IS_SUBSET, | 
					
						
							|  |  |  | 		DIFFERENCE, | 
					
						
							|  |  |  | 		UNION, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-19 17:00:06 +02:00
										 |  |  | 	int _set_operations(SET_OPERATIONS p_operation, HashSet<StringName> &r_u, const HashSet<StringName> &r_v); | 
					
						
							|  |  |  | 	HashMap<int, Vector<StringName>> _layering(const HashSet<StringName> &r_selected_nodes, const HashMap<StringName, HashSet<StringName>> &r_upper_neighbours); | 
					
						
							| 
									
										
										
										
											2021-08-11 00:44:19 +05:30
										 |  |  | 	Vector<StringName> _split(const Vector<StringName> &r_layer, const HashMap<StringName, Dictionary> &r_crossings); | 
					
						
							| 
									
										
										
										
											2022-05-19 17:00:06 +02:00
										 |  |  | 	void _horizontal_alignment(Dictionary &r_root, Dictionary &r_align, const HashMap<int, Vector<StringName>> &r_layers, const HashMap<StringName, HashSet<StringName>> &r_upper_neighbours, const HashSet<StringName> &r_selected_nodes); | 
					
						
							|  |  |  | 	void _crossing_minimisation(HashMap<int, Vector<StringName>> &r_layers, const HashMap<StringName, HashSet<StringName>> &r_upper_neighbours); | 
					
						
							|  |  |  | 	void _calculate_inner_shifts(Dictionary &r_inner_shifts, const Dictionary &r_root, const Dictionary &r_node_names, const Dictionary &r_align, const HashSet<StringName> &r_block_heads, const HashMap<StringName, Pair<int, int>> &r_port_info); | 
					
						
							| 
									
										
										
										
											2021-08-11 00:44:19 +05:30
										 |  |  | 	float _calculate_threshold(StringName p_v, StringName p_w, const Dictionary &r_node_names, const HashMap<int, Vector<StringName>> &r_layers, const Dictionary &r_root, const Dictionary &r_align, const Dictionary &r_inner_shift, real_t p_current_threshold, const HashMap<StringName, Vector2> &r_node_positions); | 
					
						
							|  |  |  | 	void _place_block(StringName p_v, float p_delta, const HashMap<int, Vector<StringName>> &r_layers, const Dictionary &r_root, const Dictionary &r_align, const Dictionary &r_node_name, const Dictionary &r_inner_shift, Dictionary &r_sink, Dictionary &r_shift, HashMap<StringName, Vector2> &r_node_positions); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	static void _bind_methods(); | 
					
						
							| 
									
										
										
										
											2020-07-10 11:34:39 +01:00
										 |  |  | 	virtual void add_child_notify(Node *p_child) override; | 
					
						
							|  |  |  | 	virtual void remove_child_notify(Node *p_child) override; | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	void _notification(int p_what); | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-22 12:37:22 -03:00
										 |  |  | 	GDVIRTUAL2RC(Vector<Vector2>, _get_connection_line, Vector2, Vector2) | 
					
						
							| 
									
										
										
										
											2021-12-29 20:27:44 +03:00
										 |  |  | 	GDVIRTUAL3R(bool, _is_in_input_hotzone, Object *, int, Vector2) | 
					
						
							|  |  |  | 	GDVIRTUAL3R(bool, _is_in_output_hotzone, Object *, int, Vector2) | 
					
						
							| 
									
										
										
										
											2021-08-01 03:19:55 +02:00
										 |  |  | 	GDVIRTUAL4R(bool, _is_node_hover_valid, StringName, int, StringName, int); | 
					
						
							| 
									
										
										
										
											2021-08-22 12:37:22 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2023-05-07 11:14:57 -03:00
										 |  |  | 	virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-19 16:43:15 +01:00
										 |  |  | 	PackedStringArray get_configuration_warnings() const override; | 
					
						
							| 
									
										
										
										
											2022-09-14 18:09:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	Error connect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port); | 
					
						
							|  |  |  | 	bool is_node_connected(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port); | 
					
						
							|  |  |  | 	void disconnect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port); | 
					
						
							|  |  |  | 	void clear_connections(); | 
					
						
							| 
									
										
										
										
											2021-07-26 16:31:31 +02:00
										 |  |  | 	void force_connection_drag_end(); | 
					
						
							| 
									
										
										
										
											2021-08-01 03:19:55 +02:00
										 |  |  | 	virtual bool is_node_hover_valid(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port); | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-18 22:10:48 -03:00
										 |  |  | 	void set_connection_activity(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port, float p_activity); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-02 19:11:05 -03:00
										 |  |  | 	void add_valid_connection_type(int p_type, int p_with_type); | 
					
						
							|  |  |  | 	void remove_valid_connection_type(int p_type, int p_with_type); | 
					
						
							|  |  |  | 	bool is_valid_connection_type(int p_type, int p_with_type) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-28 18:00:16 +02:00
										 |  |  | 	void set_panning_scheme(PanningScheme p_scheme); | 
					
						
							|  |  |  | 	PanningScheme get_panning_scheme() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-18 20:32:37 -03:00
										 |  |  | 	void set_zoom(float p_zoom); | 
					
						
							| 
									
										
										
										
											2017-11-01 21:49:39 +01:00
										 |  |  | 	void set_zoom_custom(float p_zoom, const Vector2 &p_center); | 
					
						
							| 
									
										
										
										
											2016-01-18 20:32:37 -03:00
										 |  |  | 	float get_zoom() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-16 16:14:25 +03:00
										 |  |  | 	void set_zoom_min(float p_zoom_min); | 
					
						
							|  |  |  | 	float get_zoom_min() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void set_zoom_max(float p_zoom_max); | 
					
						
							|  |  |  | 	float get_zoom_max() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void set_zoom_step(float p_zoom_step); | 
					
						
							|  |  |  | 	float get_zoom_step() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void set_show_zoom_label(bool p_enable); | 
					
						
							|  |  |  | 	bool is_showing_zoom_label() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-06 22:16:45 +03:00
										 |  |  | 	void set_minimap_size(Vector2 p_size); | 
					
						
							|  |  |  | 	Vector2 get_minimap_size() const; | 
					
						
							|  |  |  | 	void set_minimap_opacity(float p_opacity); | 
					
						
							|  |  |  | 	float get_minimap_opacity() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void set_minimap_enabled(bool p_enable); | 
					
						
							|  |  |  | 	bool is_minimap_enabled() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-04 06:31:53 +01:00
										 |  |  | 	void set_arrange_nodes_button_hidden(bool p_enable); | 
					
						
							|  |  |  | 	bool is_arrange_nodes_button_hidden() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	GraphEditFilter *get_top_layer() const { return top_layer; } | 
					
						
							| 
									
										
										
										
											2020-11-06 22:16:45 +03:00
										 |  |  | 	GraphEditMinimap *get_minimap() const { return minimap; } | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	void get_connection_list(List<Connection> *r_connections) const; | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	void set_right_disconnects(bool p_enable); | 
					
						
							|  |  |  | 	bool is_right_disconnects_enabled() const; | 
					
						
							| 
									
										
										
										
											2016-03-09 00:00:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-02 19:11:05 -03:00
										 |  |  | 	void add_valid_right_disconnect_type(int p_type); | 
					
						
							|  |  |  | 	void remove_valid_right_disconnect_type(int p_type); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void add_valid_left_disconnect_type(int p_type); | 
					
						
							|  |  |  | 	void remove_valid_left_disconnect_type(int p_type); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-06 19:00:54 -03:00
										 |  |  | 	void set_scroll_ofs(const Vector2 &p_ofs); | 
					
						
							| 
									
										
										
										
											2016-01-17 22:26:32 +01:00
										 |  |  | 	Vector2 get_scroll_ofs() const; | 
					
						
							| 
									
										
										
										
											2015-01-07 01:45:46 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-02 19:11:05 -03:00
										 |  |  | 	void set_selected(Node *p_child); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-04 00:05:35 -03:00
										 |  |  | 	void set_use_snap(bool p_enable); | 
					
						
							|  |  |  | 	bool is_using_snap() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int get_snap() const; | 
					
						
							|  |  |  | 	void set_snap(int p_snap); | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 15:38:13 +02:00
										 |  |  | 	void set_connection_lines_curvature(float p_curvature); | 
					
						
							|  |  |  | 	float get_connection_lines_curvature() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-18 16:13:28 +03:00
										 |  |  | 	void set_connection_lines_thickness(float p_thickness); | 
					
						
							|  |  |  | 	float get_connection_lines_thickness() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void set_connection_lines_antialiased(bool p_antialiased); | 
					
						
							|  |  |  | 	bool is_connection_lines_antialiased() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-18 22:10:48 -03:00
										 |  |  | 	HBoxContainer *get_zoom_hbox(); | 
					
						
							| 
									
										
										
										
											2022-01-19 19:59:12 +01:00
										 |  |  | 	Ref<ViewPanner> get_panner(); | 
					
						
							|  |  |  | 	void set_warped_panning(bool p_warped); | 
					
						
							| 
									
										
										
										
											2018-06-18 22:10:48 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-11 00:44:19 +05:30
										 |  |  | 	void arrange_nodes(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 22:15:06 -03:00
										 |  |  | 	GraphEdit(); | 
					
						
							| 
									
										
										
										
											2015-01-03 16:52:37 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-28 18:00:16 +02:00
										 |  |  | VARIANT_ENUM_CAST(GraphEdit::PanningScheme); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-23 23:41:51 +02:00
										 |  |  | #endif // GRAPH_EDIT_H
 |