graph_node.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. /*************************************************************************/
  2. /* graph_node.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "graph_node.h"
  31. #include "method_bind_ext.gen.inc"
  32. bool GraphNode::_set(const StringName &p_name, const Variant &p_value) {
  33. if (!p_name.operator String().begins_with("slot/"))
  34. return false;
  35. int idx = p_name.operator String().get_slice("/", 1).to_int();
  36. String what = p_name.operator String().get_slice("/", 2);
  37. Slot si;
  38. if (slot_info.has(idx))
  39. si = slot_info[idx];
  40. if (what == "left_enabled")
  41. si.enable_left = p_value;
  42. else if (what == "left_type")
  43. si.type_left = p_value;
  44. else if (what == "left_color")
  45. si.color_left = p_value;
  46. else if (what == "right_enabled")
  47. si.enable_right = p_value;
  48. else if (what == "right_type")
  49. si.type_right = p_value;
  50. else if (what == "right_color")
  51. si.color_right = p_value;
  52. else
  53. return false;
  54. set_slot(idx, si.enable_left, si.type_left, si.color_left, si.enable_right, si.type_right, si.color_right);
  55. update();
  56. return true;
  57. }
  58. bool GraphNode::_get(const StringName &p_name, Variant &r_ret) const {
  59. if (!p_name.operator String().begins_with("slot/")) {
  60. return false;
  61. }
  62. int idx = p_name.operator String().get_slice("/", 1).to_int();
  63. String what = p_name.operator String().get_slice("/", 2);
  64. Slot si;
  65. if (slot_info.has(idx))
  66. si = slot_info[idx];
  67. if (what == "left_enabled")
  68. r_ret = si.enable_left;
  69. else if (what == "left_type")
  70. r_ret = si.type_left;
  71. else if (what == "left_color")
  72. r_ret = si.color_left;
  73. else if (what == "right_enabled")
  74. r_ret = si.enable_right;
  75. else if (what == "right_type")
  76. r_ret = si.type_right;
  77. else if (what == "right_color")
  78. r_ret = si.color_right;
  79. else
  80. return false;
  81. return true;
  82. }
  83. void GraphNode::_get_property_list(List<PropertyInfo> *p_list) const {
  84. int idx = 0;
  85. for (int i = 0; i < get_child_count(); i++) {
  86. Control *c = get_child(i)->cast_to<Control>();
  87. if (!c || c->is_set_as_toplevel())
  88. continue;
  89. String base = "slot/" + itos(idx) + "/";
  90. p_list->push_back(PropertyInfo(Variant::BOOL, base + "left_enabled"));
  91. p_list->push_back(PropertyInfo(Variant::INT, base + "left_type"));
  92. p_list->push_back(PropertyInfo(Variant::COLOR, base + "left_color"));
  93. p_list->push_back(PropertyInfo(Variant::BOOL, base + "right_enabled"));
  94. p_list->push_back(PropertyInfo(Variant::INT, base + "right_type"));
  95. p_list->push_back(PropertyInfo(Variant::COLOR, base + "right_color"));
  96. idx++;
  97. }
  98. }
  99. void GraphNode::_resort() {
  100. int sep = get_constant("separation");
  101. Ref<StyleBox> sb = get_stylebox("frame");
  102. bool first = true;
  103. Size2 minsize;
  104. for (int i = 0; i < get_child_count(); i++) {
  105. Control *c = get_child(i)->cast_to<Control>();
  106. if (!c)
  107. continue;
  108. if (c->is_set_as_toplevel())
  109. continue;
  110. Size2i size = c->get_combined_minimum_size();
  111. minsize.y += size.y;
  112. minsize.x = MAX(minsize.x, size.x);
  113. if (first)
  114. first = false;
  115. else
  116. minsize.y += sep;
  117. }
  118. int vofs = 0;
  119. int w = get_size().x - sb->get_minimum_size().x;
  120. cache_y.clear();
  121. for (int i = 0; i < get_child_count(); i++) {
  122. Control *c = get_child(i)->cast_to<Control>();
  123. if (!c)
  124. continue;
  125. if (c->is_set_as_toplevel())
  126. continue;
  127. Size2i size = c->get_combined_minimum_size();
  128. Rect2 r(sb->get_margin(MARGIN_LEFT), sb->get_margin(MARGIN_TOP) + vofs, w, size.y);
  129. fit_child_in_rect(c, r);
  130. cache_y.push_back(vofs + size.y * 0.5);
  131. if (vofs > 0)
  132. vofs += sep;
  133. vofs += size.y;
  134. }
  135. _change_notify();
  136. update();
  137. connpos_dirty = true;
  138. }
  139. bool GraphNode::has_point(const Point2 &p_point) const {
  140. if (comment) {
  141. Ref<StyleBox> comment = get_stylebox("comment");
  142. Ref<Texture> resizer = get_icon("resizer");
  143. if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) {
  144. return true;
  145. }
  146. if (Rect2(0, 0, get_size().width, comment->get_margin(MARGIN_TOP)).has_point(p_point)) {
  147. return true;
  148. }
  149. return false;
  150. } else {
  151. return Control::has_point(p_point);
  152. }
  153. }
  154. void GraphNode::_notification(int p_what) {
  155. if (p_what == NOTIFICATION_DRAW) {
  156. Ref<StyleBox> sb;
  157. if (comment) {
  158. sb = get_stylebox(selected ? "commentfocus" : "comment");
  159. } else {
  160. sb = get_stylebox(selected ? "selectedframe" : "frame");
  161. }
  162. //sb=sb->duplicate();
  163. //sb->call("set_modulate",modulate);
  164. Ref<Texture> port = get_icon("port");
  165. Ref<Texture> close = get_icon("close");
  166. Ref<Texture> resizer = get_icon("resizer");
  167. int close_offset = get_constant("close_offset");
  168. Ref<Font> title_font = get_font("title_font");
  169. int title_offset = get_constant("title_offset");
  170. Color title_color = get_color("title_color");
  171. Point2i icofs = -port->get_size() * 0.5;
  172. int edgeofs = get_constant("port_offset");
  173. icofs.y += sb->get_margin(MARGIN_TOP);
  174. draw_style_box(sb, Rect2(Point2(), get_size()));
  175. switch (overlay) {
  176. case OVERLAY_DISABLED: {
  177. } break;
  178. case OVERLAY_BREAKPOINT: {
  179. draw_style_box(get_stylebox("breakpoint"), Rect2(Point2(), get_size()));
  180. } break;
  181. case OVERLAY_POSITION: {
  182. draw_style_box(get_stylebox("position"), Rect2(Point2(), get_size()));
  183. } break;
  184. }
  185. int w = get_size().width - sb->get_minimum_size().x;
  186. if (show_close)
  187. w -= close->get_width();
  188. draw_string(title_font, Point2(sb->get_margin(MARGIN_LEFT), -title_font->get_height() + title_font->get_ascent() + title_offset), title, title_color, w);
  189. if (show_close) {
  190. Vector2 cpos = Point2(w + sb->get_margin(MARGIN_LEFT), -close->get_height() + close_offset);
  191. draw_texture(close, cpos);
  192. close_rect.position = cpos;
  193. close_rect.size = close->get_size();
  194. } else {
  195. close_rect = Rect2();
  196. }
  197. for (Map<int, Slot>::Element *E = slot_info.front(); E; E = E->next()) {
  198. if (E->key() < 0 || E->key() >= cache_y.size())
  199. continue;
  200. if (!slot_info.has(E->key()))
  201. continue;
  202. const Slot &s = slot_info[E->key()];
  203. //left
  204. if (s.enable_left) {
  205. Ref<Texture> p = port;
  206. if (s.custom_slot_left.is_valid()) {
  207. p = s.custom_slot_left;
  208. }
  209. p->draw(get_canvas_item(), icofs + Point2(edgeofs, cache_y[E->key()]), s.color_left);
  210. }
  211. if (s.enable_right) {
  212. Ref<Texture> p = port;
  213. if (s.custom_slot_right.is_valid()) {
  214. p = s.custom_slot_right;
  215. }
  216. p->draw(get_canvas_item(), icofs + Point2(get_size().x - edgeofs, cache_y[E->key()]), s.color_right);
  217. }
  218. }
  219. if (resizeable) {
  220. draw_texture(resizer, get_size() - resizer->get_size());
  221. }
  222. }
  223. if (p_what == NOTIFICATION_SORT_CHILDREN) {
  224. _resort();
  225. }
  226. }
  227. void GraphNode::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, const Ref<Texture> &p_custom_left, const Ref<Texture> &p_custom_right) {
  228. ERR_FAIL_COND(p_idx < 0);
  229. if (!p_enable_left && p_type_left == 0 && p_color_left == Color(1, 1, 1, 1) && !p_enable_right && p_type_right == 0 && p_color_right == Color(1, 1, 1, 1)) {
  230. slot_info.erase(p_idx);
  231. return;
  232. }
  233. Slot s;
  234. s.enable_left = p_enable_left;
  235. s.type_left = p_type_left;
  236. s.color_left = p_color_left;
  237. s.enable_right = p_enable_right;
  238. s.type_right = p_type_right;
  239. s.color_right = p_color_right;
  240. s.custom_slot_left = p_custom_left;
  241. s.custom_slot_right = p_custom_right;
  242. slot_info[p_idx] = s;
  243. update();
  244. connpos_dirty = true;
  245. }
  246. void GraphNode::clear_slot(int p_idx) {
  247. slot_info.erase(p_idx);
  248. update();
  249. connpos_dirty = true;
  250. }
  251. void GraphNode::clear_all_slots() {
  252. slot_info.clear();
  253. update();
  254. connpos_dirty = true;
  255. }
  256. bool GraphNode::is_slot_enabled_left(int p_idx) const {
  257. if (!slot_info.has(p_idx))
  258. return false;
  259. return slot_info[p_idx].enable_left;
  260. }
  261. int GraphNode::get_slot_type_left(int p_idx) const {
  262. if (!slot_info.has(p_idx))
  263. return 0;
  264. return slot_info[p_idx].type_left;
  265. }
  266. Color GraphNode::get_slot_color_left(int p_idx) const {
  267. if (!slot_info.has(p_idx))
  268. return Color(1, 1, 1, 1);
  269. return slot_info[p_idx].color_left;
  270. }
  271. bool GraphNode::is_slot_enabled_right(int p_idx) const {
  272. if (!slot_info.has(p_idx))
  273. return false;
  274. return slot_info[p_idx].enable_right;
  275. }
  276. int GraphNode::get_slot_type_right(int p_idx) const {
  277. if (!slot_info.has(p_idx))
  278. return 0;
  279. return slot_info[p_idx].type_right;
  280. }
  281. Color GraphNode::get_slot_color_right(int p_idx) const {
  282. if (!slot_info.has(p_idx))
  283. return Color(1, 1, 1, 1);
  284. return slot_info[p_idx].color_right;
  285. }
  286. Size2 GraphNode::get_minimum_size() const {
  287. Ref<Font> title_font = get_font("title_font");
  288. int sep = get_constant("separation");
  289. Ref<StyleBox> sb = get_stylebox("frame");
  290. bool first = true;
  291. Size2 minsize;
  292. minsize.x = title_font->get_string_size(title).x;
  293. if (show_close) {
  294. Ref<Texture> close = get_icon("close");
  295. minsize.x += sep + close->get_width();
  296. }
  297. for (int i = 0; i < get_child_count(); i++) {
  298. Control *c = get_child(i)->cast_to<Control>();
  299. if (!c)
  300. continue;
  301. if (c->is_set_as_toplevel())
  302. continue;
  303. Size2i size = c->get_combined_minimum_size();
  304. minsize.y += size.y;
  305. minsize.x = MAX(minsize.x, size.x);
  306. if (first)
  307. first = false;
  308. else
  309. minsize.y += sep;
  310. }
  311. return minsize + sb->get_minimum_size();
  312. }
  313. void GraphNode::set_title(const String &p_title) {
  314. title = p_title;
  315. minimum_size_changed();
  316. update();
  317. }
  318. String GraphNode::get_title() const {
  319. return title;
  320. }
  321. void GraphNode::set_offset(const Vector2 &p_offset) {
  322. offset = p_offset;
  323. emit_signal("offset_changed");
  324. update();
  325. }
  326. Vector2 GraphNode::get_offset() const {
  327. return offset;
  328. }
  329. void GraphNode::set_selected(bool p_selected) {
  330. selected = p_selected;
  331. update();
  332. }
  333. bool GraphNode::is_selected() {
  334. return selected;
  335. }
  336. void GraphNode::set_drag(bool p_drag) {
  337. if (p_drag)
  338. drag_from = get_offset();
  339. else
  340. emit_signal("dragged", drag_from, get_offset()); //useful for undo/redo
  341. }
  342. Vector2 GraphNode::get_drag_from() {
  343. return drag_from;
  344. }
  345. void GraphNode::set_show_close_button(bool p_enable) {
  346. show_close = p_enable;
  347. update();
  348. }
  349. bool GraphNode::is_close_button_visible() const {
  350. return show_close;
  351. }
  352. void GraphNode::_connpos_update() {
  353. int edgeofs = get_constant("port_offset");
  354. int sep = get_constant("separation");
  355. Ref<StyleBox> sb = get_stylebox("frame");
  356. conn_input_cache.clear();
  357. conn_output_cache.clear();
  358. int vofs = 0;
  359. int idx = 0;
  360. for (int i = 0; i < get_child_count(); i++) {
  361. Control *c = get_child(i)->cast_to<Control>();
  362. if (!c)
  363. continue;
  364. if (c->is_set_as_toplevel())
  365. continue;
  366. Size2i size = c->get_combined_minimum_size();
  367. int y = sb->get_margin(MARGIN_TOP) + vofs;
  368. int h = size.y;
  369. if (slot_info.has(idx)) {
  370. if (slot_info[idx].enable_left) {
  371. ConnCache cc;
  372. cc.pos = Point2i(edgeofs, y + h / 2);
  373. cc.type = slot_info[idx].type_left;
  374. cc.color = slot_info[idx].color_left;
  375. conn_input_cache.push_back(cc);
  376. }
  377. if (slot_info[idx].enable_right) {
  378. ConnCache cc;
  379. cc.pos = Point2i(get_size().width - edgeofs, y + h / 2);
  380. cc.type = slot_info[idx].type_right;
  381. cc.color = slot_info[idx].color_right;
  382. conn_output_cache.push_back(cc);
  383. }
  384. }
  385. if (vofs > 0)
  386. vofs += sep;
  387. vofs += size.y;
  388. idx++;
  389. }
  390. connpos_dirty = false;
  391. }
  392. int GraphNode::get_connection_input_count() {
  393. if (connpos_dirty)
  394. _connpos_update();
  395. return conn_input_cache.size();
  396. }
  397. int GraphNode::get_connection_output_count() {
  398. if (connpos_dirty)
  399. _connpos_update();
  400. return conn_output_cache.size();
  401. }
  402. Vector2 GraphNode::get_connection_input_pos(int p_idx) {
  403. if (connpos_dirty)
  404. _connpos_update();
  405. ERR_FAIL_INDEX_V(p_idx, conn_input_cache.size(), Vector2());
  406. Vector2 pos = conn_input_cache[p_idx].pos;
  407. pos.x *= get_scale().x;
  408. pos.y *= get_scale().y;
  409. return pos;
  410. }
  411. int GraphNode::get_connection_input_type(int p_idx) {
  412. if (connpos_dirty)
  413. _connpos_update();
  414. ERR_FAIL_INDEX_V(p_idx, conn_input_cache.size(), 0);
  415. return conn_input_cache[p_idx].type;
  416. }
  417. Color GraphNode::get_connection_input_color(int p_idx) {
  418. if (connpos_dirty)
  419. _connpos_update();
  420. ERR_FAIL_INDEX_V(p_idx, conn_input_cache.size(), Color());
  421. return conn_input_cache[p_idx].color;
  422. }
  423. Vector2 GraphNode::get_connection_output_pos(int p_idx) {
  424. if (connpos_dirty)
  425. _connpos_update();
  426. ERR_FAIL_INDEX_V(p_idx, conn_output_cache.size(), Vector2());
  427. Vector2 pos = conn_output_cache[p_idx].pos;
  428. pos.x *= get_scale().x;
  429. pos.y *= get_scale().y;
  430. return pos;
  431. }
  432. int GraphNode::get_connection_output_type(int p_idx) {
  433. if (connpos_dirty)
  434. _connpos_update();
  435. ERR_FAIL_INDEX_V(p_idx, conn_output_cache.size(), 0);
  436. return conn_output_cache[p_idx].type;
  437. }
  438. Color GraphNode::get_connection_output_color(int p_idx) {
  439. if (connpos_dirty)
  440. _connpos_update();
  441. ERR_FAIL_INDEX_V(p_idx, conn_output_cache.size(), Color());
  442. return conn_output_cache[p_idx].color;
  443. }
  444. void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) {
  445. Ref<InputEventMouseButton> mb = p_ev;
  446. if (mb.is_valid()) {
  447. ERR_EXPLAIN("GraphNode must be the child of a GraphEdit node.");
  448. ERR_FAIL_COND(get_parent_control() == NULL);
  449. if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
  450. Vector2 mpos = Vector2(mb->get_position().x, mb->get_position().y);
  451. if (close_rect.size != Size2() && close_rect.has_point(mpos)) {
  452. emit_signal("close_request");
  453. accept_event();
  454. return;
  455. }
  456. Ref<Texture> resizer = get_icon("resizer");
  457. if (resizeable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) {
  458. resizing = true;
  459. resizing_from = mpos;
  460. resizing_from_size = get_size();
  461. accept_event();
  462. return;
  463. }
  464. //send focus to parent
  465. emit_signal("raise_request");
  466. get_parent_control()->grab_focus();
  467. }
  468. if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
  469. resizing = false;
  470. }
  471. }
  472. Ref<InputEventMouseMotion> mm = p_ev;
  473. if (resizing && mm.is_valid()) {
  474. Vector2 mpos = mm->get_position();
  475. Vector2 diff = mpos - resizing_from;
  476. emit_signal("resize_request", resizing_from_size + diff);
  477. }
  478. }
  479. void GraphNode::set_overlay(Overlay p_overlay) {
  480. overlay = p_overlay;
  481. update();
  482. }
  483. GraphNode::Overlay GraphNode::get_overlay() const {
  484. return overlay;
  485. }
  486. void GraphNode::set_comment(bool p_enable) {
  487. comment = p_enable;
  488. update();
  489. }
  490. bool GraphNode::is_comment() const {
  491. return comment;
  492. }
  493. void GraphNode::set_resizeable(bool p_enable) {
  494. resizeable = p_enable;
  495. update();
  496. }
  497. bool GraphNode::is_resizeable() const {
  498. return resizeable;
  499. }
  500. void GraphNode::_bind_methods() {
  501. ClassDB::bind_method(D_METHOD("set_title", "title"), &GraphNode::set_title);
  502. ClassDB::bind_method(D_METHOD("get_title"), &GraphNode::get_title);
  503. ClassDB::bind_method(D_METHOD("_gui_input"), &GraphNode::_gui_input);
  504. ClassDB::bind_method(D_METHOD("set_slot", "idx", "enable_left", "type_left", "color_left", "enable_right", "type_right", "color_right", "custom_left", "custom_right"), &GraphNode::set_slot, DEFVAL(Ref<Texture>()), DEFVAL(Ref<Texture>()));
  505. ClassDB::bind_method(D_METHOD("clear_slot", "idx"), &GraphNode::clear_slot);
  506. ClassDB::bind_method(D_METHOD("clear_all_slots", "idx"), &GraphNode::clear_all_slots);
  507. ClassDB::bind_method(D_METHOD("is_slot_enabled_left", "idx"), &GraphNode::is_slot_enabled_left);
  508. ClassDB::bind_method(D_METHOD("get_slot_type_left", "idx"), &GraphNode::get_slot_type_left);
  509. ClassDB::bind_method(D_METHOD("get_slot_color_left", "idx"), &GraphNode::get_slot_color_left);
  510. ClassDB::bind_method(D_METHOD("is_slot_enabled_right", "idx"), &GraphNode::is_slot_enabled_right);
  511. ClassDB::bind_method(D_METHOD("get_slot_type_right", "idx"), &GraphNode::get_slot_type_right);
  512. ClassDB::bind_method(D_METHOD("get_slot_color_right", "idx"), &GraphNode::get_slot_color_right);
  513. ClassDB::bind_method(D_METHOD("set_offset", "offset"), &GraphNode::set_offset);
  514. ClassDB::bind_method(D_METHOD("get_offset"), &GraphNode::get_offset);
  515. ClassDB::bind_method(D_METHOD("set_comment", "comment"), &GraphNode::set_comment);
  516. ClassDB::bind_method(D_METHOD("is_comment"), &GraphNode::is_comment);
  517. ClassDB::bind_method(D_METHOD("set_resizeable", "resizeable"), &GraphNode::set_resizeable);
  518. ClassDB::bind_method(D_METHOD("is_resizeable"), &GraphNode::is_resizeable);
  519. ClassDB::bind_method(D_METHOD("set_selected", "selected"), &GraphNode::set_selected);
  520. ClassDB::bind_method(D_METHOD("is_selected"), &GraphNode::is_selected);
  521. ClassDB::bind_method(D_METHOD("get_connection_output_count"), &GraphNode::get_connection_output_count);
  522. ClassDB::bind_method(D_METHOD("get_connection_input_count"), &GraphNode::get_connection_input_count);
  523. ClassDB::bind_method(D_METHOD("get_connection_output_pos", "idx"), &GraphNode::get_connection_output_pos);
  524. ClassDB::bind_method(D_METHOD("get_connection_output_type", "idx"), &GraphNode::get_connection_output_type);
  525. ClassDB::bind_method(D_METHOD("get_connection_output_color", "idx"), &GraphNode::get_connection_output_color);
  526. ClassDB::bind_method(D_METHOD("get_connection_input_pos", "idx"), &GraphNode::get_connection_input_pos);
  527. ClassDB::bind_method(D_METHOD("get_connection_input_type", "idx"), &GraphNode::get_connection_input_type);
  528. ClassDB::bind_method(D_METHOD("get_connection_input_color", "idx"), &GraphNode::get_connection_input_color);
  529. ClassDB::bind_method(D_METHOD("set_show_close_button", "show"), &GraphNode::set_show_close_button);
  530. ClassDB::bind_method(D_METHOD("is_close_button_visible"), &GraphNode::is_close_button_visible);
  531. ClassDB::bind_method(D_METHOD("set_overlay", "overlay"), &GraphNode::set_overlay);
  532. ClassDB::bind_method(D_METHOD("get_overlay"), &GraphNode::get_overlay);
  533. ADD_PROPERTY(PropertyInfo(Variant::STRING, "title"), "set_title", "get_title");
  534. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_close"), "set_show_close_button", "is_close_button_visible");
  535. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizeable"), "set_resizeable", "is_resizeable");
  536. ADD_SIGNAL(MethodInfo("offset_changed"));
  537. ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::VECTOR2, "from"), PropertyInfo(Variant::VECTOR2, "to")));
  538. ADD_SIGNAL(MethodInfo("raise_request"));
  539. ADD_SIGNAL(MethodInfo("close_request"));
  540. ADD_SIGNAL(MethodInfo("resize_request", PropertyInfo(Variant::VECTOR2, "new_minsize")));
  541. BIND_CONSTANT(OVERLAY_DISABLED);
  542. BIND_CONSTANT(OVERLAY_BREAKPOINT);
  543. BIND_CONSTANT(OVERLAY_POSITION);
  544. }
  545. GraphNode::GraphNode() {
  546. overlay = OVERLAY_DISABLED;
  547. show_close = false;
  548. connpos_dirty = true;
  549. set_mouse_filter(MOUSE_FILTER_PASS);
  550. comment = false;
  551. resizeable = false;
  552. resizing = false;
  553. selected = false;
  554. }