Page 1 of 1

Gui element "scroll-pane" scroll-state read/write

Posted: Tue Oct 23, 2018 4:14 pm
by eradicator
What?
The ability to create a scroll-pane and set the initially visible portion of the pane to something other than the top.

Whaat?
When a scroll-pane is newly created the scroll pane will always show the upper left corner. I would like to be able to control which part of the scroll-pane is displayed by default without inhibiting the users ability to scroll up/down later.

Why?
When a user closes and reopens a scroll-panel (i.e. the panel is recreated) it is desireable for a mod to display the same section of the panel that was displayed when the panel was closed. This would also make it possible to have behavior like the # operator on web pages that allows a user to quickly jump to a subsection of e.g. a wikipedia article without having to create a seperate page for every subsection.

How?
Two [r/w] float values vertical_scroll_state and horizontal_scroll_state would suffice. These would give a percentage value of how far down the panel should be scrolled down. Additionaly an event on_scroll_state_changed would also be nice to ensure a mod always knows the last scroll state (as in certain circumstances there might be no event called before a gui element is destroyed, leaving no time to read the last state).

Usecases
  1. Jumping directly to a part of the scroll-pane.
  2. Adding hotkey navigation to a scroll-pane.

Re: Gui element "scroll-pane" scroll-state read/write

Posted: Thu Dec 03, 2020 12:16 pm
by Bilka
Hey, this was implemented at some point with https://lua-api.factorio.com/latest/Lua ... to_element and scroll_to_top/bottom/left/right.

Re: Gui element "scroll-pane" scroll-state read/write

Posted: Thu Dec 03, 2020 1:20 pm
by eradicator
Bilka wrote:
Thu Dec 03, 2020 12:16 pm
Hey, this was implemented at some point with https://lua-api.factorio.com/latest/Lua ... to_element and scroll_to_top/bottom/left/right.
I'm sorry, but i still don't see any way to read the current state of a scroll pane. There's only write methods. But without read it's impossible to restore the exact state of a gui element after it was closed/destroyed. Or adjust the scroll position when elements are added/removed from an open gui to prevent visual jitter, etc.

Re: Gui element "scroll-pane" scroll-state read/write

Posted: Thu Dec 03, 2020 1:24 pm
by Bilka
Oops, I missed the "read" when reading the title and assumed you'd know what element you want to jump to.

Re: Gui element "scroll-pane" scroll-state read/write

Posted: Thu Dec 03, 2020 5:56 pm
by Rseding91
Sorry, but this is in the same realm as 92021 and isn't likely to ever be implemented.

Re: Gui element "scroll-pane" scroll-state read/write

Posted: Thu Dec 03, 2020 10:52 pm
by eradicator
Rseding91 wrote:
Thu Dec 03, 2020 5:56 pm
Sorry, but this is in the same realm as 92021 and isn't likely to ever be implemented.
Welp. Not unexpected given the thread was more than 2 years old ;). At least now it's official.