graph_node.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  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-2016 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. void GraphNode::_notification(int p_what) {
  139. if (p_what==NOTIFICATION_DRAW) {
  140. Ref<StyleBox> sb=get_stylebox(comment? "comment": (selected ? "selectedframe" : "frame"));
  141. sb=sb->duplicate();
  142. sb->call("set_modulate",modulate);
  143. Ref<Texture> port =get_icon("port");
  144. Ref<Texture> close =get_icon("close");
  145. Ref<Texture> resizer =get_icon("resizer");
  146. int close_offset = get_constant("close_offset");
  147. Ref<Font> title_font = get_font("title_font");
  148. int title_offset = get_constant("title_offset");
  149. Color title_color = get_color("title_color");
  150. Point2i icofs = -port->get_size()*0.5;
  151. int edgeofs=get_constant("port_offset");
  152. icofs.y+=sb->get_margin(MARGIN_TOP);
  153. draw_style_box(sb,Rect2(Point2(),get_size()));
  154. switch(overlay) {
  155. case OVERLAY_DISABLED: {
  156. } break;
  157. case OVERLAY_BREAKPOINT: {
  158. draw_style_box(get_stylebox("breakpoint"),Rect2(Point2(),get_size()));
  159. } break;
  160. case OVERLAY_POSITION: {
  161. draw_style_box(get_stylebox("position"),Rect2(Point2(),get_size()));
  162. } break;
  163. }
  164. int w = get_size().width-sb->get_minimum_size().x;
  165. if (show_close)
  166. w-=close->get_width();
  167. draw_string(title_font,Point2(sb->get_margin(MARGIN_LEFT),-title_font->get_height()+title_font->get_ascent()+title_offset),title,title_color,w);
  168. if (show_close) {
  169. Vector2 cpos = Point2(w+sb->get_margin(MARGIN_LEFT),-close->get_height()+close_offset);
  170. draw_texture(close,cpos);
  171. close_rect.pos=cpos;
  172. close_rect.size=close->get_size();
  173. } else {
  174. close_rect=Rect2();
  175. }
  176. for (Map<int,Slot>::Element *E=slot_info.front();E;E=E->next()) {
  177. if (E->key() < 0 || E->key()>=cache_y.size())
  178. continue;
  179. if (!slot_info.has(E->key()))
  180. continue;
  181. const Slot &s=slot_info[E->key()];
  182. //left
  183. if (s.enable_left) {
  184. Ref<Texture> p = port;
  185. if (s.custom_slot_left.is_valid()) {
  186. p=s.custom_slot_left;
  187. }
  188. p->draw(get_canvas_item(),icofs+Point2(edgeofs,cache_y[E->key()]),s.color_left);
  189. }
  190. if (s.enable_right) {
  191. Ref<Texture> p = port;
  192. if (s.custom_slot_right.is_valid()) {
  193. p=s.custom_slot_right;
  194. }
  195. p->draw(get_canvas_item(),icofs+Point2(get_size().x-edgeofs,cache_y[E->key()]),s.color_right);
  196. }
  197. }
  198. if (resizeable) {
  199. draw_texture(resizer,get_size()-resizer->get_size());
  200. }
  201. }
  202. if (p_what==NOTIFICATION_SORT_CHILDREN) {
  203. _resort();
  204. }
  205. }
  206. 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) {
  207. ERR_FAIL_COND(p_idx<0);
  208. 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)) {
  209. slot_info.erase(p_idx);
  210. return;
  211. }
  212. Slot s;
  213. s.enable_left=p_enable_left;
  214. s.type_left=p_type_left;
  215. s.color_left=p_color_left;
  216. s.enable_right=p_enable_right;
  217. s.type_right=p_type_right;
  218. s.color_right=p_color_right;
  219. s.custom_slot_left=p_custom_left;
  220. s.custom_slot_right=p_custom_right;
  221. slot_info[p_idx]=s;
  222. update();
  223. connpos_dirty=true;
  224. }
  225. void GraphNode::clear_slot(int p_idx){
  226. slot_info.erase(p_idx);
  227. update();
  228. connpos_dirty=true;
  229. }
  230. void GraphNode::clear_all_slots(){
  231. slot_info.clear();
  232. update();
  233. connpos_dirty=true;
  234. }
  235. bool GraphNode::is_slot_enabled_left(int p_idx) const{
  236. if (!slot_info.has(p_idx))
  237. return false;
  238. return slot_info[p_idx].enable_left;
  239. }
  240. int GraphNode::get_slot_type_left(int p_idx) const{
  241. if (!slot_info.has(p_idx))
  242. return 0;
  243. return slot_info[p_idx].type_left;
  244. }
  245. Color GraphNode::get_slot_color_left(int p_idx) const{
  246. if (!slot_info.has(p_idx))
  247. return Color(1,1,1,1);
  248. return slot_info[p_idx].color_left;
  249. }
  250. bool GraphNode::is_slot_enabled_right(int p_idx) const{
  251. if (!slot_info.has(p_idx))
  252. return false;
  253. return slot_info[p_idx].enable_right;
  254. }
  255. int GraphNode::get_slot_type_right(int p_idx) const{
  256. if (!slot_info.has(p_idx))
  257. return 0;
  258. return slot_info[p_idx].type_right;
  259. }
  260. Color GraphNode::get_slot_color_right(int p_idx) const{
  261. if (!slot_info.has(p_idx))
  262. return Color(1,1,1,1);
  263. return slot_info[p_idx].color_right;
  264. }
  265. Size2 GraphNode::get_minimum_size() const {
  266. Ref<Font> title_font = get_font("title_font");
  267. int sep=get_constant("separation");
  268. Ref<StyleBox> sb=get_stylebox("frame");
  269. bool first=true;
  270. Size2 minsize;
  271. minsize.x=title_font->get_string_size(title).x;
  272. if (show_close) {
  273. Ref<Texture> close =get_icon("close");
  274. minsize.x+=sep+close->get_width();
  275. }
  276. for(int i=0;i<get_child_count();i++) {
  277. Control *c=get_child(i)->cast_to<Control>();
  278. if (!c)
  279. continue;
  280. if (c->is_set_as_toplevel())
  281. continue;
  282. Size2i size=c->get_combined_minimum_size();
  283. minsize.y+=size.y;
  284. minsize.x=MAX(minsize.x,size.x);
  285. if (first)
  286. first=false;
  287. else
  288. minsize.y+=sep;
  289. }
  290. return minsize+sb->get_minimum_size();
  291. }
  292. void GraphNode::set_title(const String& p_title) {
  293. title=p_title;
  294. minimum_size_changed();
  295. update();
  296. }
  297. String GraphNode::get_title() const{
  298. return title;
  299. }
  300. void GraphNode::set_offset(const Vector2& p_offset) {
  301. offset=p_offset;
  302. emit_signal("offset_changed");
  303. update();
  304. }
  305. Vector2 GraphNode::get_offset() const {
  306. return offset;
  307. }
  308. void GraphNode::set_selected(bool p_selected)
  309. {
  310. selected = p_selected;
  311. update();
  312. }
  313. bool GraphNode::is_selected()
  314. {
  315. return selected;
  316. }
  317. void GraphNode::set_drag(bool p_drag)
  318. {
  319. if (p_drag)
  320. drag_from=get_offset();
  321. else
  322. emit_signal("dragged",drag_from,get_offset()); //useful for undo/redo
  323. }
  324. Vector2 GraphNode::get_drag_from()
  325. {
  326. return drag_from;
  327. }
  328. void GraphNode::set_show_close_button(bool p_enable){
  329. show_close=p_enable;
  330. update();
  331. }
  332. bool GraphNode::is_close_button_visible() const{
  333. return show_close;
  334. }
  335. void GraphNode::_connpos_update() {
  336. int edgeofs=get_constant("port_offset");
  337. int sep=get_constant("separation");
  338. Ref<StyleBox> sb=get_stylebox("frame");
  339. conn_input_cache.clear();
  340. conn_output_cache.clear();
  341. int vofs=0;
  342. int idx=0;
  343. for(int i=0;i<get_child_count();i++) {
  344. Control *c=get_child(i)->cast_to<Control>();
  345. if (!c)
  346. continue;
  347. if (c->is_set_as_toplevel())
  348. continue;
  349. Size2i size=c->get_combined_minimum_size();
  350. int y = sb->get_margin(MARGIN_TOP)+vofs;
  351. int h = size.y;
  352. if (slot_info.has(idx)) {
  353. if (slot_info[idx].enable_left) {
  354. ConnCache cc;
  355. cc.pos=Point2i(edgeofs,y+h/2);
  356. cc.type=slot_info[idx].type_left;
  357. cc.color=slot_info[idx].color_left;
  358. conn_input_cache.push_back(cc);
  359. }
  360. if (slot_info[idx].enable_right) {
  361. ConnCache cc;
  362. cc.pos=Point2i(get_size().width-edgeofs,y+h/2);
  363. cc.type=slot_info[idx].type_right;
  364. cc.color=slot_info[idx].color_right;
  365. conn_output_cache.push_back(cc);
  366. }
  367. }
  368. if (vofs>0)
  369. vofs+=sep;
  370. vofs+=size.y;
  371. idx++;
  372. }
  373. connpos_dirty=false;
  374. }
  375. int GraphNode::get_connection_input_count() {
  376. if (connpos_dirty)
  377. _connpos_update();
  378. return conn_input_cache.size();
  379. }
  380. int GraphNode::get_connection_output_count() {
  381. if (connpos_dirty)
  382. _connpos_update();
  383. return conn_output_cache.size();
  384. }
  385. Vector2 GraphNode::get_connection_input_pos(int p_idx) {
  386. if (connpos_dirty)
  387. _connpos_update();
  388. ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),Vector2());
  389. Vector2 pos = conn_input_cache[p_idx].pos;
  390. pos.x *= get_scale().x;
  391. pos.y *= get_scale().y;
  392. return pos;
  393. }
  394. int GraphNode::get_connection_input_type(int p_idx) {
  395. if (connpos_dirty)
  396. _connpos_update();
  397. ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),0);
  398. return conn_input_cache[p_idx].type;
  399. }
  400. Color GraphNode::get_connection_input_color(int p_idx) {
  401. if (connpos_dirty)
  402. _connpos_update();
  403. ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),Color());
  404. return conn_input_cache[p_idx].color;
  405. }
  406. Vector2 GraphNode::get_connection_output_pos(int p_idx){
  407. if (connpos_dirty)
  408. _connpos_update();
  409. ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),Vector2());
  410. Vector2 pos = conn_output_cache[p_idx].pos;
  411. pos.x *= get_scale().x;
  412. pos.y *= get_scale().y;
  413. return pos;
  414. }
  415. int GraphNode::get_connection_output_type(int p_idx) {
  416. if (connpos_dirty)
  417. _connpos_update();
  418. ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),0);
  419. return conn_output_cache[p_idx].type;
  420. }
  421. Color GraphNode::get_connection_output_color(int p_idx) {
  422. if (connpos_dirty)
  423. _connpos_update();
  424. ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),Color());
  425. return conn_output_cache[p_idx].color;
  426. }
  427. void GraphNode::_input_event(const InputEvent& p_ev) {
  428. if (p_ev.type==InputEvent::MOUSE_BUTTON) {
  429. ERR_EXPLAIN("GraphNode must be the child of a GraphEdit node.");
  430. ERR_FAIL_COND(get_parent_control() == NULL);
  431. if(p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {
  432. Vector2 mpos = Vector2(p_ev.mouse_button.x,p_ev.mouse_button.y);
  433. if (close_rect.size!=Size2() && close_rect.has_point(mpos)) {
  434. emit_signal("close_request");
  435. accept_event();
  436. return;
  437. }
  438. Ref<Texture> resizer =get_icon("resizer");
  439. if (resizeable && mpos.x > get_size().x-resizer->get_width() && mpos.y > get_size().y-resizer->get_height()) {
  440. resizing=true;
  441. resizing_from=mpos;
  442. resizing_from_size=get_size();
  443. accept_event();
  444. return;
  445. }
  446. //send focus to parent
  447. emit_signal("raise_request");
  448. get_parent_control()->grab_focus();
  449. }
  450. if(!p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {
  451. resizing=false;
  452. }
  453. }
  454. if (resizing && p_ev.type==InputEvent::MOUSE_MOTION) {
  455. Vector2 mpos = Vector2(p_ev.mouse_motion.x,p_ev.mouse_motion.y);
  456. Vector2 diff = mpos - resizing_from;
  457. emit_signal("resize_request",resizing_from_size+diff);
  458. }
  459. }
  460. void GraphNode::set_modulate(const Color &p_color) {
  461. modulate=p_color;
  462. update();
  463. }
  464. Color GraphNode::get_modulate() const{
  465. return modulate;
  466. }
  467. void GraphNode::set_overlay(Overlay p_overlay) {
  468. overlay=p_overlay;
  469. update();
  470. }
  471. GraphNode::Overlay GraphNode::get_overlay() const{
  472. return overlay;
  473. }
  474. void GraphNode::set_comment(bool p_enable) {
  475. comment=p_enable;
  476. update();
  477. }
  478. bool GraphNode::is_comment() const{
  479. return comment;
  480. }
  481. void GraphNode::set_resizeable(bool p_enable) {
  482. resizeable=p_enable;
  483. update();
  484. }
  485. bool GraphNode::is_resizeable() const{
  486. return resizeable;
  487. }
  488. void GraphNode::_bind_methods() {
  489. ObjectTypeDB::bind_method(_MD("set_title","title"),&GraphNode::set_title);
  490. ObjectTypeDB::bind_method(_MD("get_title"),&GraphNode::get_title);
  491. ObjectTypeDB::bind_method(_MD("_input_event"),&GraphNode::_input_event);
  492. ObjectTypeDB::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>()));
  493. ObjectTypeDB::bind_method(_MD("clear_slot","idx"),&GraphNode::clear_slot);
  494. ObjectTypeDB::bind_method(_MD("clear_all_slots","idx"),&GraphNode::clear_all_slots);
  495. ObjectTypeDB::bind_method(_MD("is_slot_enabled_left","idx"),&GraphNode::is_slot_enabled_left);
  496. ObjectTypeDB::bind_method(_MD("get_slot_type_left","idx"),&GraphNode::get_slot_type_left);
  497. ObjectTypeDB::bind_method(_MD("get_slot_color_left","idx"),&GraphNode::get_slot_color_left);
  498. ObjectTypeDB::bind_method(_MD("is_slot_enabled_right","idx"),&GraphNode::is_slot_enabled_right);
  499. ObjectTypeDB::bind_method(_MD("get_slot_type_right","idx"),&GraphNode::get_slot_type_right);
  500. ObjectTypeDB::bind_method(_MD("get_slot_color_right","idx"),&GraphNode::get_slot_color_right);
  501. ObjectTypeDB::bind_method(_MD("set_offset","offset"),&GraphNode::set_offset);
  502. ObjectTypeDB::bind_method(_MD("get_offset"),&GraphNode::get_offset);
  503. ObjectTypeDB::bind_method(_MD("set_comment","comment"),&GraphNode::set_comment);
  504. ObjectTypeDB::bind_method(_MD("is_comment"),&GraphNode::is_comment);
  505. ObjectTypeDB::bind_method(_MD("set_resizeable","resizeable"),&GraphNode::set_resizeable);
  506. ObjectTypeDB::bind_method(_MD("is_resizeable"),&GraphNode::is_resizeable);
  507. ObjectTypeDB::bind_method(_MD("get_connection_output_count"),&GraphNode::get_connection_output_count);
  508. ObjectTypeDB::bind_method(_MD("get_connection_input_count"),&GraphNode::get_connection_input_count);
  509. ObjectTypeDB::bind_method(_MD("get_connection_output_pos","idx"),&GraphNode::get_connection_output_pos);
  510. ObjectTypeDB::bind_method(_MD("get_connection_output_type","idx"),&GraphNode::get_connection_output_type);
  511. ObjectTypeDB::bind_method(_MD("get_connection_output_color","idx"),&GraphNode::get_connection_output_color);
  512. ObjectTypeDB::bind_method(_MD("get_connection_input_pos","idx"),&GraphNode::get_connection_input_pos);
  513. ObjectTypeDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
  514. ObjectTypeDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
  515. ObjectTypeDB::bind_method(_MD("set_modulate","color"),&GraphNode::set_modulate);
  516. ObjectTypeDB::bind_method(_MD("get_modulate"),&GraphNode::get_modulate);
  517. ObjectTypeDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button);
  518. ObjectTypeDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible);
  519. ObjectTypeDB::bind_method(_MD("set_overlay","overlay"),&GraphNode::set_overlay);
  520. ObjectTypeDB::bind_method(_MD("get_overlay"),&GraphNode::get_overlay);
  521. ADD_PROPERTY( PropertyInfo(Variant::STRING,"title"),_SCS("set_title"),_SCS("get_title"));
  522. ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_close"),_SCS("set_show_close_button"),_SCS("is_close_button_visible"));
  523. ADD_SIGNAL(MethodInfo("offset_changed"));
  524. ADD_SIGNAL(MethodInfo("dragged",PropertyInfo(Variant::VECTOR2,"from"),PropertyInfo(Variant::VECTOR2,"to")));
  525. ADD_SIGNAL(MethodInfo("raise_request"));
  526. ADD_SIGNAL(MethodInfo("close_request"));
  527. ADD_SIGNAL(MethodInfo("resize_request",PropertyInfo(Variant::VECTOR2,"new_minsize")));
  528. BIND_CONSTANT( OVERLAY_DISABLED );
  529. BIND_CONSTANT( OVERLAY_BREAKPOINT );
  530. BIND_CONSTANT( OVERLAY_POSITION );
  531. }
  532. GraphNode::GraphNode() {
  533. overlay=OVERLAY_DISABLED;
  534. show_close=false;
  535. connpos_dirty=true;
  536. set_stop_mouse(false);
  537. modulate=Color(1,1,1,1);
  538. comment=false;
  539. resizeable=false;
  540. resizing=false;
  541. }