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

sizeChanged not called before showing a Displayable #195

Open
vipaoL opened this issue Jul 19, 2023 · 1 comment
Open

sizeChanged not called before showing a Displayable #195

vipaoL opened this issue Jul 19, 2023 · 1 comment

Comments

@vipaoL
Copy link

vipaoL commented Jul 19, 2023

https://docs.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/javax/microedition/lcdui/Displayable.html#sizeChanged(int,%20int)
"This method is called at least once before the Displayable is shown for the first time."

@recompileorg
Copy link
Collaborator

Good catch. The notes below are for anyone who wants to tackle this.

sizeChanged also needs to be called on displayables if the size changes when the item is not visible, just before it becomes visible (deferred) and immediately if the item is visible when the size changes.

Covering Canvas, Screen, etc. shouldn't be too difficult. There are a few different ways this could be handled, though the simplest is probably just to track the last known size in each Displayable. For deferred calls, we can check that size against the current size and make the call (and update the size) when one of the Display.setCurrent methods is called. We can initially set the size to negative values to ensure that sizeChanged is called the first time a Displayable is shown. When the size changes, these should be updated in the current Displayable before calling sizeChanged so that it isn't unnecessarily called the next time it's shown.

Form complicates things as it contains other Displayables and changes to its internal size (like from adding a title) will affect its children. As sizeChanged is expected to be overwritten, we'll also need a helper method that we can call instead of sizeChanged added to Displayable to do whatever needs to be done internally, such as calling the sizeChanged helper on any child elements. All the Form stuff needs completely overhauled anyway as it was just minimally hacked together to allow a few games can start, so that part of it can probably wait.

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

No branches or pull requests

2 participants