graph_node.cpp 19 KB

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