graph_node.cpp 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172
  1. /*************************************************************************/
  2. /* graph_node.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 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 "core/string/translation.h"
  32. #include "graph_edit.h"
  33. struct _MinSizeCache {
  34. int min_size;
  35. bool will_stretch;
  36. int final_size;
  37. };
  38. bool GraphNode::_set(const StringName &p_name, const Variant &p_value) {
  39. String str = p_name;
  40. if (!str.begins_with("slot/")) {
  41. return false;
  42. }
  43. int idx = str.get_slice("/", 1).to_int();
  44. String what = str.get_slice("/", 2);
  45. Slot si;
  46. if (slot_info.has(idx)) {
  47. si = slot_info[idx];
  48. }
  49. if (what == "left_enabled") {
  50. si.enable_left = p_value;
  51. } else if (what == "left_type") {
  52. si.type_left = p_value;
  53. } else if (what == "left_icon") {
  54. si.custom_slot_left = p_value;
  55. } else if (what == "left_color") {
  56. si.color_left = p_value;
  57. } else if (what == "right_enabled") {
  58. si.enable_right = p_value;
  59. } else if (what == "right_type") {
  60. si.type_right = p_value;
  61. } else if (what == "right_color") {
  62. si.color_right = p_value;
  63. } else if (what == "right_icon") {
  64. si.custom_slot_right = p_value;
  65. } else if (what == "draw_stylebox") {
  66. si.draw_stylebox = p_value;
  67. } else {
  68. return false;
  69. }
  70. set_slot(idx, si.enable_left, si.type_left, si.color_left, si.enable_right, si.type_right, si.color_right, si.custom_slot_left, si.custom_slot_right, si.draw_stylebox);
  71. queue_redraw();
  72. return true;
  73. }
  74. bool GraphNode::_get(const StringName &p_name, Variant &r_ret) const {
  75. String str = p_name;
  76. if (!str.begins_with("slot/")) {
  77. return false;
  78. }
  79. int idx = str.get_slice("/", 1).to_int();
  80. String what = str.get_slice("/", 2);
  81. Slot si;
  82. if (slot_info.has(idx)) {
  83. si = slot_info[idx];
  84. }
  85. if (what == "left_enabled") {
  86. r_ret = si.enable_left;
  87. } else if (what == "left_type") {
  88. r_ret = si.type_left;
  89. } else if (what == "left_color") {
  90. r_ret = si.color_left;
  91. } else if (what == "left_icon") {
  92. r_ret = si.custom_slot_left;
  93. } else if (what == "right_enabled") {
  94. r_ret = si.enable_right;
  95. } else if (what == "right_type") {
  96. r_ret = si.type_right;
  97. } else if (what == "right_color") {
  98. r_ret = si.color_right;
  99. } else if (what == "right_icon") {
  100. r_ret = si.custom_slot_right;
  101. } else if (what == "draw_stylebox") {
  102. r_ret = si.draw_stylebox;
  103. } else {
  104. return false;
  105. }
  106. return true;
  107. }
  108. void GraphNode::_get_property_list(List<PropertyInfo> *p_list) const {
  109. int idx = 0;
  110. for (int i = 0; i < get_child_count(); i++) {
  111. Control *c = Object::cast_to<Control>(get_child(i));
  112. if (!c || c->is_set_as_top_level()) {
  113. continue;
  114. }
  115. String base = "slot/" + itos(idx) + "/";
  116. p_list->push_back(PropertyInfo(Variant::BOOL, base + "left_enabled"));
  117. p_list->push_back(PropertyInfo(Variant::INT, base + "left_type"));
  118. p_list->push_back(PropertyInfo(Variant::COLOR, base + "left_color"));
  119. p_list->push_back(PropertyInfo(Variant::OBJECT, base + "left_icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
  120. p_list->push_back(PropertyInfo(Variant::BOOL, base + "right_enabled"));
  121. p_list->push_back(PropertyInfo(Variant::INT, base + "right_type"));
  122. p_list->push_back(PropertyInfo(Variant::COLOR, base + "right_color"));
  123. p_list->push_back(PropertyInfo(Variant::OBJECT, base + "right_icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
  124. p_list->push_back(PropertyInfo(Variant::BOOL, base + "draw_stylebox"));
  125. idx++;
  126. }
  127. }
  128. void GraphNode::_resort() {
  129. /** First pass, determine minimum size AND amount of stretchable elements */
  130. Size2i new_size = get_size();
  131. Ref<StyleBox> sb = get_theme_stylebox(SNAME("frame"));
  132. Ref<StyleBox> sb_slot = get_theme_stylebox(SNAME("slot"));
  133. int sep = get_theme_constant(SNAME("separation"));
  134. bool first = true;
  135. int children_count = 0;
  136. int stretch_min = 0;
  137. int stretch_avail = 0;
  138. float stretch_ratio_total = 0;
  139. HashMap<Control *, _MinSizeCache> min_size_cache;
  140. for (int i = 0; i < get_child_count(); i++) {
  141. Control *c = Object::cast_to<Control>(get_child(i));
  142. if (!c || !c->is_visible_in_tree()) {
  143. continue;
  144. }
  145. if (c->is_set_as_top_level()) {
  146. continue;
  147. }
  148. Size2i size = c->get_combined_minimum_size() + (slot_info[i].draw_stylebox ? sb_slot->get_minimum_size() : Size2());
  149. _MinSizeCache msc;
  150. stretch_min += size.height;
  151. msc.min_size = size.height;
  152. msc.will_stretch = c->get_v_size_flags() & SIZE_EXPAND;
  153. if (msc.will_stretch) {
  154. stretch_avail += msc.min_size;
  155. stretch_ratio_total += c->get_stretch_ratio();
  156. }
  157. msc.final_size = msc.min_size;
  158. min_size_cache[c] = msc;
  159. children_count++;
  160. }
  161. if (children_count == 0) {
  162. return;
  163. }
  164. int stretch_max = new_size.height - (children_count - 1) * sep;
  165. int stretch_diff = stretch_max - stretch_min;
  166. if (stretch_diff < 0) {
  167. //avoid negative stretch space
  168. stretch_diff = 0;
  169. }
  170. stretch_avail += stretch_diff - sb->get_margin(SIDE_BOTTOM) - sb->get_margin(SIDE_TOP); //available stretch space.
  171. /** Second, pass successively to discard elements that can't be stretched, this will run while stretchable
  172. elements exist */
  173. while (stretch_ratio_total > 0) { // first of all, don't even be here if no stretchable objects exist
  174. bool refit_successful = true; //assume refit-test will go well
  175. for (int i = 0; i < get_child_count(); i++) {
  176. Control *c = Object::cast_to<Control>(get_child(i));
  177. if (!c || !c->is_visible_in_tree()) {
  178. continue;
  179. }
  180. if (c->is_set_as_top_level()) {
  181. continue;
  182. }
  183. ERR_FAIL_COND(!min_size_cache.has(c));
  184. _MinSizeCache &msc = min_size_cache[c];
  185. if (msc.will_stretch) { //wants to stretch
  186. //let's see if it can really stretch
  187. int final_pixel_size = stretch_avail * c->get_stretch_ratio() / stretch_ratio_total;
  188. if (final_pixel_size < msc.min_size) {
  189. //if available stretching area is too small for widget,
  190. //then remove it from stretching area
  191. msc.will_stretch = false;
  192. stretch_ratio_total -= c->get_stretch_ratio();
  193. refit_successful = false;
  194. stretch_avail -= msc.min_size;
  195. msc.final_size = msc.min_size;
  196. break;
  197. } else {
  198. msc.final_size = final_pixel_size;
  199. }
  200. }
  201. }
  202. if (refit_successful) { //uf refit went well, break
  203. break;
  204. }
  205. }
  206. /** Final pass, draw and stretch elements **/
  207. int ofs = sb->get_margin(SIDE_TOP);
  208. first = true;
  209. int idx = 0;
  210. cache_y.clear();
  211. int w = new_size.width - sb->get_minimum_size().x;
  212. for (int i = 0; i < get_child_count(); i++) {
  213. Control *c = Object::cast_to<Control>(get_child(i));
  214. if (!c || !c->is_visible_in_tree()) {
  215. continue;
  216. }
  217. if (c->is_set_as_top_level()) {
  218. continue;
  219. }
  220. _MinSizeCache &msc = min_size_cache[c];
  221. if (first) {
  222. first = false;
  223. } else {
  224. ofs += sep;
  225. }
  226. int from = ofs;
  227. int to = ofs + msc.final_size;
  228. if (msc.will_stretch && idx == children_count - 1) {
  229. //adjust so the last one always fits perfect
  230. //compensating for numerical imprecision
  231. to = new_size.height - sb->get_margin(SIDE_BOTTOM);
  232. }
  233. int size = to - from;
  234. float margin = sb->get_margin(SIDE_LEFT) + (slot_info[i].draw_stylebox ? sb_slot->get_margin(SIDE_LEFT) : 0);
  235. float width = w - (slot_info[i].draw_stylebox ? sb_slot->get_minimum_size().x : 0);
  236. Rect2 rect(margin, from, width, size);
  237. fit_child_in_rect(c, rect);
  238. cache_y.push_back(from - sb->get_margin(SIDE_TOP) + size * 0.5);
  239. ofs = to;
  240. idx++;
  241. }
  242. queue_redraw();
  243. connpos_dirty = true;
  244. }
  245. bool GraphNode::has_point(const Point2 &p_point) const {
  246. if (comment) {
  247. Ref<StyleBox> comment = get_theme_stylebox(SNAME("comment"));
  248. Ref<Texture2D> resizer = get_theme_icon(SNAME("resizer"));
  249. if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) {
  250. return true;
  251. }
  252. if (Rect2(0, 0, get_size().width, comment->get_margin(SIDE_TOP)).has_point(p_point)) {
  253. return true;
  254. }
  255. return false;
  256. } else {
  257. return Control::has_point(p_point);
  258. }
  259. }
  260. void GraphNode::_notification(int p_what) {
  261. switch (p_what) {
  262. case NOTIFICATION_DRAW: {
  263. Ref<StyleBox> sb;
  264. if (comment) {
  265. sb = get_theme_stylebox(selected ? SNAME("comment_focus") : SNAME("comment"));
  266. } else {
  267. sb = get_theme_stylebox(selected ? SNAME("selected_frame") : SNAME("frame"));
  268. }
  269. Ref<StyleBox> sb_slot = get_theme_stylebox(SNAME("slot"));
  270. Ref<Texture2D> port = get_theme_icon(SNAME("port"));
  271. Ref<Texture2D> close = get_theme_icon(SNAME("close"));
  272. Ref<Texture2D> resizer = get_theme_icon(SNAME("resizer"));
  273. int close_offset = get_theme_constant(SNAME("close_offset"));
  274. int close_h_offset = get_theme_constant(SNAME("close_h_offset"));
  275. Color close_color = get_theme_color(SNAME("close_color"));
  276. Color resizer_color = get_theme_color(SNAME("resizer_color"));
  277. int title_offset = get_theme_constant(SNAME("title_offset"));
  278. int title_h_offset = get_theme_constant(SNAME("title_h_offset"));
  279. Color title_color = get_theme_color(SNAME("title_color"));
  280. Point2i icofs = -port->get_size() * 0.5;
  281. int edgeofs = get_theme_constant(SNAME("port_offset"));
  282. icofs.y += sb->get_margin(SIDE_TOP);
  283. draw_style_box(sb, Rect2(Point2(), get_size()));
  284. switch (overlay) {
  285. case OVERLAY_DISABLED: {
  286. } break;
  287. case OVERLAY_BREAKPOINT: {
  288. draw_style_box(get_theme_stylebox(SNAME("breakpoint")), Rect2(Point2(), get_size()));
  289. } break;
  290. case OVERLAY_POSITION: {
  291. draw_style_box(get_theme_stylebox(SNAME("position")), Rect2(Point2(), get_size()));
  292. } break;
  293. }
  294. int w = get_size().width - sb->get_minimum_size().x;
  295. title_buf->draw(get_canvas_item(), Point2(sb->get_margin(SIDE_LEFT) + title_h_offset, -title_buf->get_size().y + title_offset), title_color);
  296. if (show_close) {
  297. Vector2 cpos = Point2(w + sb->get_margin(SIDE_LEFT) + close_h_offset - close->get_width(), -close->get_height() + close_offset);
  298. draw_texture(close, cpos, close_color);
  299. close_rect.position = cpos;
  300. close_rect.size = close->get_size();
  301. } else {
  302. close_rect = Rect2();
  303. }
  304. for (const KeyValue<int, Slot> &E : slot_info) {
  305. if (E.key < 0 || E.key >= cache_y.size()) {
  306. continue;
  307. }
  308. if (!slot_info.has(E.key)) {
  309. continue;
  310. }
  311. const Slot &s = slot_info[E.key];
  312. // Left port.
  313. if (s.enable_left) {
  314. Ref<Texture2D> p = port;
  315. if (s.custom_slot_left.is_valid()) {
  316. p = s.custom_slot_left;
  317. }
  318. p->draw(get_canvas_item(), icofs + Point2(edgeofs, cache_y[E.key]), s.color_left);
  319. }
  320. // Right port.
  321. if (s.enable_right) {
  322. Ref<Texture2D> p = port;
  323. if (s.custom_slot_right.is_valid()) {
  324. p = s.custom_slot_right;
  325. }
  326. p->draw(get_canvas_item(), icofs + Point2(get_size().x - edgeofs, cache_y[E.key]), s.color_right);
  327. }
  328. // Draw slot stylebox.
  329. if (s.draw_stylebox) {
  330. Control *c = Object::cast_to<Control>(get_child(E.key));
  331. Rect2 c_rect = c->get_rect();
  332. c_rect.position.x = sb->get_margin(SIDE_LEFT);
  333. c_rect.size.width = w;
  334. draw_style_box(sb_slot, c_rect);
  335. }
  336. }
  337. if (resizable) {
  338. draw_texture(resizer, get_size() - resizer->get_size(), resizer_color);
  339. }
  340. } break;
  341. case NOTIFICATION_SORT_CHILDREN: {
  342. _resort();
  343. } break;
  344. case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
  345. case NOTIFICATION_TRANSLATION_CHANGED:
  346. case NOTIFICATION_THEME_CHANGED: {
  347. _shape();
  348. update_minimum_size();
  349. queue_redraw();
  350. } break;
  351. }
  352. }
  353. void GraphNode::_shape() {
  354. Ref<Font> font = get_theme_font(SNAME("title_font"));
  355. int font_size = get_theme_font_size(SNAME("title_font_size"));
  356. title_buf->clear();
  357. if (text_direction == Control::TEXT_DIRECTION_INHERITED) {
  358. title_buf->set_direction(is_layout_rtl() ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR);
  359. } else {
  360. title_buf->set_direction((TextServer::Direction)text_direction);
  361. }
  362. title_buf->add_string(title, font, font_size, language);
  363. }
  364. #ifdef TOOLS_ENABLED
  365. void GraphNode::_edit_set_position(const Point2 &p_position) {
  366. GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent());
  367. if (graph) {
  368. Point2 offset = (p_position + graph->get_scroll_ofs()) * graph->get_zoom();
  369. set_position_offset(offset);
  370. }
  371. set_position(p_position);
  372. }
  373. #endif
  374. void GraphNode::_validate_property(PropertyInfo &p_property) const {
  375. GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent());
  376. if (graph) {
  377. if (p_property.name == "position") {
  378. p_property.usage |= PROPERTY_USAGE_READ_ONLY;
  379. }
  380. }
  381. }
  382. 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<Texture2D> &p_custom_left, const Ref<Texture2D> &p_custom_right, bool p_draw_stylebox) {
  383. ERR_FAIL_COND_MSG(p_idx < 0, vformat("Cannot set slot with p_idx (%d) lesser than zero.", p_idx));
  384. if (!p_enable_left && p_type_left == 0 && p_color_left == Color(1, 1, 1, 1) &&
  385. !p_enable_right && p_type_right == 0 && p_color_right == Color(1, 1, 1, 1) &&
  386. !p_custom_left.is_valid() && !p_custom_right.is_valid()) {
  387. slot_info.erase(p_idx);
  388. return;
  389. }
  390. Slot s;
  391. s.enable_left = p_enable_left;
  392. s.type_left = p_type_left;
  393. s.color_left = p_color_left;
  394. s.enable_right = p_enable_right;
  395. s.type_right = p_type_right;
  396. s.color_right = p_color_right;
  397. s.custom_slot_left = p_custom_left;
  398. s.custom_slot_right = p_custom_right;
  399. s.draw_stylebox = p_draw_stylebox;
  400. slot_info[p_idx] = s;
  401. queue_redraw();
  402. connpos_dirty = true;
  403. emit_signal(SNAME("slot_updated"), p_idx);
  404. }
  405. void GraphNode::clear_slot(int p_idx) {
  406. slot_info.erase(p_idx);
  407. queue_redraw();
  408. connpos_dirty = true;
  409. }
  410. void GraphNode::clear_all_slots() {
  411. slot_info.clear();
  412. queue_redraw();
  413. connpos_dirty = true;
  414. }
  415. bool GraphNode::is_slot_enabled_left(int p_idx) const {
  416. if (!slot_info.has(p_idx)) {
  417. return false;
  418. }
  419. return slot_info[p_idx].enable_left;
  420. }
  421. void GraphNode::set_slot_enabled_left(int p_idx, bool p_enable_left) {
  422. ERR_FAIL_COND_MSG(p_idx < 0, vformat("Cannot set enable_left for the slot with p_idx (%d) lesser than zero.", p_idx));
  423. if (slot_info[p_idx].enable_left == p_enable_left) {
  424. return;
  425. }
  426. slot_info[p_idx].enable_left = p_enable_left;
  427. queue_redraw();
  428. connpos_dirty = true;
  429. emit_signal(SNAME("slot_updated"), p_idx);
  430. }
  431. void GraphNode::set_slot_type_left(int p_idx, int p_type_left) {
  432. ERR_FAIL_COND_MSG(!slot_info.has(p_idx), vformat("Cannot set type_left for the slot '%d' because it hasn't been enabled.", p_idx));
  433. if (slot_info[p_idx].type_left == p_type_left) {
  434. return;
  435. }
  436. slot_info[p_idx].type_left = p_type_left;
  437. queue_redraw();
  438. connpos_dirty = true;
  439. emit_signal(SNAME("slot_updated"), p_idx);
  440. }
  441. int GraphNode::get_slot_type_left(int p_idx) const {
  442. if (!slot_info.has(p_idx)) {
  443. return 0;
  444. }
  445. return slot_info[p_idx].type_left;
  446. }
  447. void GraphNode::set_slot_color_left(int p_idx, const Color &p_color_left) {
  448. ERR_FAIL_COND_MSG(!slot_info.has(p_idx), vformat("Cannot set color_left for the slot '%d' because it hasn't been enabled.", p_idx));
  449. if (slot_info[p_idx].color_left == p_color_left) {
  450. return;
  451. }
  452. slot_info[p_idx].color_left = p_color_left;
  453. queue_redraw();
  454. connpos_dirty = true;
  455. emit_signal(SNAME("slot_updated"), p_idx);
  456. }
  457. Color GraphNode::get_slot_color_left(int p_idx) const {
  458. if (!slot_info.has(p_idx)) {
  459. return Color(1, 1, 1, 1);
  460. }
  461. return slot_info[p_idx].color_left;
  462. }
  463. bool GraphNode::is_slot_enabled_right(int p_idx) const {
  464. if (!slot_info.has(p_idx)) {
  465. return false;
  466. }
  467. return slot_info[p_idx].enable_right;
  468. }
  469. void GraphNode::set_slot_enabled_right(int p_idx, bool p_enable_right) {
  470. ERR_FAIL_COND_MSG(p_idx < 0, vformat("Cannot set enable_right for the slot with p_idx (%d) lesser than zero.", p_idx));
  471. if (slot_info[p_idx].enable_right == p_enable_right) {
  472. return;
  473. }
  474. slot_info[p_idx].enable_right = p_enable_right;
  475. queue_redraw();
  476. connpos_dirty = true;
  477. emit_signal(SNAME("slot_updated"), p_idx);
  478. }
  479. void GraphNode::set_slot_type_right(int p_idx, int p_type_right) {
  480. ERR_FAIL_COND_MSG(!slot_info.has(p_idx), vformat("Cannot set type_right for the slot '%d' because it hasn't been enabled.", p_idx));
  481. if (slot_info[p_idx].type_right == p_type_right) {
  482. return;
  483. }
  484. slot_info[p_idx].type_right = p_type_right;
  485. queue_redraw();
  486. connpos_dirty = true;
  487. emit_signal(SNAME("slot_updated"), p_idx);
  488. }
  489. int GraphNode::get_slot_type_right(int p_idx) const {
  490. if (!slot_info.has(p_idx)) {
  491. return 0;
  492. }
  493. return slot_info[p_idx].type_right;
  494. }
  495. void GraphNode::set_slot_color_right(int p_idx, const Color &p_color_right) {
  496. ERR_FAIL_COND_MSG(!slot_info.has(p_idx), vformat("Cannot set color_right for the slot '%d' because it hasn't been enabled.", p_idx));
  497. if (slot_info[p_idx].color_right == p_color_right) {
  498. return;
  499. }
  500. slot_info[p_idx].color_right = p_color_right;
  501. queue_redraw();
  502. connpos_dirty = true;
  503. emit_signal(SNAME("slot_updated"), p_idx);
  504. }
  505. Color GraphNode::get_slot_color_right(int p_idx) const {
  506. if (!slot_info.has(p_idx)) {
  507. return Color(1, 1, 1, 1);
  508. }
  509. return slot_info[p_idx].color_right;
  510. }
  511. bool GraphNode::is_slot_draw_stylebox(int p_idx) const {
  512. if (!slot_info.has(p_idx)) {
  513. return false;
  514. }
  515. return slot_info[p_idx].draw_stylebox;
  516. }
  517. void GraphNode::set_slot_draw_stylebox(int p_idx, bool p_enable) {
  518. ERR_FAIL_COND_MSG(p_idx < 0, vformat("Cannot set draw_stylebox for the slot with p_idx (%d) lesser than zero.", p_idx));
  519. slot_info[p_idx].draw_stylebox = p_enable;
  520. queue_redraw();
  521. connpos_dirty = true;
  522. emit_signal(SNAME("slot_updated"), p_idx);
  523. }
  524. Size2 GraphNode::get_minimum_size() const {
  525. Ref<StyleBox> sb = get_theme_stylebox(SNAME("frame"));
  526. Ref<StyleBox> sb_slot = get_theme_stylebox(SNAME("slot"));
  527. int sep = get_theme_constant(SNAME("separation"));
  528. int title_h_offset = get_theme_constant(SNAME("title_h_offset"));
  529. bool first = true;
  530. Size2 minsize;
  531. minsize.x = title_buf->get_size().x + title_h_offset;
  532. if (show_close) {
  533. int close_h_offset = get_theme_constant(SNAME("close_h_offset"));
  534. Ref<Texture2D> close = get_theme_icon(SNAME("close"));
  535. //TODO: Remove this magic number after GraphNode rework.
  536. minsize.x += 12 + close->get_width() + close_h_offset;
  537. }
  538. for (int i = 0; i < get_child_count(); i++) {
  539. Control *c = Object::cast_to<Control>(get_child(i));
  540. if (!c) {
  541. continue;
  542. }
  543. if (c->is_set_as_top_level()) {
  544. continue;
  545. }
  546. Size2i size = c->get_combined_minimum_size();
  547. if (slot_info.has(i)) {
  548. size += slot_info[i].draw_stylebox ? sb_slot->get_minimum_size() : Size2();
  549. }
  550. minsize.y += size.y;
  551. minsize.x = MAX(minsize.x, size.x);
  552. if (first) {
  553. first = false;
  554. } else {
  555. minsize.y += sep;
  556. }
  557. }
  558. return minsize + sb->get_minimum_size();
  559. }
  560. void GraphNode::set_title(const String &p_title) {
  561. if (title == p_title) {
  562. return;
  563. }
  564. title = p_title;
  565. _shape();
  566. queue_redraw();
  567. update_minimum_size();
  568. }
  569. String GraphNode::get_title() const {
  570. return title;
  571. }
  572. void GraphNode::set_text_direction(Control::TextDirection p_text_direction) {
  573. ERR_FAIL_COND((int)p_text_direction < -1 || (int)p_text_direction > 3);
  574. if (text_direction != p_text_direction) {
  575. text_direction = p_text_direction;
  576. _shape();
  577. queue_redraw();
  578. }
  579. }
  580. Control::TextDirection GraphNode::get_text_direction() const {
  581. return text_direction;
  582. }
  583. void GraphNode::set_language(const String &p_language) {
  584. if (language != p_language) {
  585. language = p_language;
  586. _shape();
  587. queue_redraw();
  588. }
  589. }
  590. String GraphNode::get_language() const {
  591. return language;
  592. }
  593. void GraphNode::set_position_offset(const Vector2 &p_offset) {
  594. if (position_offset == p_offset) {
  595. return;
  596. }
  597. position_offset = p_offset;
  598. emit_signal(SNAME("position_offset_changed"));
  599. queue_redraw();
  600. }
  601. Vector2 GraphNode::get_position_offset() const {
  602. return position_offset;
  603. }
  604. void GraphNode::set_selected(bool p_selected) {
  605. if (!is_selectable() || selected == p_selected) {
  606. return;
  607. }
  608. selected = p_selected;
  609. emit_signal(p_selected ? SNAME("selected") : SNAME("deselected"));
  610. queue_redraw();
  611. }
  612. bool GraphNode::is_selected() {
  613. return selected;
  614. }
  615. void GraphNode::set_drag(bool p_drag) {
  616. if (p_drag) {
  617. drag_from = get_position_offset();
  618. } else {
  619. emit_signal(SNAME("dragged"), drag_from, get_position_offset()); //useful for undo/redo
  620. }
  621. }
  622. Vector2 GraphNode::get_drag_from() {
  623. return drag_from;
  624. }
  625. void GraphNode::set_show_close_button(bool p_enable) {
  626. if (show_close == p_enable) {
  627. return;
  628. }
  629. show_close = p_enable;
  630. queue_redraw();
  631. }
  632. bool GraphNode::is_close_button_visible() const {
  633. return show_close;
  634. }
  635. void GraphNode::_connpos_update() {
  636. int edgeofs = get_theme_constant(SNAME("port_offset"));
  637. int sep = get_theme_constant(SNAME("separation"));
  638. Ref<StyleBox> sb = get_theme_stylebox(SNAME("frame"));
  639. left_port_cache.clear();
  640. right_port_cache.clear();
  641. int vofs = 0;
  642. int idx = 0;
  643. for (int i = 0; i < get_child_count(); i++) {
  644. Control *c = Object::cast_to<Control>(get_child(i));
  645. if (!c) {
  646. continue;
  647. }
  648. if (c->is_set_as_top_level()) {
  649. continue;
  650. }
  651. Size2i size = c->get_rect().size;
  652. int y = sb->get_margin(SIDE_TOP) + vofs;
  653. int h = size.y;
  654. if (slot_info.has(idx)) {
  655. if (slot_info[idx].enable_left) {
  656. PortCache cc;
  657. cc.position = Point2i(edgeofs, y + h / 2);
  658. cc.height = size.height;
  659. cc.slot_idx = idx;
  660. cc.type = slot_info[idx].type_left;
  661. cc.color = slot_info[idx].color_left;
  662. left_port_cache.push_back(cc);
  663. }
  664. if (slot_info[idx].enable_right) {
  665. PortCache cc;
  666. cc.position = Point2i(get_size().width - edgeofs, y + h / 2);
  667. cc.height = size.height;
  668. cc.slot_idx = idx;
  669. cc.type = slot_info[idx].type_right;
  670. cc.color = slot_info[idx].color_right;
  671. right_port_cache.push_back(cc);
  672. }
  673. }
  674. vofs += sep;
  675. vofs += size.y;
  676. idx++;
  677. }
  678. connpos_dirty = false;
  679. }
  680. int GraphNode::get_connection_input_count() {
  681. if (connpos_dirty) {
  682. _connpos_update();
  683. }
  684. return left_port_cache.size();
  685. }
  686. int GraphNode::get_connection_input_height(int p_port) {
  687. if (connpos_dirty) {
  688. _connpos_update();
  689. }
  690. ERR_FAIL_INDEX_V(p_port, left_port_cache.size(), 0);
  691. return left_port_cache[p_port].height;
  692. }
  693. Vector2 GraphNode::get_connection_input_position(int p_port) {
  694. if (connpos_dirty) {
  695. _connpos_update();
  696. }
  697. ERR_FAIL_INDEX_V(p_port, left_port_cache.size(), Vector2());
  698. Vector2 pos = left_port_cache[p_port].position;
  699. pos.x *= get_scale().x;
  700. pos.y *= get_scale().y;
  701. return pos;
  702. }
  703. int GraphNode::get_connection_input_type(int p_port) {
  704. if (connpos_dirty) {
  705. _connpos_update();
  706. }
  707. ERR_FAIL_INDEX_V(p_port, left_port_cache.size(), 0);
  708. return left_port_cache[p_port].type;
  709. }
  710. Color GraphNode::get_connection_input_color(int p_port) {
  711. if (connpos_dirty) {
  712. _connpos_update();
  713. }
  714. ERR_FAIL_INDEX_V(p_port, left_port_cache.size(), Color());
  715. return left_port_cache[p_port].color;
  716. }
  717. int GraphNode::get_connection_input_slot(int p_port) {
  718. if (connpos_dirty) {
  719. _connpos_update();
  720. }
  721. ERR_FAIL_INDEX_V(p_port, left_port_cache.size(), -1);
  722. return left_port_cache[p_port].slot_idx;
  723. }
  724. int GraphNode::get_connection_output_count() {
  725. if (connpos_dirty) {
  726. _connpos_update();
  727. }
  728. return right_port_cache.size();
  729. }
  730. int GraphNode::get_connection_output_height(int p_port) {
  731. if (connpos_dirty) {
  732. _connpos_update();
  733. }
  734. ERR_FAIL_INDEX_V(p_port, right_port_cache.size(), 0);
  735. return right_port_cache[p_port].height;
  736. }
  737. Vector2 GraphNode::get_connection_output_position(int p_port) {
  738. if (connpos_dirty) {
  739. _connpos_update();
  740. }
  741. ERR_FAIL_INDEX_V(p_port, right_port_cache.size(), Vector2());
  742. Vector2 pos = right_port_cache[p_port].position;
  743. pos.x *= get_scale().x;
  744. pos.y *= get_scale().y;
  745. return pos;
  746. }
  747. int GraphNode::get_connection_output_type(int p_port) {
  748. if (connpos_dirty) {
  749. _connpos_update();
  750. }
  751. ERR_FAIL_INDEX_V(p_port, right_port_cache.size(), 0);
  752. return right_port_cache[p_port].type;
  753. }
  754. Color GraphNode::get_connection_output_color(int p_port) {
  755. if (connpos_dirty) {
  756. _connpos_update();
  757. }
  758. ERR_FAIL_INDEX_V(p_port, right_port_cache.size(), Color());
  759. return right_port_cache[p_port].color;
  760. }
  761. int GraphNode::get_connection_output_slot(int p_port) {
  762. if (connpos_dirty) {
  763. _connpos_update();
  764. }
  765. ERR_FAIL_INDEX_V(p_port, right_port_cache.size(), -1);
  766. return right_port_cache[p_port].slot_idx;
  767. }
  768. void GraphNode::gui_input(const Ref<InputEvent> &p_ev) {
  769. ERR_FAIL_COND(p_ev.is_null());
  770. Ref<InputEventMouseButton> mb = p_ev;
  771. if (mb.is_valid()) {
  772. ERR_FAIL_COND_MSG(get_parent_control() == nullptr, "GraphNode must be the child of a GraphEdit node.");
  773. if (mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
  774. Vector2 mpos = mb->get_position();
  775. if (close_rect.size != Size2() && close_rect.has_point(mpos)) {
  776. //send focus to parent
  777. get_parent_control()->grab_focus();
  778. emit_signal(SNAME("close_request"));
  779. accept_event();
  780. return;
  781. }
  782. Ref<Texture2D> resizer = get_theme_icon(SNAME("resizer"));
  783. if (resizable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) {
  784. resizing = true;
  785. resizing_from = mpos;
  786. resizing_from_size = get_size();
  787. accept_event();
  788. return;
  789. }
  790. emit_signal(SNAME("raise_request"));
  791. }
  792. if (!mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
  793. resizing = false;
  794. }
  795. }
  796. Ref<InputEventMouseMotion> mm = p_ev;
  797. if (resizing && mm.is_valid()) {
  798. Vector2 mpos = mm->get_position();
  799. Vector2 diff = mpos - resizing_from;
  800. emit_signal(SNAME("resize_request"), resizing_from_size + diff);
  801. }
  802. }
  803. void GraphNode::set_overlay(Overlay p_overlay) {
  804. if (overlay == p_overlay) {
  805. return;
  806. }
  807. overlay = p_overlay;
  808. queue_redraw();
  809. }
  810. GraphNode::Overlay GraphNode::get_overlay() const {
  811. return overlay;
  812. }
  813. void GraphNode::set_comment(bool p_enable) {
  814. if (comment == p_enable) {
  815. return;
  816. }
  817. comment = p_enable;
  818. queue_redraw();
  819. }
  820. bool GraphNode::is_comment() const {
  821. return comment;
  822. }
  823. void GraphNode::set_resizable(bool p_enable) {
  824. if (resizable == p_enable) {
  825. return;
  826. }
  827. resizable = p_enable;
  828. queue_redraw();
  829. }
  830. bool GraphNode::is_resizable() const {
  831. return resizable;
  832. }
  833. void GraphNode::set_draggable(bool p_draggable) {
  834. draggable = p_draggable;
  835. }
  836. bool GraphNode::is_draggable() {
  837. return draggable;
  838. }
  839. void GraphNode::set_selectable(bool p_selectable) {
  840. if (!p_selectable) {
  841. set_selected(false);
  842. }
  843. selectable = p_selectable;
  844. }
  845. bool GraphNode::is_selectable() {
  846. return selectable;
  847. }
  848. Vector<int> GraphNode::get_allowed_size_flags_horizontal() const {
  849. Vector<int> flags;
  850. flags.append(SIZE_FILL);
  851. flags.append(SIZE_SHRINK_BEGIN);
  852. flags.append(SIZE_SHRINK_CENTER);
  853. flags.append(SIZE_SHRINK_END);
  854. return flags;
  855. }
  856. Vector<int> GraphNode::get_allowed_size_flags_vertical() const {
  857. Vector<int> flags;
  858. flags.append(SIZE_FILL);
  859. flags.append(SIZE_EXPAND);
  860. flags.append(SIZE_SHRINK_BEGIN);
  861. flags.append(SIZE_SHRINK_CENTER);
  862. flags.append(SIZE_SHRINK_END);
  863. return flags;
  864. }
  865. void GraphNode::_bind_methods() {
  866. ClassDB::bind_method(D_METHOD("set_title", "title"), &GraphNode::set_title);
  867. ClassDB::bind_method(D_METHOD("get_title"), &GraphNode::get_title);
  868. ClassDB::bind_method(D_METHOD("set_text_direction", "direction"), &GraphNode::set_text_direction);
  869. ClassDB::bind_method(D_METHOD("get_text_direction"), &GraphNode::get_text_direction);
  870. ClassDB::bind_method(D_METHOD("set_language", "language"), &GraphNode::set_language);
  871. ClassDB::bind_method(D_METHOD("get_language"), &GraphNode::get_language);
  872. ClassDB::bind_method(D_METHOD("set_slot", "slot_index", "enable_left_port", "type_left", "color_left", "enable_right_port", "type_right", "color_right", "custom_icon_left", "custom_icon_right", "draw_stylebox"), &GraphNode::set_slot, DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(true));
  873. ClassDB::bind_method(D_METHOD("clear_slot", "slot_index"), &GraphNode::clear_slot);
  874. ClassDB::bind_method(D_METHOD("clear_all_slots"), &GraphNode::clear_all_slots);
  875. ClassDB::bind_method(D_METHOD("set_slot_enabled_left", "slot_index", "enable"), &GraphNode::set_slot_enabled_left);
  876. ClassDB::bind_method(D_METHOD("is_slot_enabled_left", "slot_index"), &GraphNode::is_slot_enabled_left);
  877. ClassDB::bind_method(D_METHOD("set_slot_type_left", "slot_index", "type"), &GraphNode::set_slot_type_left);
  878. ClassDB::bind_method(D_METHOD("get_slot_type_left", "slot_index"), &GraphNode::get_slot_type_left);
  879. ClassDB::bind_method(D_METHOD("set_slot_color_left", "slot_index", "color"), &GraphNode::set_slot_color_left);
  880. ClassDB::bind_method(D_METHOD("get_slot_color_left", "slot_index"), &GraphNode::get_slot_color_left);
  881. ClassDB::bind_method(D_METHOD("set_slot_enabled_right", "slot_index", "enable"), &GraphNode::set_slot_enabled_right);
  882. ClassDB::bind_method(D_METHOD("is_slot_enabled_right", "slot_index"), &GraphNode::is_slot_enabled_right);
  883. ClassDB::bind_method(D_METHOD("set_slot_type_right", "slot_index", "type"), &GraphNode::set_slot_type_right);
  884. ClassDB::bind_method(D_METHOD("get_slot_type_right", "slot_index"), &GraphNode::get_slot_type_right);
  885. ClassDB::bind_method(D_METHOD("set_slot_color_right", "slot_index", "color"), &GraphNode::set_slot_color_right);
  886. ClassDB::bind_method(D_METHOD("get_slot_color_right", "slot_index"), &GraphNode::get_slot_color_right);
  887. ClassDB::bind_method(D_METHOD("is_slot_draw_stylebox", "slot_index"), &GraphNode::is_slot_draw_stylebox);
  888. ClassDB::bind_method(D_METHOD("set_slot_draw_stylebox", "slot_index", "enable"), &GraphNode::set_slot_draw_stylebox);
  889. ClassDB::bind_method(D_METHOD("set_position_offset", "offset"), &GraphNode::set_position_offset);
  890. ClassDB::bind_method(D_METHOD("get_position_offset"), &GraphNode::get_position_offset);
  891. ClassDB::bind_method(D_METHOD("set_comment", "comment"), &GraphNode::set_comment);
  892. ClassDB::bind_method(D_METHOD("is_comment"), &GraphNode::is_comment);
  893. ClassDB::bind_method(D_METHOD("set_resizable", "resizable"), &GraphNode::set_resizable);
  894. ClassDB::bind_method(D_METHOD("is_resizable"), &GraphNode::is_resizable);
  895. ClassDB::bind_method(D_METHOD("set_draggable", "draggable"), &GraphNode::set_draggable);
  896. ClassDB::bind_method(D_METHOD("is_draggable"), &GraphNode::is_draggable);
  897. ClassDB::bind_method(D_METHOD("set_selectable", "selectable"), &GraphNode::set_selectable);
  898. ClassDB::bind_method(D_METHOD("is_selectable"), &GraphNode::is_selectable);
  899. ClassDB::bind_method(D_METHOD("set_selected", "selected"), &GraphNode::set_selected);
  900. ClassDB::bind_method(D_METHOD("is_selected"), &GraphNode::is_selected);
  901. ClassDB::bind_method(D_METHOD("get_connection_input_count"), &GraphNode::get_connection_input_count);
  902. ClassDB::bind_method(D_METHOD("get_connection_input_height", "port"), &GraphNode::get_connection_input_height);
  903. ClassDB::bind_method(D_METHOD("get_connection_input_position", "port"), &GraphNode::get_connection_input_position);
  904. ClassDB::bind_method(D_METHOD("get_connection_input_type", "port"), &GraphNode::get_connection_input_type);
  905. ClassDB::bind_method(D_METHOD("get_connection_input_color", "port"), &GraphNode::get_connection_input_color);
  906. ClassDB::bind_method(D_METHOD("get_connection_input_slot", "port"), &GraphNode::get_connection_input_slot);
  907. ClassDB::bind_method(D_METHOD("get_connection_output_count"), &GraphNode::get_connection_output_count);
  908. ClassDB::bind_method(D_METHOD("get_connection_output_height", "port"), &GraphNode::get_connection_output_height);
  909. ClassDB::bind_method(D_METHOD("get_connection_output_position", "port"), &GraphNode::get_connection_output_position);
  910. ClassDB::bind_method(D_METHOD("get_connection_output_type", "port"), &GraphNode::get_connection_output_type);
  911. ClassDB::bind_method(D_METHOD("get_connection_output_color", "port"), &GraphNode::get_connection_output_color);
  912. ClassDB::bind_method(D_METHOD("get_connection_output_slot", "port"), &GraphNode::get_connection_output_slot);
  913. ClassDB::bind_method(D_METHOD("set_show_close_button", "show"), &GraphNode::set_show_close_button);
  914. ClassDB::bind_method(D_METHOD("is_close_button_visible"), &GraphNode::is_close_button_visible);
  915. ClassDB::bind_method(D_METHOD("set_overlay", "overlay"), &GraphNode::set_overlay);
  916. ClassDB::bind_method(D_METHOD("get_overlay"), &GraphNode::get_overlay);
  917. ADD_PROPERTY(PropertyInfo(Variant::STRING, "title"), "set_title", "get_title");
  918. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position_offset", PROPERTY_HINT_NONE, "suffix:px"), "set_position_offset", "get_position_offset");
  919. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_close"), "set_show_close_button", "is_close_button_visible");
  920. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizable"), "set_resizable", "is_resizable");
  921. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draggable"), "set_draggable", "is_draggable");
  922. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selectable"), "set_selectable", "is_selectable");
  923. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selected"), "set_selected", "is_selected");
  924. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "comment"), "set_comment", "is_comment");
  925. ADD_PROPERTY(PropertyInfo(Variant::INT, "overlay", PROPERTY_HINT_ENUM, "Disabled,Breakpoint,Position"), "set_overlay", "get_overlay");
  926. ADD_GROUP("BiDi", "");
  927. ADD_PROPERTY(PropertyInfo(Variant::INT, "text_direction", PROPERTY_HINT_ENUM, "Auto,Left-to-Right,Right-to-Left,Inherited"), "set_text_direction", "get_text_direction");
  928. ADD_PROPERTY(PropertyInfo(Variant::STRING, "language", PROPERTY_HINT_LOCALE_ID, ""), "set_language", "get_language");
  929. ADD_GROUP("", "");
  930. ADD_SIGNAL(MethodInfo("position_offset_changed"));
  931. ADD_SIGNAL(MethodInfo("selected"));
  932. ADD_SIGNAL(MethodInfo("deselected"));
  933. ADD_SIGNAL(MethodInfo("slot_updated", PropertyInfo(Variant::INT, "idx")));
  934. ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::VECTOR2, "from"), PropertyInfo(Variant::VECTOR2, "to")));
  935. ADD_SIGNAL(MethodInfo("raise_request"));
  936. ADD_SIGNAL(MethodInfo("close_request"));
  937. ADD_SIGNAL(MethodInfo("resize_request", PropertyInfo(Variant::VECTOR2, "new_minsize")));
  938. BIND_ENUM_CONSTANT(OVERLAY_DISABLED);
  939. BIND_ENUM_CONSTANT(OVERLAY_BREAKPOINT);
  940. BIND_ENUM_CONSTANT(OVERLAY_POSITION);
  941. }
  942. GraphNode::GraphNode() {
  943. title_buf.instantiate();
  944. set_mouse_filter(MOUSE_FILTER_STOP);
  945. }