LuaStyle .width[RW] | .height [RW] | .column_alignments

Things that already exist in the current mod API
Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

LuaStyle .width[RW] | .height [RW] | .column_alignments

Post by Angamara »

Hello

In LuaStyle, it is possible to define the maximum and minimum height or width.
But there is no way to set or get the value of height or width.

Would it be possible to add .width [RW] and .height [RW] in LuaStyle ?

For example, currently the only way to set a fixed height is to put
maximum_height and minimum_height at the same value.



in the same way, If two columns of a table have different heights, the alignment of the smaller column will be centered in height

.column_alignments is read-only. Is it normal behavior? And reading does not seem to work.
If the method was in [RW] this would fix a lot of positional problem.

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

Re: LuaStyle .width[RW] | .height [RW] | .column_alignments

Post by Rseding91 »

Angamara wrote:Would it be possible to add .width [RW] and .height [RW] in LuaStyle ?
No, that's not a supported property - styles only define min and max values. Additionally the current width/height of a GUI element isn't part of the game state and as such isn't MP/replay safe so mods aren't allowed to read it from LuaGuiElements.
Angamara wrote:.column_alignments is read-only. Is it normal behavior? And reading does not seem to work.
If the method was in [RW] this would fix a lot of positional problem.
It is read/write. It's a LuaObject just like LuaStyle. You can't directly assign a value to it just like you can't do "game.player = ..." but you can do: "game.player.position = ..."

You read it, then modify things on it.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5246
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: LuaStyle .width[RW] | .height [RW] | .column_alignments

Post by Klonan »

Angamara wrote:column_alignments is read-only. Is it normal behavior? And reading does not seem to work.
If the method was in [RW] this would fix a lot of positional problem.
It works like this:

Code: Select all

local widget = gui.add{type = "table", colspan = 2}
widget.style.column_alignments[1] = "left"
widget.style.column_alignments[2] = "right"

Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

Re: LuaStyle .width[RW] | .height [RW] | .column_alignments

Post by Angamara »

Rseding91 wrote:
Angamara wrote:Would it be possible to add .width [RW] and .height [RW] in LuaStyle ?
No, that's not a supported property - styles only define min and max values. Additionally the current width/height of a GUI element isn't part of the game state and as such isn't MP/replay safe so mods aren't allowed to read it from LuaGuiElements.

I do not understand how this property does not support. It is clearly supported.

If I want to give a fixed width to a table. I just need to do
.table.style.minimal_width = 245
.table.style.maximal_width = 245

I do not see what prevents from having this shorter version

.table.style.width = 245
Rseding91 wrote:
Angamara wrote:.column_alignments is read-only. Is it normal behavior? And reading does not seem to work.
If the method was in [RW] this would fix a lot of positional problem.
It is read/write. It's a LuaObject just like LuaStyle. You can't directly assign a value to it just like you can't do "game.player = ..." but you can do: "game.player.position = ..."

You read it, then modify things on it.
Thanks you, I did not understand its use, now yes

If I said that it was read-only it's because it's written like that in the documentation.

Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

Re: LuaStyle .width[RW] | .height [RW] | .column_alignments

Post by Angamara »

Klonan wrote: It works like this:

Code: Select all

local widget = gui.add{type = "table", colspan = 2}
widget.style.column_alignments[1] = "left"
widget.style.column_alignments[2] = "right"
After this :

Code: Select all

gui.add{type = "table", name = "table", colspan = 2}
gui.table.add{type = "table", name = "row_1", colspan = 1}
gui.table.add{type = "table", name = "row_2", colspan = 1}
I Try this

Code: Select all

gui.table.style.column_alignments[1] = "top-left"
gui.table.style.column_alignments[2]  = "top-left"
gui.table.style.column_alignments.row_1 = "top-left"
gui.table.style.column_alignments.row_2= "top-left"
Nothing changes, the smaller column is not aligned at the top.
I thought I understood with the examples but apparently no. What's wrong with my code?

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5246
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: LuaStyle .width[RW] | .height [RW] | .column_alignments

Post by Klonan »

