Adjustable GUI element margins

Kovus
Inserter
Inserter
Posts: 23
Joined: Sat Feb 27, 2016 5:25 pm
Contact:

Adjustable GUI element margins

Post by Kovus »

I was hoping that at some point we might be able to adjust the margins of GUI elements. Right now, I see that we can adjust the padding for an element via its LuaStyle, but not the margin.

In the case of a button, adjusting the padding of the element changes the size between our button text/sprite and the edge of the button. Adjusting the margin would affect the space between the edge of the button and the surrounding elements.

In a brief discussion on discord, Aidiakapi chimed in with pointing out how the "box model" works in regards to margins of neighboring elements:
Aidiakapi wrote:In addition, in things like the box model, margins collapse (ie. top margin collapses with the bottom margin of the element above it, basically:

Code: Select all

effective_margin = max(top_element.bottom_margin, bottom_element.top_margin))
Box model is apparently the model used in web browsers. Though, this might be beyond the necessary scope of what anyone would need in Factorio GUI development.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14316
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Adjustable GUI element margins

Post by Rseding91 »

The GUI has no concept of margins so it's not possible to do what you're asking :)
If you want to get ahold of me I'm almost always on Discord.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Adjustable GUI element margins

Post by eradicator »

As i'm not too familiar with the terms here i googled for box model margin and found this picture:
https://www.w3.org/TR/CSS2/images/boxdim.png (hrng...how do i even include an external picture in a post >_>, anyway...)

So if i understand this correctly then can't the margin be created by using padding on the buttons parent element (e.g. an invisible flow whichs only purpose it to create the margin)?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Kovus
Inserter
Inserter
Posts: 23
Joined: Sat Feb 27, 2016 5:25 pm
Contact:

Re: Adjustable GUI element margins

Post by Kovus »

That would be a LOT of overhead.

It seems what I want ought to be possible via horizontal_spacing & vertical_spacing style modifications, but I don't seem to be able to set these on a flow, though they seem to be part of every flow's style. viewtopic.php?f=28&t=53907
Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

Re: Adjustable GUI element margins

Post by Angamara »

eradicator wrote:So if i understand this correctly then can't the margin be created by using padding on the buttons parent element (e.g. an invisible flow whichs only purpose it to create the margin)?

Personally I make my margin with tables, since the flow does not manage vertical and horizontal space.

But it is obvious that LuaElement and LuaStyle should be inspired by HTML.
Post Reply

Return to “Implemented mod requests”