Shifting LuaGuiElements

Place to get help with not working mods / modding interface.
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Shifting LuaGuiElements

Post by eduran »

I am trying to place multiple UI elements within a flow. A label, textfield, check-box and sprite button. The situation looks like this:
alignment.JPG
alignment.JPG (18.89 KiB) Viewed 1196 times
The "refresh" button is supposed to be on the right side. Changing .style.align of the outer flow moves all elements to the right. Since there is no spacing parameter, do I have to add an invisible item between checkbox and button, or is there a better way?
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5412
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Shifting LuaGuiElements

Post by Klonan »

eduran wrote: Fri Feb 01, 2019 1:40 pm I am trying to place multiple UI elements within a flow. A label, textfield, check-box and sprite button. The situation looks like this:
alignment.JPG
The "refresh" button is supposed to be on the right side. Changing .style.align of the outer flow moves all elements to the right. Since there is no spacing parameter, do I have to add an invisible item between checkbox and button, or is there a better way?
The way we do it, even internally, is to add a horizontal flow between the widgets and set `flow.style.horizontally_stretchable = true`
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: Shifting LuaGuiElements

Post by eduran »

Thank you for the quick reply. A follow-up question: Is it possible to place an element next to a frame title, e.g. in the top right corner of the following image:
frame.JPG
frame.JPG (14.71 KiB) Viewed 1188 times
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5412
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Shifting LuaGuiElements

Post by Klonan »

eduran wrote: Fri Feb 01, 2019 2:33 pm Thank you for the quick reply. A follow-up question: Is it possible to place an element next to a frame title, e.g. in the top right corner of the following image:

frame.JPG
No, frames are hardcoded in that way...
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 326
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Shifting LuaGuiElements

Post by Therenas »

I assume you want to put an exit-button in the top right corner. Well you can get around the frame issue, by simply not settings a title, and doing it yourself, like this:

Code: Select all

local main_dialog = player.gui.center.add{type="frame", name="main_dialog", direction="vertical"}
local titlebar = main_dialog.add{type="flow", name="flow_titlebar", direction="horizontal"}

titlebar.add{type="label", name="label_titlebar_name", caption="Title"}

titlebar.add{type="flow", name="flow_titlebar_spacing", direction="horizontal"}
titlebar["flow_titlebar_spacing"].style.horizontally_stretchable = true

titlebar.add{type="button", name="button_titlebar_exit", caption="X"}
... adding styling and such, of course.
Post Reply

Return to “Modding help”