Angamara wrote:
Klonan wrote: It works like this:

Code: Select all

local widget = gui.add{type = "table", colspan = 2}
widget.style.column_alignments[1] = "left"
widget.style.column_alignments[2] = "right"
After this :

Code: Select all

gui.add{type = "table", name = "table", colspan = 2}
gui.table.add{type = "table", name = "row_1", colspan = 1}
gui.table.add{type = "table", name = "row_2", colspan = 1}
I Try this

Code: Select all

gui.table.style.column_alignments[1] = "top-left"
gui.table.style.column_alignments[2]  = "top-left"
gui.table.style.column_alignments.row_1 = "top-left"
gui.table.style.column_alignments.row_2= "top-left"
Nothing changes, the smaller column is not aligned at the top.
I thought I understood with the examples but apparently no. What's wrong with my code?
It doesn't work like that, you can only set column alignments, not any alignment or rows

The only usage is the way my example showed

Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

Re: LuaStyle .width[RW] | .height [RW] | .column_alignments

Post by Angamara »

Klonan wrote: It doesn't work like that, you can only set column alignments, not any alignment or rows

The only usage is the way my example showed
I use the word "row" to name the table, it may be a bad word choice but it does not change your example. I would call them "frog" or "carrot".
Your example is identical to mine.


Far from the idea of insisting, but are we talking about the same thing?

I want to manage the height alignment as specified in the definition of "Alignment" in the documentation
Concepts.html#Alignment wrote: Alignment

A string that specifies where a gui element should be.

Possible values are:

"top-left"
"middle-left" or just "left"
"bottom-left"
"top-center"
"middle-center" or just "center"
"bottom-center"
"top-right"
"middle-right" or just "right"
"bottom-right"
here is an image for what I want to do.

Image

*row1 and row2 are table

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5246
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: LuaStyle .width[RW] | .height [RW] | .column_alignments

Post by Klonan »

Angamara wrote:
Klonan wrote: It doesn't work like that, you can only set column alignments, not any alignment or rows

The only usage is the way my example showed
I use the word "row" to name the table, it may be a bad word choice but it does not change your example. I would call them "frog" or "carrot".
Your example is identical to mine.


Far from the idea of insisting, but are we talking about the same thing?

I want to manage the height alignment as specified in the definition of "Alignment" in the documentation
Concepts.html#Alignment wrote: Alignment

A string that specifies where a gui element should be.

Possible values are:

"top-left"
"middle-left" or just "left"
"bottom-left"
"top-center"
"middle-center" or just "center"
"bottom-center"
"top-right"
"middle-right" or just "right"
"bottom-right"
here is an image for what I want to do.

Image

*row1 and row2 are table
Align top and bottom just doesn't work for tables at this time,
The only align that works is left/right/center

The alignment is for the entire column in the table, and are indexed only by numbers

Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

Re: LuaStyle .width[RW] | .height [RW] | .column_alignments

Post by Angamara »

Klonan wrote:Align top and bottom just doesn't work for tables at this time,
The only align that works is left/right/center

The alignment is for the entire column in the table, and are indexed only by numbers

Ok I understand better as well. The documentation is just incomplete.

I guess an improvement of the GUI system is already planned for 0.16

And so it is not necessary to ask for this fix?

Angamara
Inserter
Inserter
Posts: 39
Joined: Mon Oct 30, 2017 3:52 pm
Contact:

Re: LuaStyle .width[RW] | .height [RW] | .column_alignments

Post by Angamara »

relevant to : viewtopic.php?f=28&t=47087&p=317931#p317926

Thank you posila for this additional information. but it's still fuzzy about using column_alignments.
Same with Klonan's examples. I do not see what is aligned.

posila what do you mean when you say that column_alignments returns a table in writing?
column_alignments [1] Do they match column 1, column_alignments [2] in column 2, and so on?

What is the effect of "right" for example with column_alignments [2] = "right"?
What can be the elements on which column_alignments to an impact?

Is it possible to have a complete example with a container that has visible aligned elements. ?

Post Reply

Return to “Already exists”