diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/dialogs.cpp | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 4da11b671e..59bbdad97a 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -219,6 +219,14 @@ void WindowDialog::_notification(int p_what) { close_button->set_begin(Point2(-get_constant("close_h_ofs", "WindowDialog"), -get_constant("close_v_ofs", "WindowDialog"))); } break; + case NOTIFICATION_TRANSLATION_CHANGED: { + String new_title = tr(title); + if (title != new_title) { + title = new_title; + update(); + } + } break; + case NOTIFICATION_MOUSE_EXIT: { // Reset the mouse cursor when leaving the resizable window border. if (resizable && !drag_type) { @@ -226,11 +234,13 @@ void WindowDialog::_notification(int p_what) { set_default_cursor_shape(CURSOR_ARROW); } } break; + #ifdef TOOLS_ENABLED case NOTIFICATION_POST_POPUP: { if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton()) EditorNode::get_singleton()->dim_editor(true); } break; + case NOTIFICATION_POPUP_HIDE: { if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton()) EditorNode::get_singleton()->dim_editor(false); @@ -272,8 +282,11 @@ int WindowDialog::_drag_hit_test(const Point2 &pos) const { void WindowDialog::set_title(const String &p_title) { - title = tr(p_title); - update(); + String new_title = tr(p_title); + if (title != new_title) { + title = new_title; + update(); + } } String WindowDialog::get_title() const { @@ -296,8 +309,8 @@ Size2 WindowDialog::get_minimum_size() const { const int padding = button_width / 2; const int button_area = button_width + padding; - // as the title gets centered, title_width + close_button_width is not enough. - // we want a width w, such that w / 2 - title_width / 2 >= button_area, i.e. + // As the title gets centered, title_width + close_button_width is not enough. + // We want a width w, such that w / 2 - title_width / 2 >= button_area, i.e. // w >= 2 * button_area + title_width return Size2(2 * button_area + title_width, 1); @@ -324,7 +337,6 @@ void WindowDialog::_bind_methods() { WindowDialog::WindowDialog() { - //title="Hello!"; drag_type = DRAG_NONE; resizable = false; close_button = memnew(TextureButton); @@ -340,7 +352,6 @@ WindowDialog::~WindowDialog() { void PopupDialog::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - RID ci = get_canvas_item(); get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size())); } @@ -362,15 +373,15 @@ void AcceptDialog::_post_popup() { void AcceptDialog::_notification(int p_what) { - if (p_what == NOTIFICATION_MODAL_CLOSE) { - - cancel_pressed(); - } else if (p_what == NOTIFICATION_READY) { - - _update_child_rects(); - } else if (p_what == NOTIFICATION_RESIZED) { + switch (p_what) { + case NOTIFICATION_MODAL_CLOSE: { + cancel_pressed(); + } break; - _update_child_rects(); + case NOTIFICATION_READY: + case NOTIFICATION_RESIZED: { + _update_child_rects(); + } break; } } |