britzl / gooey

Defold GUI system
MIT License
150 stars 22 forks source link

Dynamic lists shows odd behaviour when screen have been resized #39

Closed Jerakin closed 2 years ago

Jerakin commented 5 years ago

The bottom of the scroll list looks like this when not resizing Screen Shot 2019-05-15 at 11 36 30

But if I resize the screen with defos.set_window_size(0, 0, 570, 1224) (from 720, 1280) it looks like this instead Screen Shot 2019-05-15 at 11 36 05

Quite a lot of padding is added and a extra item can be seen. The data is nil (but it get's set even though I check for nil before doing gui.set_text().

The stencil node have Adjustment Mode: Stretch and Y Anchor: Top

britzl commented 5 years ago

Can you share the project so that I can try?

Jerakin commented 5 years ago

Eh the project is a mess 😐 could be hard to find it there (inviting you anyway).

I think I found the source of the issue and managed to reproduce it: "Adjustment Mode: Stretch" on stencil nodes gives issues. I think it is possible to reproduce it in gooey example.

In the gui file \gooey\themes\kenneyblue\components\dynamiclist.gui

Set both bg and stencil to Adjust Mode: Stretch.

You only have to make the window narrower for it to pop up.

capture2 capture

britzl commented 5 years ago

Hmm, yeah, since that's a dynamic list it has a fixed amount of list items and they are created on startup. We need to find a way to detect that there's a need for more/less list items and recreate them.

Jerakin commented 5 years ago

What do you think would be the best way to do this? Adding a window listener?

britzl commented 5 years ago

Well, I think maybe Gooey should have a function that the application can call to set/update the current window width/height. And components can somehow read this value and decide on recreating/updating the view.

britzl commented 5 years ago

I've played around with a gooey.get/set_window_size() function that the components can use to detect a change and that all works well. The next problem in the case of a list if to calculate the new size of the stencil node so that it's possible to calculate the number of list item nodes to create.

Jerakin commented 5 years ago

The next problem in the case of a list if to calculate the new size of the stencil node so that it's possible to calculate the number of list item nodes to create.

Would be very handy to call this separately for when you use set_size on a list too.

britzl commented 2 years ago

I've decided that it becomes too messy to use stretch adjust mode on lists. It complicates things too much when it comes to visible list item calculations, max scroll amount etc.

I have added support for detecting when the stencil size has changed and will recreate the nodes in the list when this happens.