[kovarex] [1.1.5] switch type LuaGuiElement overwrites label style width

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

[kovarex] [1.1.5] switch type LuaGuiElement overwrites label style width

Post by eradicator »

What?

Creating a switch type gui element with labels overrides the width of the labels. No matter what i try it seems impossible to create a switch with fixed-width labels.

Explanation

After going through a small odyssey trying to create a column of aligned switches and writing down the lengthy lua-side reimplementation i came to the conclusion that that switch style label behavior makes no sense.

So i was trying to fix this horrible zig-zag:

Image

The only way i can think of to align the switches is to make the labels fixed width.
I tried overwriting the switches label style properties one-by-one, trying anything that seemed related to width.

Code: Select all

local styles = data.raw['gui-style'].default
styles.test_switch_style = util.table.deepcopy(styles.switch)

local il = styles.test_switch_style.inactive_label

local switch_label_width = 70

-- il. width                    = switch_label_width
il. horizontally_stretchable = 'off'
il. horizontally_squashable  = 'on'
-- il. size = {switch_label_width,24}
-- il. minimal_width = switch_label_width
il. maximal_width = switch_label_width
-- il. natural_width = switch_label_width
-- il. maximum_horizontal_squash_size = switch_label_width

But no matter what i try i can not make the labels wider, only smaller.

notstretched.png
notstretched.png (144.53 KiB) Viewed 1833 times
minimal_width.png
minimal_width.png (170.09 KiB) Viewed 1833 times
Attachments
zz-bugtest-switch-label_0.0.1.zip
(1.59 KiB) Downloaded 99 times
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.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [kovarex] [1.1.5] switch type LuaGuiElement overwrites label style width

Post by kovarex »

The problem is, that there is internal, custom, logic that changes the minimal width of the labels to fit the on/off variant, as they are different font witht different width, and the switch would move on toggle otherwise.
What I coudld change is, that it would respect the minimal width specified by the parent style when it is being auto-adjusted, so the value could be just enlraged, but not made smaller, which could solve your problem.
So I'm moving this to resolved for 1.1.8

P.S. I didn't test it, as the fix seemed obvious in the code, so let me know if it doesn't solve your problem.

Post Reply

Return to “Resolved Problems and Bugs”