Scroll-pane

Post Reply
User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1524
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Scroll-pane

Post by binbinhfr »

Hi,

this new scroll-pane GUIelement is great ! No need to implement pages on lists anymore.

But would it be possible to read/write the vertical (and horizontal) position of the pane ?
Maybe like GUIelement.set_pane(vertical,horizontal) when vertical,horizontal are in [0,1] range ?

Because sometimes, when the user click something in the GUI, I want to show him a specific item of a big list which is in a scroll-pane.

Or sometimes, if you have to refresh/rebuild the inside of the scroll-pane, you want to reposition it at the same place than before, so that the user does not see the difference, otherwise the scrool-pane always come back to its 0 position...
My mods on the Factorio Mod Portal :geek:

User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1524
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Re: Scroll-pane

Post by binbinhfr »

I reup this thread.
I use these new scroll pane that are very handy, but I often need to read or write their position, when I need to recrate the list and position it at the same position than before. Or if I want to show the end of the list just after creating it.
My mods on the Factorio Mod Portal :geek:

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: Scroll-pane

Post by Mooncat »

Scroll-pane!? It seems that something is missing on the API document. :geek:
I wonder if it can be used as a simple scrollbar when its position supports read/write (e.g. for the color picker :lol: )

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Scroll-pane

Post by aubergine18 »

I thought scrolling was done now using a frame with the scroll policy set as applicable?

Being able to read/write the scroll position on anything that scrolls is pretty vital requirement tho...
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13202
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Scroll-pane

Post by Rseding91 »

The issue is the scroll position isn't saved anywhere and isn't part of the game state so there's no easy way to give read access to it that wouldn't cause desyncs.

I could probably add a method that does something like: "scroll_into_view(GUI element)" where it would scroll that specific item into view. Would that work?
If you want to get ahold of me I'm almost always on Discord.

User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1524
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Re: Scroll-pane

Post by binbinhfr »

Rseding91 wrote:I could probably add a method that does something like: "scroll_into_view(GUI element)" where it would scroll that specific item into view. Would that work?
Yes. I could handle what I need with this feature.
My mods on the Factorio Mod Portal :geek:

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Scroll-pane

Post by aubergine18 »

an scrollingElement.is_in_view(guiElement) would also be useful - eg. to avoid doing updates on elements that aren't in view.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13202
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Scroll-pane

Post by Rseding91 »

aubergine18 wrote:an scrollingElement.is_in_view(guiElement) would also be useful - eg. to avoid doing updates on elements that aren't in view.
Again that has the same problem: widget positions aren't saved in the game file so it would lead to desyncs if that information was used incorrectly (which it almost always would be).
If you want to get ahold of me I'm almost always on Discord.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Scroll-pane

Post by aubergine18 »

Posting in correct topic this time:

Out of curiosity, why does the GUI get included in MP game state? Surely it's the actions that arise from the GUI (such as updating an element or item on the map, etc) that matter and not the front-end UI the user used to trigger those actions?
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
binbinhfr
Smart Inserter
Smart Inserter
Posts: 1524
Joined: Sat Feb 27, 2016 7:37 pm
Contact:

Re: Scroll-pane

Post by binbinhfr »

As far as I understood, game desync is detected by comparing clients memory in a brute way.
And only user's control inputs (mouse clicks, keys) are transmitted to other clients.
Mod actions modifying GUI inplace of the user would not be transmitted to other clients, leading to desync.
My mods on the Factorio Mod Portal :geek:

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: Scroll-pane

Post by Mooncat »

Rseding91 wrote:
aubergine18 wrote:an scrollingElement.is_in_view(guiElement) would also be useful - eg. to avoid doing updates on elements that aren't in view.
Again that has the same problem: widget positions aren't saved in the game file so it would lead to desyncs if that information was used incorrectly (which it almost always would be).
What about an on_gui_scrolled event? :mrgreen:
I guess you know the scrollbar position when the player scrolled it? But don't know whether this will affect game performance.

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2633
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Scroll-pane

Post by steinio »

more likly a on_scrollbar_released(LuaGuiItem, position) event.
Image

Transport Belt Repair Man

View unread Posts

Zeblote
Filter Inserter
Filter Inserter
Posts: 973
Joined: Fri Oct 31, 2014 11:55 am
Contact:

Re: Scroll-pane

Post by Zeblote »

aubergine18 wrote:Posting in correct topic this time:

Out of curiosity, why does the GUI get included in MP game state? Surely it's the actions that arise from the GUI (such as updating an element or item on the map, etc) that matter and not the front-end UI the user used to trigger those actions?
They're thinking modders would be too stupid to use client sided gui + custom synchronization correctly, and force everyone on a more restrictive system so it can't be done wrong.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: Scroll-pane

Post by Mooncat »

steinio wrote:more likly a on_scrollbar_released(LuaGuiItem, position) event.
If you look into the RGB value bars for changing locomotive color, the scrollbars can update the textfields whenever they are scrolled and before they are released.
But this can be the solution if the on scrolled event is causing trouble on game performance. :P

Boodals
Fast Inserter
Fast Inserter
Posts: 129
Joined: Sun Feb 11, 2018 7:10 pm
Contact:

Re: Scroll-pane

Post by Boodals »

I have implemented this for 0.17.19 (I have source access).
Includes: scoll_to_left, scroll_to_right, scroll_to_top, scroll_to_bottom, and scroll_to_element, and works for both scroll-panes and text-boxes.
If you think a scroll_to(x, y) would be useful, please make a new request topic for it.

Post Reply

Return to “Implemented mod requests”