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

Fixed widgets not being updated in BoxLayout when a child widget's index was changed using setWidgetIndex (fixes #202) #203

Merged
merged 1 commit into from Aug 27, 2023

Conversation

CasualYT31
Copy link
Contributor

@CasualYT31 CasualYT31 commented Aug 26, 2023

Previously, when a widget within a BoxLayout-derived container (HorizontalLayout, VerticalLayout, HorizontalWrap) had its index changed via Container::setWidgetIndex(), it would not update the widgets in the BoxLayout using updateWidgets(). This would cause the widget to appear not to have been assigned a new index, until updateWidgets() was called in some other way (for example, when the BoxLayout gained a new widget, or if the BoxLayout was resized).

Now, Container::setWidgetIndex() is virtual, and BoxLayout overrides it. The overridden implementation invokes Container::setWidgetIndex(), and returns the result of the call. If the result of that call is true, the index change was successful, so updateWidgets() is called to show the change in the index immediately.

@texus texus merged commit e778c38 into texus:1.x Aug 27, 2023
11 checks passed
@texus
Copy link
Owner

texus commented Aug 27, 2023

Thanks for the detailed information and the PR with a fix.

One minor detail: the using Container::setWidgetIndex; line isn't needed. I assume you added it because it was used on other overridden functions in BoxLayout, but it is only needed in a special case. If the base class contains multiple functions with the same name (but with different parameters), and only one of them is overridden, then the others would become hidden. The using line makes it such that you can still call both the overridden (e.g. setSize(Layout2d)) and non-overridden (e.g. setSize(Layout, Layout)) functions. There is only one setWidgetIndex function, so it doesn't apply here and the using line has no effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants