Page 1 of 1

Adjustable GUI element margins

Posted: Thu Nov 09, 2017 7:18 pm
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.

Re: Adjustable GUI element margins

Posted: Thu Nov 09, 2017 7:30 pm
by Rseding91
The GUI has no concept of margins so it's not possible to do what you're asking :)

Re: Adjustable GUI element margins

Posted: Thu Nov 09, 2017 9:03 pm
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)?

Re: Adjustable GUI element margins

Posted: Thu Nov 09, 2017 9:33 pm
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

Re: Adjustable GUI element margins

Posted: Sat Nov 11, 2017 7:29 pm
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.