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 size according to the order of entering tree #77825

Closed

Conversation

Rindbee
Copy link
Contributor

@Rindbee Rindbee commented Jun 4, 2023

To calculate the size of a control, it is necessary to first calculate the size of the parent control.

Previously, the size was actually calculated on first display, and the call in NOTIFICATION_POST_ENTER_TREE was not necessary. In other words, size is not calculated correctly if it is hidden.

Fixes #77815.

To calculate the size of a control, it is necessary to first calculate the size
of the parent control.

Previously, the size was actually calculated on first display, and the call in
`NOTIFICATION_POST_ENTER_TREE` was not necessary.
@Rindbee Rindbee requested a review from a team as a code owner June 4, 2023 04:07
@KoBeWi KoBeWi added this to the 4.1 milestone Jun 4, 2023
@YuriSizov
Copy link
Contributor

For the record, reduz rejected this change before in #19334.

@Rindbee
Copy link
Contributor Author

Rindbee commented Jun 6, 2023

  1. because computing size with out of tree controls should never happen,
  2. and children nodes receive that notification after the parent, so for cases like this it's needed.

I think the second point pointed out by @reduz is the reason for the need to make changes. The order of receiving the notification NOTIFICATION_POST_ENTER_TREE is the same as the notification NOTIFICATION_READY, both of which are children nodes receive that notification before the parent (both in Node::_propagate_ready()).

notification(NOTIFICATION_POST_ENTER_TREE);

About the first point, _notification() is called in inheritance order. By the time NOTIFICATION_ENTER_TREE reaches Control, all prerequisites for calculating the size have been met, and the first drawing request has even been issued.

@YuriSizov
Copy link
Contributor

The order of receiving the notification NOTIFICATION_POST_ENTER_TREE is the same as the notification NOTIFICATION_READY, both of which are children nodes receive that notification before the parent

Yes, that's the point.

@akien-mga
Copy link
Member

Superseded by #78009.

@akien-mga akien-mga closed this Jun 12, 2023
@Rindbee Rindbee deleted the update_size_when_enter_tree branch June 12, 2023 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.1 SubViewport.size is always (2, 2)?
5 participants