Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update WindowDialog title when translation changes #31078

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 25 additions & 14 deletions scene/gui/dialogs.cpp
Expand Up @@ -219,18 +219,28 @@ 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) {
if (get_default_cursor_shape() != CURSOR_ARROW)
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);
Expand Down Expand Up @@ -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 {

Expand All @@ -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);
Expand All @@ -324,7 +337,6 @@ void WindowDialog::_bind_methods() {

WindowDialog::WindowDialog() {

//title="Hello!";
drag_type = DRAG_NONE;
resizable = false;
close_button = memnew(TextureButton);
Expand All @@ -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()));
}
Expand All @@ -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;
}
}

Expand Down