Types/StyleSpecification: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(→‎Optional properties: parent is recommended to be set)
(Updated styling of prototype doc migration note)
 
(15 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<div class="stub"><p>'''The prototype docs have moved to a new website with an improved format.''' This documentation page can now be found here: [https://lua-api.factorio.com/latest/types/StyleSpecification.html https://lua-api.factorio.com/latest/types/StyleSpecification.html]
</p><p>This wiki page is no longer updated and '''will be removed at some point in the future''', so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback [https://forums.factorio.com/viewforum.php?f=233 on the forums].</p></div>
A [[types/table|table]], used as a value in [[Prototype/GuiStyle]], named by the key that is used there. Prototype/GuiStyle loads one of the extensions of this prototype, depending on the specified <code>type</code>.
A [[types/table|table]], used as a value in [[Prototype/GuiStyle]], named by the key that is used there. Prototype/GuiStyle loads one of the extensions of this prototype, depending on the specified <code>type</code>.


Line 22: Line 28:
* [[Types/ScrollPaneStyleSpecification]] '''scroll_pane_style'''
* [[Types/ScrollPaneStyleSpecification]] '''scroll_pane_style'''
* [[Types/SliderStyleSpecification]] '''slider_style'''
* [[Types/SliderStyleSpecification]] '''slider_style'''
** [[Types/DoubleSliderStyleSpecification]] '''double_slider_style'''
* [[Types/SpeechBubbleStyleSpecification]] '''speech_bubble_style'''
* [[Types/SpeechBubbleStyleSpecification]] '''speech_bubble_style'''
* [[Types/StyleWithClickableGraphicalSetSpecification]] <abstract>
* [[Types/StyleWithClickableGraphicalSetSpecification]] <abstract>
Line 47: Line 54:
'''Type''': [[Types/string|string]]
'''Type''': [[Types/string|string]]


Name of a Types/StyleSpecification. This style specification inherits all property values from the parent style specification.<br>
Name of a [[Types/StyleSpecification]]. This style specification inherits all property values from the parent style specification.<br>
It is recommended to always set the parent style to at least the basic vanilla style. If no parent is set, some style properties become mandatory and behavior may be unexpected, such as an element not showing up because its size defaults to 0.
Styles without a parent property default to the root style for their type. The exception to this are the root styles themselves, they cannot have a parent set. Due to this, for root styles some style properties are mandatory and behavior may be unexpected, such as an element not showing up because its size defaults to 0.


=== horizontal_align ===
=== horizontal_align ===
Line 63: Line 70:


Either "top", "center" or "bottom".
Either "top", "center" or "bottom".
=== ignored_by_search ===
'''Type''': [[Types/bool|bool]]
=== never_hide_by_search ===
'''Type''': [[Types/bool|bool]]


=== horizontally_stretchable ===
=== horizontally_stretchable ===
'''Type''': [[Types/string|string]]
'''Type''': [[Types/StretchRule|StretchRule]]


'''Default''': "auto"
'''Default''': "auto"
Either "off", "on" or "auto".


=== vertically_stretchable ===
=== vertically_stretchable ===
'''Type''': [[Types/string|string]]
'''Type''': [[Types/StretchRule|StretchRule]]


'''Default''': "auto"
'''Default''': "auto"
Either "off", "on" or "auto".


=== horizontally_squashable ===
=== horizontally_squashable ===
'''Type''': [[Types/string|string]]
'''Type''': [[Types/StretchRule|StretchRule]]


'''Default''': "auto"
'''Default''': "auto"
Either "off", "on" or "auto".


=== vertically_squashable ===
=== vertically_squashable ===
'''Type''': [[Types/string|string]]
'''Type''': [[Types/StretchRule|StretchRule]]


'''Default''': "auto"
'''Default''': "auto"


Either "off", "on" or "auto".
=== natural_size ===
'''Type''': [[Types/uint32|uint32]] or [[Types/table|table]] of [[Types/uint32|uint32]]
 
If this is an array, the first member of the array is <code>natural_width</code> and the second is <code>natural_height</code>. Otherwise the size is both <code>natural_width</code> and <code>natural_height</code>.


=== size ===
=== size ===
Line 106: Line 116:


'''Default''': 0
'''Default''': 0
Minimal width ensures, that the widget will never be smaller than than that size. It can't be squashed to be smaller.


=== maximal_width ===
=== maximal_width ===
Line 111: Line 123:


'''Default''': 0
'''Default''': 0
Maximal width ensures, that the widget will never be bigger than than that size. It can't be stretched to be bigger.


=== natural_width ===
=== natural_width ===
Line 116: Line 130:


'''Default''': 0
'''Default''': 0
Natural width specifies the width of the element tries to have, but it can still be squashed/stretched to have a smaller or bigger size.


=== height ===
=== height ===
Line 126: Line 142:


'''Default''': 0
'''Default''': 0
Minimal height ensures, that the widget will never be smaller than than that size. It can't be squashed to be smaller.


=== maximal_height ===
=== maximal_height ===
Line 131: Line 149:


'''Default''': 0
'''Default''': 0
Maximal height ensures, that the widget will never be bigger than than that size. It can't be stretched to be bigger.


=== natural_height ===
=== natural_height ===
Line 136: Line 156:


'''Default''': 0
'''Default''': 0
Natural height specifies the height of the element tries to have, but it can still be squashed/stretched to have a smaller or bigger size.


=== padding ===
=== padding ===
Line 189: Line 211:
=== effect ===
=== effect ===
'''Type''': [[Types/string|string]]
'''Type''': [[Types/string|string]]
Name of a custom GUI effect. Custom GUI effects are hardcoded in the game's C++ code. List of available effects: "compilatron-hologram"


=== effect_opacity ===
=== effect_opacity ===
Line 194: Line 218:


'''Default''': 1.0
'''Default''': 1.0
=== tooltip ===
'''Type''': [[Types/LocalisedString|LocalisedString]]
== Example ==
Example of adding a custom style via [[Prototype/GuiStyle]], in this case a [[Types/FrameStyleSpecification]]:
<syntaxhighlight lang="lua">data.raw["gui-style"]["default"]["custom_style_for_a_frame"] =
{
  type = "frame_style",
  parent = "frame",
  use_header_filler = false,
  drag_by_title = false
}</syntaxhighlight>

Latest revision as of 10:42, 21 September 2023

The prototype docs have moved to a new website with an improved format. This documentation page can now be found here: https://lua-api.factorio.com/latest/types/StyleSpecification.html

This wiki page is no longer updated and will be removed at some point in the future, so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback on the forums.


A table, used as a value in Prototype/GuiStyle, named by the key that is used there. Prototype/GuiStyle loads one of the extensions of this prototype, depending on the specified type.

Extensions

Mandatory properties

type

Type: string

The type of one of the above listed extensions, this style specification is then loaded as that extension.

Optional properties

parent

Type: string

Name of a Types/StyleSpecification. This style specification inherits all property values from the parent style specification.
Styles without a parent property default to the root style for their type. The exception to this are the root styles themselves, they cannot have a parent set. Due to this, for root styles some style properties are mandatory and behavior may be unexpected, such as an element not showing up because its size defaults to 0.

horizontal_align

Type: string

Default: "left"

Either "left", "center" or "right".

vertical_align

Type: string

Default: "top"

Either "top", "center" or "bottom".

ignored_by_search

Type: bool

never_hide_by_search

Type: bool

horizontally_stretchable

Type: StretchRule

Default: "auto"

vertically_stretchable

Type: StretchRule

Default: "auto"

horizontally_squashable

Type: StretchRule

Default: "auto"

vertically_squashable

Type: StretchRule

Default: "auto"

natural_size

Type: uint32 or table of uint32

If this is an array, the first member of the array is natural_width and the second is natural_height. Otherwise the size is both natural_width and natural_height.

size

Type: uint32 or table of uint32

If this is an array, the first member of the array is width and the second is height. Otherwise the size is both width and height.

width

Type: uint32

Sets minimal_width, maximal_width and natural_width.

minimal_width

Type: uint32

Default: 0

Minimal width ensures, that the widget will never be smaller than than that size. It can't be squashed to be smaller.

maximal_width

Type: uint32

Default: 0

Maximal width ensures, that the widget will never be bigger than than that size. It can't be stretched to be bigger.

natural_width

Type: uint32

Default: 0

Natural width specifies the width of the element tries to have, but it can still be squashed/stretched to have a smaller or bigger size.

height

Type: uint32

Sets minimal_height, maximal_height and natural_height.

minimal_height

Type: uint32

Default: 0

Minimal height ensures, that the widget will never be smaller than than that size. It can't be squashed to be smaller.

maximal_height

Type: uint32

Default: 0

Maximal height ensures, that the widget will never be bigger than than that size. It can't be stretched to be bigger.

natural_height

Type: uint32

Default: 0

Natural height specifies the height of the element tries to have, but it can still be squashed/stretched to have a smaller or bigger size.

padding

Type: int16

Sets top_padding, right_padding, bottom_padding and left_padding.

top_padding

Type: int16

Default: 0

right_padding

Type: int16

Default: 0

bottom_padding

Type: int16

Default: 0

left_padding

Type: int16

Default: 0

margin

Type: int16

Sets top_margin, right_margin, bottom_margin and left_margin.

top_margin

Type: int16

Default: 0

right_margin

Type: int16

Default: 0

bottom_margin

Type: int16

Default: 0

left_margin

Type: int16

Default: 0

effect

Type: string

Name of a custom GUI effect. Custom GUI effects are hardcoded in the game's C++ code. List of available effects: "compilatron-hologram"

effect_opacity

Type: float

Default: 1.0

tooltip

Type: LocalisedString

Example

Example of adding a custom style via Prototype/GuiStyle, in this case a Types/FrameStyleSpecification:

data.raw["gui-style"]["default"]["custom_style_for_a_frame"] =
{
  type = "frame_style",
  parent = "frame",
  use_header_filler = false,
  drag_by_title = false
}