dialogs.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. /*************************************************************************/
  2. /* dialogs.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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 "dialogs.h"
  31. #include "core/print_string.h"
  32. #include "core/translation.h"
  33. #include "line_edit.h"
  34. #ifdef TOOLS_ENABLED
  35. #include "editor/editor_node.h"
  36. #endif
  37. // WindowDialog
  38. void WindowDialog::_post_popup() {
  39. drag_type = DRAG_NONE; // just in case
  40. }
  41. void WindowDialog::_fix_size() {
  42. // Perhaps this should be called when the viewport resizes as well or windows go out of bounds...
  43. // Ensure the whole window is visible.
  44. Point2i pos = get_global_position();
  45. Size2i size = get_size();
  46. Size2i viewport_size = get_viewport_rect().size;
  47. // Windows require additional padding to keep the window chrome visible.
  48. Ref<StyleBox> panel = get_stylebox("panel", "WindowDialog");
  49. float top = 0;
  50. float left = 0;
  51. float bottom = 0;
  52. float right = 0;
  53. // Check validity, because the theme could contain a different type of StyleBox
  54. if (panel->get_class() == "StyleBoxTexture") {
  55. Ref<StyleBoxTexture> panel_texture = Object::cast_to<StyleBoxTexture>(*panel);
  56. top = panel_texture->get_expand_margin_size(MARGIN_TOP);
  57. left = panel_texture->get_expand_margin_size(MARGIN_LEFT);
  58. bottom = panel_texture->get_expand_margin_size(MARGIN_BOTTOM);
  59. right = panel_texture->get_expand_margin_size(MARGIN_RIGHT);
  60. } else if (panel->get_class() == "StyleBoxFlat") {
  61. Ref<StyleBoxFlat> panel_flat = Object::cast_to<StyleBoxFlat>(*panel);
  62. top = panel_flat->get_expand_margin_size(MARGIN_TOP);
  63. left = panel_flat->get_expand_margin_size(MARGIN_LEFT);
  64. bottom = panel_flat->get_expand_margin_size(MARGIN_BOTTOM);
  65. right = panel_flat->get_expand_margin_size(MARGIN_RIGHT);
  66. }
  67. pos.x = MAX(left, MIN(pos.x, viewport_size.x - size.x - right));
  68. pos.y = MAX(top, MIN(pos.y, viewport_size.y - size.y - bottom));
  69. set_global_position(pos);
  70. if (resizable) {
  71. size.x = MIN(size.x, viewport_size.x - left - right);
  72. size.y = MIN(size.y, viewport_size.y - top - bottom);
  73. set_size(size);
  74. }
  75. }
  76. bool WindowDialog::has_point(const Point2 &p_point) const {
  77. Rect2 r(Point2(), get_size());
  78. // Enlarge upwards for title bar.
  79. int title_height = get_constant("title_height", "WindowDialog");
  80. r.position.y -= title_height;
  81. r.size.y += title_height;
  82. // Inflate by the resizable border thickness.
  83. if (resizable) {
  84. int scaleborder_size = get_constant("scaleborder_size", "WindowDialog");
  85. r.position.x -= scaleborder_size;
  86. r.size.width += scaleborder_size * 2;
  87. r.position.y -= scaleborder_size;
  88. r.size.height += scaleborder_size * 2;
  89. }
  90. return r.has_point(p_point);
  91. }
  92. void WindowDialog::_gui_input(const Ref<InputEvent> &p_event) {
  93. Ref<InputEventMouseButton> mb = p_event;
  94. if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) {
  95. if (mb->is_pressed()) {
  96. // Begin a possible dragging operation.
  97. drag_type = _drag_hit_test(Point2(mb->get_position().x, mb->get_position().y));
  98. if (drag_type != DRAG_NONE)
  99. drag_offset = get_global_mouse_position() - get_position();
  100. drag_offset_far = get_position() + get_size() - get_global_mouse_position();
  101. } else if (drag_type != DRAG_NONE && !mb->is_pressed()) {
  102. // End a dragging operation.
  103. drag_type = DRAG_NONE;
  104. }
  105. }
  106. Ref<InputEventMouseMotion> mm = p_event;
  107. if (mm.is_valid()) {
  108. if (drag_type == DRAG_NONE) {
  109. // Update the cursor while moving along the borders.
  110. CursorShape cursor = CURSOR_ARROW;
  111. if (resizable) {
  112. int preview_drag_type = _drag_hit_test(Point2(mm->get_position().x, mm->get_position().y));
  113. switch (preview_drag_type) {
  114. case DRAG_RESIZE_TOP:
  115. case DRAG_RESIZE_BOTTOM:
  116. cursor = CURSOR_VSIZE;
  117. break;
  118. case DRAG_RESIZE_LEFT:
  119. case DRAG_RESIZE_RIGHT:
  120. cursor = CURSOR_HSIZE;
  121. break;
  122. case DRAG_RESIZE_TOP + DRAG_RESIZE_LEFT:
  123. case DRAG_RESIZE_BOTTOM + DRAG_RESIZE_RIGHT:
  124. cursor = CURSOR_FDIAGSIZE;
  125. break;
  126. case DRAG_RESIZE_TOP + DRAG_RESIZE_RIGHT:
  127. case DRAG_RESIZE_BOTTOM + DRAG_RESIZE_LEFT:
  128. cursor = CURSOR_BDIAGSIZE;
  129. break;
  130. }
  131. }
  132. if (get_cursor_shape() != cursor)
  133. set_default_cursor_shape(cursor);
  134. } else {
  135. // Update while in a dragging operation.
  136. Point2 global_pos = get_global_mouse_position();
  137. global_pos.y = MAX(global_pos.y, 0); // Ensure title bar stays visible.
  138. Rect2 rect = get_rect();
  139. Size2 min_size = get_minimum_size();
  140. if (drag_type == DRAG_MOVE) {
  141. rect.position = global_pos - drag_offset;
  142. } else {
  143. if (drag_type & DRAG_RESIZE_TOP) {
  144. int bottom = rect.position.y + rect.size.height;
  145. int max_y = bottom - min_size.height;
  146. rect.position.y = MIN(global_pos.y - drag_offset.y, max_y);
  147. rect.size.height = bottom - rect.position.y;
  148. } else if (drag_type & DRAG_RESIZE_BOTTOM) {
  149. rect.size.height = global_pos.y - rect.position.y + drag_offset_far.y;
  150. }
  151. if (drag_type & DRAG_RESIZE_LEFT) {
  152. int right = rect.position.x + rect.size.width;
  153. int max_x = right - min_size.width;
  154. rect.position.x = MIN(global_pos.x - drag_offset.x, max_x);
  155. rect.size.width = right - rect.position.x;
  156. } else if (drag_type & DRAG_RESIZE_RIGHT) {
  157. rect.size.width = global_pos.x - rect.position.x + drag_offset_far.x;
  158. }
  159. }
  160. set_size(rect.size);
  161. set_position(rect.position);
  162. }
  163. }
  164. }
  165. void WindowDialog::_notification(int p_what) {
  166. switch (p_what) {
  167. case NOTIFICATION_DRAW: {
  168. RID canvas = get_canvas_item();
  169. // Draw the background.
  170. Ref<StyleBox> panel = get_stylebox("panel");
  171. Size2 size = get_size();
  172. panel->draw(canvas, Rect2(0, 0, size.x, size.y));
  173. // Draw the title bar text.
  174. Ref<Font> title_font = get_font("title_font", "WindowDialog");
  175. Color title_color = get_color("title_color", "WindowDialog");
  176. int title_height = get_constant("title_height", "WindowDialog");
  177. int font_height = title_font->get_height() - title_font->get_descent() * 2;
  178. int x = (size.x - title_font->get_string_size(title).x) / 2;
  179. int y = (-title_height + font_height) / 2;
  180. title_font->draw(canvas, Point2(x, y), title, title_color, size.x - panel->get_minimum_size().x);
  181. } break;
  182. case NOTIFICATION_THEME_CHANGED:
  183. case NOTIFICATION_ENTER_TREE: {
  184. close_button->set_normal_texture(get_icon("close", "WindowDialog"));
  185. close_button->set_pressed_texture(get_icon("close", "WindowDialog"));
  186. close_button->set_hover_texture(get_icon("close_highlight", "WindowDialog"));
  187. close_button->set_anchor(MARGIN_LEFT, ANCHOR_END);
  188. close_button->set_begin(Point2(-get_constant("close_h_ofs", "WindowDialog"), -get_constant("close_v_ofs", "WindowDialog")));
  189. } break;
  190. case NOTIFICATION_MOUSE_EXIT: {
  191. // Reset the mouse cursor when leaving the resizable window border.
  192. if (resizable && !drag_type) {
  193. if (get_default_cursor_shape() != CURSOR_ARROW)
  194. set_default_cursor_shape(CURSOR_ARROW);
  195. }
  196. } break;
  197. #ifdef TOOLS_ENABLED
  198. case NOTIFICATION_POST_POPUP: {
  199. if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton())
  200. EditorNode::get_singleton()->dim_editor(true);
  201. } break;
  202. case NOTIFICATION_POPUP_HIDE: {
  203. if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton())
  204. EditorNode::get_singleton()->dim_editor(false);
  205. } break;
  206. #endif
  207. }
  208. }
  209. void WindowDialog::_closed() {
  210. _close_pressed();
  211. hide();
  212. }
  213. int WindowDialog::_drag_hit_test(const Point2 &pos) const {
  214. int drag_type = DRAG_NONE;
  215. if (resizable) {
  216. int title_height = get_constant("title_height", "WindowDialog");
  217. int scaleborder_size = get_constant("scaleborder_size", "WindowDialog");
  218. Rect2 rect = get_rect();
  219. if (pos.y < (-title_height + scaleborder_size))
  220. drag_type = DRAG_RESIZE_TOP;
  221. else if (pos.y >= (rect.size.height - scaleborder_size))
  222. drag_type = DRAG_RESIZE_BOTTOM;
  223. if (pos.x < scaleborder_size)
  224. drag_type |= DRAG_RESIZE_LEFT;
  225. else if (pos.x >= (rect.size.width - scaleborder_size))
  226. drag_type |= DRAG_RESIZE_RIGHT;
  227. }
  228. if (drag_type == DRAG_NONE && pos.y < 0)
  229. drag_type = DRAG_MOVE;
  230. return drag_type;
  231. }
  232. void WindowDialog::set_title(const String &p_title) {
  233. title = tr(p_title);
  234. update();
  235. }
  236. String WindowDialog::get_title() const {
  237. return title;
  238. }
  239. void WindowDialog::set_resizable(bool p_resizable) {
  240. resizable = p_resizable;
  241. }
  242. bool WindowDialog::get_resizable() const {
  243. return resizable;
  244. }
  245. Size2 WindowDialog::get_minimum_size() const {
  246. Ref<Font> font = get_font("title_font", "WindowDialog");
  247. const int button_width = close_button->get_combined_minimum_size().x;
  248. const int title_width = font->get_string_size(title).x;
  249. const int padding = button_width / 2;
  250. const int button_area = button_width + padding;
  251. // as the title gets centered, title_width + close_button_width is not enough.
  252. // we want a width w, such that w / 2 - title_width / 2 >= button_area, i.e.
  253. // w >= 2 * button_area + title_width
  254. return Size2(2 * button_area + title_width, 1);
  255. }
  256. TextureButton *WindowDialog::get_close_button() {
  257. return close_button;
  258. }
  259. void WindowDialog::_bind_methods() {
  260. ClassDB::bind_method(D_METHOD("_gui_input"), &WindowDialog::_gui_input);
  261. ClassDB::bind_method(D_METHOD("set_title", "title"), &WindowDialog::set_title);
  262. ClassDB::bind_method(D_METHOD("get_title"), &WindowDialog::get_title);
  263. ClassDB::bind_method(D_METHOD("set_resizable", "resizable"), &WindowDialog::set_resizable);
  264. ClassDB::bind_method(D_METHOD("get_resizable"), &WindowDialog::get_resizable);
  265. ClassDB::bind_method(D_METHOD("_closed"), &WindowDialog::_closed);
  266. ClassDB::bind_method(D_METHOD("get_close_button"), &WindowDialog::get_close_button);
  267. ADD_PROPERTY(PropertyInfo(Variant::STRING, "window_title", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), "set_title", "get_title");
  268. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizable", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), "set_resizable", "get_resizable");
  269. }
  270. WindowDialog::WindowDialog() {
  271. //title="Hello!";
  272. drag_type = DRAG_NONE;
  273. resizable = false;
  274. close_button = memnew(TextureButton);
  275. add_child(close_button);
  276. close_button->connect("pressed", this, "_closed");
  277. }
  278. WindowDialog::~WindowDialog() {
  279. }
  280. // PopupDialog
  281. void PopupDialog::_notification(int p_what) {
  282. if (p_what == NOTIFICATION_DRAW) {
  283. RID ci = get_canvas_item();
  284. get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size()));
  285. }
  286. }
  287. PopupDialog::PopupDialog() {
  288. }
  289. PopupDialog::~PopupDialog() {
  290. }
  291. // AcceptDialog
  292. void AcceptDialog::_post_popup() {
  293. WindowDialog::_post_popup();
  294. get_ok()->grab_focus();
  295. }
  296. void AcceptDialog::_notification(int p_what) {
  297. if (p_what == NOTIFICATION_MODAL_CLOSE) {
  298. cancel_pressed();
  299. } else if (p_what == NOTIFICATION_READY) {
  300. _update_child_rects();
  301. } else if (p_what == NOTIFICATION_RESIZED) {
  302. _update_child_rects();
  303. }
  304. }
  305. void AcceptDialog::_builtin_text_entered(const String &p_text) {
  306. _ok_pressed();
  307. }
  308. void AcceptDialog::_ok_pressed() {
  309. if (hide_on_ok)
  310. hide();
  311. ok_pressed();
  312. emit_signal("confirmed");
  313. }
  314. void AcceptDialog::_close_pressed() {
  315. cancel_pressed();
  316. }
  317. String AcceptDialog::get_text() const {
  318. return label->get_text();
  319. }
  320. void AcceptDialog::set_text(String p_text) {
  321. label->set_text(p_text);
  322. minimum_size_changed();
  323. _update_child_rects();
  324. }
  325. void AcceptDialog::set_hide_on_ok(bool p_hide) {
  326. hide_on_ok = p_hide;
  327. }
  328. bool AcceptDialog::get_hide_on_ok() const {
  329. return hide_on_ok;
  330. }
  331. void AcceptDialog::register_text_enter(Node *p_line_edit) {
  332. ERR_FAIL_NULL(p_line_edit);
  333. p_line_edit->connect("text_entered", this, "_builtin_text_entered");
  334. }
  335. void AcceptDialog::_update_child_rects() {
  336. Size2 label_size = label->get_minimum_size();
  337. if (label->get_text().empty()) {
  338. label_size.height = 0;
  339. }
  340. int margin = get_constant("margin", "Dialogs");
  341. Size2 size = get_size();
  342. Size2 hminsize = hbc->get_combined_minimum_size();
  343. Vector2 cpos(margin, margin + label_size.height);
  344. Vector2 csize(size.x - margin * 2, size.y - margin * 3 - hminsize.y - label_size.height);
  345. for (int i = 0; i < get_child_count(); i++) {
  346. Control *c = Object::cast_to<Control>(get_child(i));
  347. if (!c)
  348. continue;
  349. if (c == hbc || c == label || c == get_close_button() || c->is_set_as_toplevel())
  350. continue;
  351. c->set_position(cpos);
  352. c->set_size(csize);
  353. }
  354. cpos.y += csize.y + margin;
  355. csize.y = hminsize.y;
  356. hbc->set_position(cpos);
  357. hbc->set_size(csize);
  358. }
  359. Size2 AcceptDialog::get_minimum_size() const {
  360. int margin = get_constant("margin", "Dialogs");
  361. Size2 minsize = label->get_combined_minimum_size();
  362. for (int i = 0; i < get_child_count(); i++) {
  363. Control *c = Object::cast_to<Control>(get_child(i));
  364. if (!c)
  365. continue;
  366. if (c == hbc || c == label || c == const_cast<AcceptDialog *>(this)->get_close_button() || c->is_set_as_toplevel())
  367. continue;
  368. Size2 cminsize = c->get_combined_minimum_size();
  369. minsize.x = MAX(cminsize.x, minsize.x);
  370. minsize.y = MAX(cminsize.y, minsize.y);
  371. }
  372. Size2 hminsize = hbc->get_combined_minimum_size();
  373. minsize.x = MAX(hminsize.x, minsize.x);
  374. minsize.y += hminsize.y;
  375. minsize.x += margin * 2;
  376. minsize.y += margin * 3; //one as separation between hbc and child
  377. Size2 wmsize = WindowDialog::get_minimum_size();
  378. minsize.x = MAX(wmsize.x, minsize.x);
  379. return minsize;
  380. }
  381. void AcceptDialog::_custom_action(const String &p_action) {
  382. emit_signal("custom_action", p_action);
  383. custom_action(p_action);
  384. }
  385. Button *AcceptDialog::add_button(const String &p_text, bool p_right, const String &p_action) {
  386. Button *button = memnew(Button);
  387. button->set_text(p_text);
  388. if (p_right) {
  389. hbc->add_child(button);
  390. hbc->add_spacer();
  391. } else {
  392. hbc->add_child(button);
  393. hbc->move_child(button, 0);
  394. hbc->add_spacer(true);
  395. }
  396. if (p_action != "") {
  397. button->connect("pressed", this, "_custom_action", varray(p_action));
  398. }
  399. return button;
  400. }
  401. Button *AcceptDialog::add_cancel(const String &p_cancel) {
  402. String c = p_cancel;
  403. if (p_cancel == "")
  404. c = RTR("Cancel");
  405. Button *b = swap_ok_cancel ? add_button(c, true) : add_button(c);
  406. b->connect("pressed", this, "_closed");
  407. return b;
  408. }
  409. void AcceptDialog::_bind_methods() {
  410. ClassDB::bind_method(D_METHOD("_ok"), &AcceptDialog::_ok_pressed);
  411. ClassDB::bind_method(D_METHOD("get_ok"), &AcceptDialog::get_ok);
  412. ClassDB::bind_method(D_METHOD("get_label"), &AcceptDialog::get_label);
  413. ClassDB::bind_method(D_METHOD("set_hide_on_ok", "enabled"), &AcceptDialog::set_hide_on_ok);
  414. ClassDB::bind_method(D_METHOD("get_hide_on_ok"), &AcceptDialog::get_hide_on_ok);
  415. ClassDB::bind_method(D_METHOD("add_button", "text", "right", "action"), &AcceptDialog::add_button, DEFVAL(false), DEFVAL(""));
  416. ClassDB::bind_method(D_METHOD("add_cancel", "name"), &AcceptDialog::add_cancel);
  417. ClassDB::bind_method(D_METHOD("_builtin_text_entered"), &AcceptDialog::_builtin_text_entered);
  418. ClassDB::bind_method(D_METHOD("register_text_enter", "line_edit"), &AcceptDialog::register_text_enter);
  419. ClassDB::bind_method(D_METHOD("_custom_action"), &AcceptDialog::_custom_action);
  420. ClassDB::bind_method(D_METHOD("set_text", "text"), &AcceptDialog::set_text);
  421. ClassDB::bind_method(D_METHOD("get_text"), &AcceptDialog::get_text);
  422. ADD_SIGNAL(MethodInfo("confirmed"));
  423. ADD_SIGNAL(MethodInfo("custom_action", PropertyInfo(Variant::STRING, "action")));
  424. ADD_GROUP("Dialog", "dialog");
  425. ADD_PROPERTY(PropertyInfo(Variant::STRING, "dialog_text", PROPERTY_HINT_MULTILINE_TEXT, "", PROPERTY_USAGE_DEFAULT_INTL), "set_text", "get_text");
  426. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog_hide_on_ok"), "set_hide_on_ok", "get_hide_on_ok");
  427. }
  428. bool AcceptDialog::swap_ok_cancel = false;
  429. void AcceptDialog::set_swap_ok_cancel(bool p_swap) {
  430. swap_ok_cancel = p_swap;
  431. }
  432. AcceptDialog::AcceptDialog() {
  433. int margin = get_constant("margin", "Dialogs");
  434. int button_margin = get_constant("button_margin", "Dialogs");
  435. label = memnew(Label);
  436. label->set_anchor(MARGIN_RIGHT, ANCHOR_END);
  437. label->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
  438. label->set_begin(Point2(margin, margin));
  439. label->set_end(Point2(-margin, -button_margin - 10));
  440. //label->set_autowrap(true);
  441. add_child(label);
  442. hbc = memnew(HBoxContainer);
  443. add_child(hbc);
  444. hbc->add_spacer();
  445. ok = memnew(Button);
  446. ok->set_text(RTR("OK"));
  447. hbc->add_child(ok);
  448. hbc->add_spacer();
  449. ok->connect("pressed", this, "_ok");
  450. set_as_toplevel(true);
  451. hide_on_ok = true;
  452. set_title(RTR("Alert!"));
  453. }
  454. AcceptDialog::~AcceptDialog() {
  455. }
  456. // ConfirmationDialog
  457. void ConfirmationDialog::_bind_methods() {
  458. ClassDB::bind_method(D_METHOD("get_cancel"), &ConfirmationDialog::get_cancel);
  459. }
  460. Button *ConfirmationDialog::get_cancel() {
  461. return cancel;
  462. }
  463. ConfirmationDialog::ConfirmationDialog() {
  464. set_title(RTR("Please Confirm..."));
  465. #ifdef TOOLS_ENABLED
  466. set_custom_minimum_size(Size2(200, 70) * EDSCALE);
  467. #endif
  468. cancel = add_cancel();
  469. }