graph_node.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #ifndef GRAPH_NODE_H
  2. #define GRAPH_NODE_H
  3. #include "scene/gui/container.h"
  4. class GraphNode : public Container {
  5. OBJ_TYPE(GraphNode,Container);
  6. struct Slot {
  7. bool enable_left;
  8. int type_left;
  9. Color color_left;
  10. bool enable_right;
  11. int type_right;
  12. Color color_right;
  13. Slot() { enable_left=false; type_left=0; color_left=Color(1,1,1,1); enable_right=false; type_right=0; color_right=Color(1,1,1,1); }
  14. };
  15. String title;
  16. bool show_close;
  17. Vector2 offset;
  18. Rect2 close_rect;
  19. Vector<int> cache_y;
  20. struct ConnCache {
  21. Vector2 pos;
  22. int type;
  23. Color color;
  24. };
  25. Vector<ConnCache> conn_input_cache;
  26. Vector<ConnCache> conn_output_cache;
  27. Map<int,Slot> slot_info;
  28. bool connpos_dirty;
  29. void _connpos_update();
  30. void _resort();
  31. Vector2 drag_from;
  32. bool selected;
  33. protected:
  34. void _input_event(const InputEvent& p_ev);
  35. void _notification(int p_what);
  36. static void _bind_methods();
  37. bool _set(const StringName& p_name, const Variant& p_value);
  38. bool _get(const StringName& p_name,Variant &r_ret) const;
  39. void _get_property_list( List<PropertyInfo> *p_list) const;
  40. public:
  41. void set_slot(int p_idx,bool p_enable_left,int p_type_left,const Color& p_color_left, bool p_enable_right,int p_type_right,const Color& p_color_right);
  42. void clear_slot(int p_idx);
  43. void clear_all_slots();
  44. bool is_slot_enabled_left(int p_idx) const;
  45. int get_slot_type_left(int p_idx) const;
  46. Color get_slot_color_left(int p_idx) const;
  47. bool is_slot_enabled_right(int p_idx) const;
  48. int get_slot_type_right(int p_idx) const;
  49. Color get_slot_color_right(int p_idx) const;
  50. void set_title(const String& p_title);
  51. String get_title() const;
  52. void set_offset(const Vector2& p_offset);
  53. Vector2 get_offset() const;
  54. void set_selected(bool p_selected);
  55. bool is_selected();
  56. void set_drag(bool p_drag);
  57. Vector2 get_drag_from();
  58. void set_show_close_button(bool p_enable);
  59. bool is_close_button_visible() const;
  60. int get_connection_input_count() ;
  61. int get_connection_output_count() ;
  62. Vector2 get_connection_input_pos(int p_idx);
  63. int get_connection_input_type(int p_idx);
  64. Color get_connection_input_color(int p_idx);
  65. Vector2 get_connection_output_pos(int p_idx);
  66. int get_connection_output_type(int p_idx);
  67. Color get_connection_output_color(int p_idx);
  68. virtual Size2 get_minimum_size() const;
  69. GraphNode();
  70. };
  71. #endif // GRAPH_NODE_H