dialogs.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*************************************************************************/
  2. /* dialogs.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "dialogs.h"
  31. #include "line_edit.h"
  32. #include "print_string.h"
  33. #include "translation.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. int msx = close_button->get_combined_minimum_size().x;
  248. msx += font->get_string_size(title).x;
  249. return Size2(msx, 1);
  250. }
  251. TextureButton *WindowDialog::get_close_button() {
  252. return close_button;
  253. }
  254. void WindowDialog::_bind_methods() {
  255. ClassDB::bind_method(D_METHOD("_gui_input"), &WindowDialog::_gui_input);
  256. ClassDB::bind_method(D_METHOD("set_title", "title"), &WindowDialog::set_title);
  257. ClassDB::bind_method(D_METHOD("get_title"), &WindowDialog::get_title);
  258. ClassDB::bind_method(D_METHOD("set_resizable", "resizable"), &WindowDialog::set_resizable);
  259. ClassDB::bind_method(D_METHOD("get_resizable"), &WindowDialog::get_resizable);
  260. ClassDB::bind_method(D_METHOD("_closed"), &WindowDialog::_closed);
  261. ClassDB::bind_method(D_METHOD("get_close_button"), &WindowDialog::get_close_button);
  262. ADD_PROPERTY(PropertyInfo(Variant::STRING, "window_title", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), "set_title", "get_title");
  263. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizable", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), "set_resizable", "get_resizable");
  264. }
  265. WindowDialog::WindowDialog() {
  266. //title="Hello!";
  267. drag_type = DRAG_NONE;
  268. resizable = false;
  269. close_button = memnew(TextureButton);
  270. add_child(close_button);
  271. close_button->connect("pressed", this, "_closed");
  272. }
  273. WindowDialog::~WindowDialog() {
  274. }
  275. // PopupDialog
  276. void PopupDialog::_notification(int p_what) {
  277. if (p_what == NOTIFICATION_DRAW) {
  278. RID ci = get_canvas_item();
  279. get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size()));
  280. }
  281. }
  282. PopupDialog::PopupDialog() {
  283. }
  284. PopupDialog::~PopupDialog() {
  285. }
  286. // AcceptDialog
  287. void AcceptDialog::_post_popup() {
  288. WindowDialog::_post_popup();
  289. get_ok()->grab_focus();
  290. }
  291. void AcceptDialog::_notification(int p_what) {
  292. if (p_what == NOTIFICATION_MODAL_CLOSE) {
  293. cancel_pressed();
  294. } else if (p_what == NOTIFICATION_READY) {
  295. _update_child_rects();
  296. } else if (p_what == NOTIFICATION_RESIZED) {
  297. _update_child_rects();
  298. }
  299. }
  300. void AcceptDialog::_builtin_text_entered(const String &p_text) {
  301. _ok_pressed();
  302. }
  303. void AcceptDialog::_ok_pressed() {
  304. if (hide_on_ok)
  305. hide();
  306. ok_pressed();
  307. emit_signal("confirmed");
  308. }
  309. void AcceptDialog::_close_pressed() {
  310. cancel_pressed();
  311. }
  312. String AcceptDialog::get_text() const {
  313. return label->get_text();
  314. }
  315. void AcceptDialog::set_text(String p_text) {
  316. label->set_text(p_text);
  317. minimum_size_changed();
  318. _update_child_rects();
  319. }
  320. void AcceptDialog::set_hide_on_ok(bool p_hide) {
  321. hide_on_ok = p_hide;
  322. }
  323. bool AcceptDialog::get_hide_on_ok() const {
  324. return hide_on_ok;
  325. }
  326. void AcceptDialog::register_text_enter(Node *p_line_edit) {
  327. ERR_FAIL_NULL(p_line_edit);
  328. p_line_edit->connect("text_entered", this, "_builtin_text_entered");
  329. }
  330. void AcceptDialog::_update_child_rects() {
  331. Size2 label_size = label->get_minimum_size();
  332. if (label->get_text().empty()) {
  333. label_size.height = 0;
  334. }
  335. int margin = get_constant("margin", "Dialogs");
  336. Size2 size = get_size();
  337. Size2 hminsize = hbc->get_combined_minimum_size();
  338. Vector2 cpos(margin, margin + label_size.height);
  339. Vector2 csize(size.x - margin * 2, size.y - margin * 3 - hminsize.y - label_size.height);
  340. for (int i = 0; i < get_child_count(); i++) {
  341. Control *c = Object::cast_to<Control>(get_child(i));
  342. if (!c)
  343. continue;
  344. if (c == hbc || c == label || c == get_close_button() || c->is_set_as_toplevel())
  345. continue;
  346. c->set_position(cpos);
  347. c->set_size(csize);
  348. }
  349. cpos.y += csize.y + margin;
  350. csize.y = hminsize.y;
  351. hbc->set_position(cpos);
  352. hbc->set_size(csize);
  353. }
  354. Size2 AcceptDialog::get_minimum_size() const {
  355. int margin = get_constant("margin", "Dialogs");
  356. Size2 minsize = label->get_combined_minimum_size();
  357. for (int i = 0; i < get_child_count(); i++) {
  358. Control *c = Object::cast_to<Control>(get_child(i));
  359. if (!c)
  360. continue;
  361. if (c == hbc || c == label || c == const_cast<AcceptDialog *>(this)->get_close_button() || c->is_set_as_toplevel())
  362. continue;
  363. Size2 cminsize = c->get_combined_minimum_size();
  364. minsize.x = MAX(cminsize.x, minsize.x);
  365. minsize.y = MAX(cminsize.y, minsize.y);
  366. }
  367. Size2 hminsize = hbc->get_combined_minimum_size();
  368. minsize.x = MAX(hminsize.x, minsize.x);
  369. minsize.y += hminsize.y;
  370. minsize.x += margin * 2;
  371. minsize.y += margin * 3; //one as separation between hbc and child
  372. Size2 wmsize = WindowDialog::get_minimum_size();
  373. minsize.x = MAX(wmsize.x, minsize.x);
  374. return minsize;
  375. }
  376. void AcceptDialog::_custom_action(const String &p_action) {
  377. emit_signal("custom_action", p_action);
  378. custom_action(p_action);
  379. }
  380. Button *AcceptDialog::add_button(const String &p_text, bool p_right, const String &p_action) {
  381. Button *button = memnew(Button);
  382. button->set_text(p_text);
  383. if (p_right) {
  384. hbc->add_child(button);
  385. hbc->add_spacer();
  386. } else {
  387. hbc->add_child(button);
  388. hbc->move_child(button, 0);
  389. hbc->add_spacer(true);
  390. }
  391. if (p_action != "") {
  392. button->connect("pressed", this, "_custom_action", varray(p_action));
  393. }
  394. return button;
  395. }
  396. Button *AcceptDialog::add_cancel(const String &p_cancel) {
  397. String c = p_cancel;
  398. if (p_cancel == "")
  399. c = RTR("Cancel");
  400. Button *b = swap_ok_cancel ? add_button(c, true) : add_button(c);
  401. b->connect("pressed", this, "_closed");
  402. return b;
  403. }
  404. void AcceptDialog::_bind_methods() {
  405. ClassDB::bind_method(D_METHOD("_ok"), &AcceptDialog::_ok_pressed);
  406. ClassDB::bind_method(D_METHOD("get_ok"), &AcceptDialog::get_ok);
  407. ClassDB::bind_method(D_METHOD("get_label"), &AcceptDialog::get_label);
  408. ClassDB::bind_method(D_METHOD("set_hide_on_ok", "enabled"), &AcceptDialog::set_hide_on_ok);
  409. ClassDB::bind_method(D_METHOD("get_hide_on_ok"), &AcceptDialog::get_hide_on_ok);
  410. ClassDB::bind_method(D_METHOD("add_button", "text", "right", "action"), &AcceptDialog::add_button, DEFVAL(false), DEFVAL(""));
  411. ClassDB::bind_method(D_METHOD("add_cancel", "name"), &AcceptDialog::add_cancel);
  412. ClassDB::bind_method(D_METHOD("_builtin_text_entered"), &AcceptDialog::_builtin_text_entered);
  413. ClassDB::bind_method(D_METHOD("register_text_enter", "line_edit"), &AcceptDialog::register_text_enter);
  414. ClassDB::bind_method(D_METHOD("_custom_action"), &AcceptDialog::_custom_action);
  415. ClassDB::bind_method(D_METHOD("set_text", "text"), &AcceptDialog::set_text);
  416. ClassDB::bind_method(D_METHOD("get_text"), &AcceptDialog::get_text);
  417. ADD_SIGNAL(MethodInfo("confirmed"));
  418. ADD_SIGNAL(MethodInfo("custom_action", PropertyInfo(Variant::STRING, "action")));
  419. ADD_GROUP("Dialog", "dialog");
  420. ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "dialog_text", PROPERTY_HINT_MULTILINE_TEXT, "", PROPERTY_USAGE_DEFAULT_INTL), "set_text", "get_text");
  421. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog_hide_on_ok"), "set_hide_on_ok", "get_hide_on_ok");
  422. }
  423. bool AcceptDialog::swap_ok_cancel = false;
  424. void AcceptDialog::set_swap_ok_cancel(bool p_swap) {
  425. swap_ok_cancel = p_swap;
  426. }
  427. AcceptDialog::AcceptDialog() {
  428. int margin = get_constant("margin", "Dialogs");
  429. int button_margin = get_constant("button_margin", "Dialogs");
  430. label = memnew(Label);
  431. label->set_anchor(MARGIN_RIGHT, ANCHOR_END);
  432. label->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
  433. label->set_begin(Point2(margin, margin));
  434. label->set_end(Point2(-margin, -button_margin - 10));
  435. //label->set_autowrap(true);
  436. add_child(label);
  437. hbc = memnew(HBoxContainer);
  438. add_child(hbc);
  439. hbc->add_spacer();
  440. ok = memnew(Button);
  441. ok->set_text(RTR("OK"));
  442. hbc->add_child(ok);
  443. hbc->add_spacer();
  444. ok->connect("pressed", this, "_ok");
  445. set_as_toplevel(true);
  446. hide_on_ok = true;
  447. set_title(RTR("Alert!"));
  448. }
  449. AcceptDialog::~AcceptDialog() {
  450. }
  451. // ConfirmationDialog
  452. void ConfirmationDialog::_bind_methods() {
  453. ClassDB::bind_method(D_METHOD("get_cancel"), &ConfirmationDialog::get_cancel);
  454. }
  455. Button *ConfirmationDialog::get_cancel() {
  456. return cancel;
  457. }
  458. ConfirmationDialog::ConfirmationDialog() {
  459. set_title(RTR("Please Confirm..."));
  460. #ifdef TOOLS_ENABLED
  461. set_custom_minimum_size(Size2(200, 70) * EDSCALE);
  462. #endif
  463. cancel = add_cancel();
  464. }