diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-01-02 19:12:25 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-01-02 19:12:25 -0300 |
commit | ce26eb74bca48f16e9a34b4eb1c34e50dfc5daae (patch) | |
tree | 5f9c387037d0142d40f7275575436483dc0a7237 /scene/gui/dialogs.cpp | |
parent | ab4126f51061277e87b41c48b40e7b54942d4eca (diff) | |
parent | 45c5c89de961357a7042d9e1f063e288d7a510cf (diff) |
Merge branch 'master' of https://github.com/godotengine/godot
Diffstat (limited to 'scene/gui/dialogs.cpp')
-rw-r--r-- | scene/gui/dialogs.cpp | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index b8c5f227c6..ae5a51c3c5 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -254,52 +254,40 @@ void AcceptDialog::register_text_enter(Node *p_line_edit) { } void AcceptDialog::_update_child_rect() { - - const int margin = get_constant("margin","Dialogs"); - const Size2 size = get_size(); + Size2 label_size=label->get_minimum_size(); + if (label->get_text().empty()) { + label_size.height = 0; + } + int margin = get_constant("margin","Dialogs"); + Size2 size = get_size(); Size2 hminsize = hbc->get_combined_minimum_size(); - const Size2 max_csize( - size.width - margin * 2, - size.height - margin * 3 - hminsize.height); - hminsize.width = max_csize.width; - - Point2 cpos(margin, margin); - Size2 csize = label->get_combined_minimum_size(); - if(label->get_text().empty()) - csize.y = 0; - csize.x = MIN(csize.width, max_csize.width); - csize.y = MIN(csize.height, max_csize.height); - label->set_pos(cpos); - label->set_size(csize); - - if(child) { - const float child_y_offset = csize.height + (csize.height > 0 ? margin : 0); - cpos.y += child_y_offset; - csize = max_csize; - csize.height -= child_y_offset; + Vector2 cpos(margin,margin+label_size.height); + Vector2 csize(size.x-margin*2,size.y-margin*3-hminsize.y-label_size.height); + + if (child) { child->set_pos(cpos); child->set_size(csize); } - cpos.y += csize.height + margin; + cpos.y+=csize.y+margin; + csize.y=hminsize.y; hbc->set_pos(cpos); - hbc->set_size(hminsize); + hbc->set_size(csize); + } Size2 AcceptDialog::get_minimum_size() const { int margin = get_constant("margin","Dialogs"); Size2 minsize = label->get_combined_minimum_size(); - if(label->get_text().empty()) - minsize.y = 0; if (child) { Size2 cminsize = child->get_combined_minimum_size(); minsize.x=MAX(cminsize.x,minsize.x); - minsize.y += cminsize.y + (minsize.y > 0 ? margin : 0); + minsize.y=MAX(cminsize.y,minsize.y); } Size2 hminsize = hbc->get_combined_minimum_size(); |