Page 1 of 1

Scroll-pane scroll-bar graphical_set access.

Posted: Tue Feb 13, 2018 8:57 am
by eradicator
I'm currently working on a themed mod gui and it looks like the scroll-panes scroll-bar looks can not be changed? At least none of the base games scroll_pane_style prototypes have a (default_)graphical_set and assigning one to a custom style doesn't have any effect.
scrollbar.png
scrollbar.png (186.01 KiB) Viewed 2564 times

Re: Scroll-pane scroll-bar graphical_set access.

Posted: Tue Feb 13, 2018 9:25 am
by bobingabout
Hey, I like the progress so far.
Shame we can't actually have more than just the default theme applied.

Re: Scroll-pane scroll-bar graphical_set access.

Posted: Thu Feb 15, 2018 4:16 am
by Rseding91
Scroll bars use "thumb_button_style", "top_button_style" and "bottom_button_style" which are internally button styles.

You should be able to set those on the default scroll bar style.

Re: Scroll-pane scroll-bar graphical_set access.

Posted: Thu Feb 15, 2018 10:06 am
by eradicator
Hm, interesting. I can see there are type="horizontal/vertical_scrollbar_style" styles in the default gui that have the button styles you mentioned. But how do i get a reference to the scroll-bar gui element? .add{type='scroll-pane'} only returns a reference to the scroll-pane which doesn't accept scroll_bar_style and doesn't have any children. Perhaps .add should return should return the bar as a second return value?
local pane,bar = gui.add{type="scroll-pane"}
Unless i'm missing something else.

Thanks for the help btw ;)

Re: Scroll-pane scroll-bar graphical_set access.

Posted: Thu Feb 15, 2018 10:17 am
by Rseding91
eradicator wrote:Hm, interesting. I can see there are type="horizontal/vertical_scrollbar_style" styles in the default gui that have the button styles you mentioned. But how do i get a reference to the scroll-bar gui element? .add{type='scroll-pane'} only returns a reference to the scroll-pane which doesn't accept scroll_bar_style and doesn't have any children. Perhaps .add should return should return the bar as a second return value?
local pane,bar = gui.add{type="scroll-pane"}
Unless i'm missing something else.

Thanks for the help btw ;)
You don't, you'd set the style on the parent GUI element that owns the scroll bars. That is, if it's exposed (I think it is but haven't checked).

Re: Scroll-pane scroll-bar graphical_set access.

Posted: Thu Feb 15, 2018 12:25 pm
by eradicator
I already tried that before and couldn't find it. Tested a brute force approach now and still can't find it:

Code: Select all

  local function force_style(element)
    element.style = 'vertical_scrollbar'
    end
  
  local function for_all_children(element)
    local err,stat = pcall(force_style, element)
    print(err)
    
    for _,child in pairs(element.children) do
      for_all_children(child)
      end
    
    end
  
  for_all_children(p.gui.center) 
According to pcall all attempts to set the style fail (and in the process makes the scroll bar vanish completely :P).

Edit:
(Hrng, pressed submit too early:P)
The code to create the scroll-pane is something like:

Code: Select all

local center = player.gui.center
local flow = center.add{type='flow'}
local frame = flow.add{type='frame'}
local pane = frame.add{type='scroll-pane'}

Re: Scroll-pane scroll-bar graphical_set access.

Posted: Thu Feb 15, 2018 12:34 pm
by Rseding91
I guess it isn't setup then. I'll see about getting support added for it.

Re: Scroll-pane scroll-bar graphical_set access.

Posted: Thu Feb 15, 2018 12:35 pm
by eradicator
Yay. Thanks =)