Prohibit inconsistent size state for SubViewport
Prohibit size changes of SubViewports with parent SubViewportContainers that have stretch mode enabled.
This commit is contained in:
parent
0056acf46f
commit
decbda68d7
5 changed files with 25 additions and 3 deletions
|
|
@ -4080,9 +4080,26 @@ Viewport::~Viewport() {
|
|||
/////////////////////////////////
|
||||
|
||||
void SubViewport::set_size(const Size2i &p_size) {
|
||||
_internal_set_size(p_size);
|
||||
}
|
||||
|
||||
void SubViewport::set_size_force(const Size2i &p_size) {
|
||||
// Use only for setting the size from the parent SubViewportContainer with enabled stretch mode.
|
||||
// Don't expose function to scripting.
|
||||
_internal_set_size(p_size, true);
|
||||
}
|
||||
|
||||
void SubViewport::_internal_set_size(const Size2i &p_size, bool p_force) {
|
||||
SubViewportContainer *c = Object::cast_to<SubViewportContainer>(get_parent());
|
||||
if (!p_force && c && c->is_stretch_enabled()) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
WARN_PRINT("Can't change the size of a `SubViewport` with a `SubViewportContainer` parent that has `stretch` enabled. Set `SubViewportContainer.stretch` to `false` to allow changing the size manually.");
|
||||
#endif // DEBUG_ENABLED
|
||||
return;
|
||||
}
|
||||
|
||||
_set_size(p_size, _get_size_2d_override(), Rect2i(), _stretch_transform(), true);
|
||||
|
||||
SubViewportContainer *c = Object::cast_to<SubViewportContainer>(get_parent());
|
||||
if (c) {
|
||||
c->update_minimum_size();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue