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

Keep scroll position when reinstantiating science_report #2330

Merged

Conversation

blabber
Copy link
Collaborator

@blabber blabber commented Jul 29, 2024

The science_report loses the scroll position when the view is closed. This is because the object is destroyed and therefore loses its state.

This commit adds code to track the scroll position in static fields and restore the state when the science_report is reinstantiated.

Closes #2329.

An alternative solution would be to prevent the destruction of science_report when the view is closed; this is the behavior in stable.

@blabber blabber force-pushed the bugfix/science_report_scroll_position branch from c459790 to 901acc0 Compare July 29, 2024 18:19
@blabber blabber requested a review from jwrober July 29, 2024 18:40
@blabber
Copy link
Collaborator Author

blabber commented Aug 1, 2024

All views are losing their state (scroll positions etc.), tracking and restoring them is possible, but I think we should take our time to check if we could restore the old behavior from stable (not destroying the instances). I am converting this into a draft PR for now.

@blabber blabber marked this pull request as draft August 1, 2024 16:59
@blabber blabber removed the request for review from jwrober August 1, 2024 16:59
@lmoureaux
Copy link
Contributor

Notes:

  • The position is lost when switching to the map view. Switching between views doesn't affect it
  • The city list is magically not reset
  • The default scroll location of the science report should probably focus on current research

@blabber blabber force-pushed the bugfix/science_report_scroll_position branch from 901acc0 to 3bc16c3 Compare September 7, 2024 20:10
@blabber
Copy link
Collaborator Author

blabber commented Sep 7, 2024

@jwrober, I updated this PR with a version I used to play LT85 until now. This change does not destroy reports/views when the player switches to the map and thus retains their state.

@jwrober jwrober marked this pull request as ready for review September 7, 2024 20:18
@jwrober
Copy link
Collaborator

jwrober commented Sep 7, 2024

Looks like it needs a clang-format or a rebase

This reverts commit f985113.

Calling the `popdown*' functions causes the destructors of the views
to be called. As a result, the views lose their state.

Reverting this commit may use a little extra memory as the views are
kept in memory, but seems to have no other negative impact and
restores the behaviour known from 3.0.

Closes longturn#2329
@blabber blabber force-pushed the bugfix/science_report_scroll_position branch from 3bc16c3 to 24e44b9 Compare September 7, 2024 20:27
@jwrober jwrober enabled auto-merge (rebase) September 7, 2024 20:39
@blabber
Copy link
Collaborator Author

blabber commented Sep 7, 2024

  • The city list is magically not reset

This is because popdown_city_report wasn't called in top_bar_show_map.

@jwrober jwrober merged commit cac4093 into longturn:master Sep 7, 2024
20 checks passed
@blabber blabber deleted the bugfix/science_report_scroll_position branch September 7, 2024 20:55
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.

Research view loses scroll position
3 participants