graph_edit.h
1 #ifndef GRAPH_EDIT_H
2 #define GRAPH_EDIT_H
3 
4 #include "scene/gui/graph_node.h"
5 #include "scene/gui/scroll_bar.h"
6 #include "scene/gui/slider.h"
7 #include "scene/gui/tool_button.h"
8 #include "texture_frame.h"
9 
10 class GraphEdit;
11 
12 class GraphEditFilter : public Control {
13 
14  OBJ_TYPE(GraphEditFilter,Control);
15 
16  friend class GraphEdit;
17  GraphEdit *ge;
18  virtual bool has_point(const Point2& p_point) const;
19 
20 public:
21 
22 
23  GraphEditFilter(GraphEdit *p_edit);
24 };
25 
26 class GraphEdit : public Control {
27 
28  OBJ_TYPE(GraphEdit,Control);
29 public:
30 
31  struct Connection {
32  StringName from;
33  StringName to;
34  int from_port;
35  int to_port;
36 
37  };
38 private:
39 
40 
41  ToolButton *zoom_minus;
42  ToolButton *zoom_reset;
43  ToolButton *zoom_plus;
44 
45  void _zoom_minus();
46  void _zoom_reset();
47  void _zoom_plus();
48 
49  HScrollBar* h_scroll;
50  VScrollBar* v_scroll;
51 
52 
53  bool connecting;
54  String connecting_from;
55  bool connecting_out;
56  int connecting_index;
57  int connecting_type;
58  Color connecting_color;
59  bool connecting_target;
60  Vector2 connecting_to;
61  String connecting_target_to;
62  int connecting_target_index;
63 
64  bool dragging;
65  bool just_selected;
66  Vector2 drag_accum;
67 
68  float zoom;
69 
70  bool box_selecting;
71  bool box_selection_mode_aditive;
72  Point2 box_selecting_from;
73  Point2 box_selecting_to;
74  Rect2 box_selecting_rect;
75  List<GraphNode*> previus_selected;
76 
77  bool right_disconnects;
78  bool updating;
79  List<Connection> connections;
80 
81  void _draw_cos_line(const Vector2& p_from, const Vector2& p_to,const Color& p_color);
82 
83  void _graph_node_raised(Node* p_gn);
84  void _graph_node_moved(Node *p_gn);
85 
86  void _update_scroll();
87  void _scroll_moved(double);
88  void _input_event(const InputEvent& p_ev);
89 
90  GraphEditFilter *top_layer;
91  void _top_layer_input(const InputEvent& p_ev);
92  void _top_layer_draw();
93  void _update_scroll_offset();
94 
95  Array _get_connection_list() const;
96 
97  friend class GraphEditFilter;
98  bool _filter_input(const Point2& p_point);
99 protected:
100 
101  static void _bind_methods();
102  virtual void add_child_notify(Node *p_child);
103  virtual void remove_child_notify(Node *p_child);
104  void _notification(int p_what);
105  virtual bool clips_input() const;
106 public:
107 
108  Error connect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
109  bool is_node_connected(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
110  void disconnect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
111  void clear_connections();
112 
113  void set_zoom(float p_zoom);
114  float get_zoom() const;
115 
116  GraphEditFilter *get_top_layer() const { return top_layer; }
117  void get_connection_list(List<Connection> *r_connections) const;
118 
119  void set_right_disconnects(bool p_enable);
120  bool is_right_disconnects_enabled() const;
121 
122  Vector2 get_scroll_ofs() const;
123 
124 
125  GraphEdit();
126 };
127 
128 #endif // GRAPHEdit_H
Definition: graph_edit.h:31
Definition: scroll_bar.h:110
Definition: array.h:38
Definition: node.h:42
Definition: color.h:37
Definition: math_2d.h:204
Definition: string_db.h:48
Definition: scroll_bar.h:118
Definition: input_event.h:263
Definition: graph_edit.h:26
Definition: math_2d.h:65
Definition: tool_button.h:34
Definition: control.h:47
Definition: ustring.h:64
Definition: graph_edit.h:12