User:Raiguard/Tutorial:Modding tutorial/GUI/Style guide: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (Bilka moved page Tutorial:Modding tutorial/GUI/Style guide to User:Raiguard/Tutorial:Modding tutorial/GUI/Style guide without leaving a redirect: WIP pages must be in your userspace)
m (Dialog row micro)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''THIS PAGE IS A WORK IN PROGRESS'''
This style guide is designed to give you an overview of the precepts and specific element styles used to create 0.18-esque GUIs. This guide is not to be taken as gospel - the contents are merely suggestions to help you improve your interfaces.
This style guide is designed to give you an overview of the precepts and specific element styles used to create 0.18-esque GUIs. This guide is not to be taken as gospel - the contents are merely suggestions to help you improve your interfaces.


Line 5: Line 8:
== Window ==
== Window ==


[[File:GUI tutorial window types.png|frame|Examples of standard vs. dialog windows.]]
[[File:GUI tutorial window types.png|Standard vs. dialog windows.]]
 
Windows are created using the default frame style. Because of this, you need not specify a style when creating the element.


Windows are created using <code>standalone_inner_frame_in_outer_frame</code>. For windows that contain multiple sub-windows (e.g. most windows that hold a character inventory) <code>outer_frame</code> is used as the outer frame and <code>inner_frame_in_outer_frame</code> is used for each internal window.
For windows that contain multiple sub-windows (e.g. most windows that hold a character inventory) <code>outer_frame</code> is used as the outer frame and <code>inner_frame_in_outer_frame</code> is used for each internal window.


Generally there are three kinds of windows:
Generally there are three kinds of windows:
Line 16: Line 21:
=== Titlebar ===
=== Titlebar ===


[[File:GUI tutorial dialog types.png|frame|Draggable vs. non-draggable windows.]]
[[File:GUI tutorial dialog types.png|Draggable vs. non-draggable windows.]]


Each non-compact window '''must''' have a titlebar. All titlebars include a '''title''', and for windows that are meant to be draggable, the titlebar includes a drag handle. '''Standard''' windows also include a close button. Other frame action buttons may be added to the left of the close button, but should be used sparingly.
Each non-compact window '''must''' have a titlebar. All titlebars include a '''title''', and for windows that are meant to be draggable, the titlebar includes a drag handle. '''Standard''' windows also include a close button. Other frame action buttons may be added to the left of the close button, but should be used sparingly.
Line 22: Line 27:
Titlebars are created using a simple '''horizontal flow''' with no special edits - the default style is perfect for this case.
Titlebars are created using a simple '''horizontal flow''' with no special edits - the default style is perfect for this case.


* The title text is a <code>label</code> using the <code>frame_title</code> style.
* The title text is a <code>label</code> using the <code>frame_title</code> style. Set <code>ignored_by_interaction</code> on this element, so the dragging functionality will work.
* The "drag handle" is an <code>empty-widget</code> element with the <code>draggable_space_header</code> style. You will need to apply <code>horizontally_stretchable</code> to the element's style, and set the <code>height</code> to <code>24</code>. If adding a close button or other frame action button, set the <code>right_margin</code> to <code>4</code>.
* The "drag handle" is an <code>empty-widget</code> element with the <code>draggable_space_header</code> style. You will need to apply <code>horizontally_stretchable</code> to the element's style, and set the <code>height</code> to <code>24</code>. If adding a close button or other frame action button, set the <code>right_margin</code> to <code>4</code>. This element also requires <code>ignored_by_interaction</code> to be true, so the dragging functionality will work.
* Close buttons, or any other frame action buttons you are adding, are created with <code>sprite-button</code> using the <code>frame_action_button</code> style. The default sprite should be colored (RGB) <code>227,227,227</code>, and the hovered and clicked sprites should be colored (RGB) <code>29,29,29</code>. Custom frame action sprites should be 26x26 with a 3px padding around the edges, making for a file size of 32x32. As of the time of writing, the base game does not use mipmaps for these icons, but it would probably be a good idea to add them to your own icons just in case.
* Close buttons, or any other frame action buttons you are adding, are created with <code>sprite-button</code> using the <code>frame_action_button</code> style. The default sprite should be colored (RGB) <code>227,227,227</code>, and the hovered and clicked sprites should be colored (RGB) <code>29,29,29</code>. Custom frame action sprites should be 26x26 with a 3px padding around the edges, making for a file size of 32x32. As of the time of writing, the base game does not use mipmaps for these icons, but it would probably be a good idea to add them to your own icons just in case.
* When creating draggable windows, <code>drag_target</code> should be set on the flow element that comprises the titlebar, not the "drag handle" itself.
* When creating draggable windows, <code>drag_target</code> should be set on the '''flow element''' that comprises the titlebar, not the "drag handle" itself.
* If your window is not in <code>screen</code> or is otherwise non-draggable, '''DO NOT''' add a drag handle. Instead, use an <code>empty-widget</code> with <code>horizontally_stretchable</code> enabled.
* If your window is not in <code>screen</code> or is otherwise non-draggable, '''DO NOT''' add a drag handle. Instead, use an <code>empty-widget</code> with <code>horizontally_stretchable</code> enabled.


=== Content frame ===
=== Content frame ===


Each non-compact window '''must''' have a "content frame" (the light grey pane seen in the above screenshots). This is where the meat of your interface will go.
[[File:GUI tutorial content frame with padding.png|An example of <code>inside_shallow_frame_with_padding</code>, demonstrating the built-in 12px padding.]]
 
Each non-compact window '''must''' have at least one "content frame" (the light grey pane seen in the above screenshots). This is where the meat of your interface will go.
 
Content frames are created using the <code>inside_shallow_frame_with_padding</code> style. This will give you 12px of padding in the frame. If you need to have zero padding (i.e. for adding a scroll pane or a toolbar), use <code>inside_shallow_frame</code> instead.
 
It is good practice to separate different "purposes" in a GUI with different content panes. For example, Recipe Book uses different content panes for search and information:
 
TODO add image
 
If you add multiple content panes, add them to a flow element with <code>horizontal_spacing</code> or <code>vertical_spacing</code> set to <code>12</code>.
 
=== Dialog Row ===
 
The dialog row is the row of buttons at the bottom of a dialog window. Generally, a window will have one or two of these, but more can be added if necessary.
 
The game uses a left-to-right methodology for its navigation. Therefore, the leftmost dialog button is the "back" or "cancel" action, while the rightmost is the "confirm" action. Because dialogs have an actual "confirm" action, changes to the content of the dialog should not be saved until the "confirm" button is clicked and the window closed.
 
TODO list styles


Content frames are created using the <code>inside_shallow_frame_with_padding</code> style. This will give you 12px of padding in the frame. If you need to have zero padding, use <code>inside_shallow_frame</code> instead.
== Toolbar ==


[[File:GUI tutorial content frame with padding.png|frame|An example of <code>inside_shallow_frame_with_padding</code>, demonstrating the built-in 12px padding.]]
Toolbars are a great place to keep a content pane's "title" as well as tools used in that pane. You can see two examples of toolbars in the Recipe Book screenshot above.


Toolbars are created using the <code>subheader_frame</code> style. There are a few locations where they are acceptable:


'''TO BE CONTINUED'''
* At the top of an <code>inside_shallow_frame</code> (no padding)
* At the top of an <code>inside_deep_frame</code> (usually above a tabbed pane)
* Below the tab row in a tabbed pane. In this case, use a custom style TODO SHOW STYLE

Latest revision as of 18:29, 14 July 2020

THIS PAGE IS A WORK IN PROGRESS


This style guide is designed to give you an overview of the precepts and specific element styles used to create 0.18-esque GUIs. This guide is not to be taken as gospel - the contents are merely suggestions to help you improve your interfaces.

This style guide assumes you know how to create GUIs, assign styles to elements, and edit styles. If you do not know these things, this guide won't be of much use to you.

Window

Standard vs. dialog windows.

Windows are created using the default frame style. Because of this, you need not specify a style when creating the element.

For windows that contain multiple sub-windows (e.g. most windows that hold a character inventory) outer_frame is used as the outer frame and inner_frame_in_outer_frame is used for each internal window.

Generally there are three kinds of windows:

  • Standard windows have a close button in the top-right corner, and are opened/closed manually either by clicking something or using a hotkey.
  • Dialog windows have a row of dialog buttons along the bottom, and do not have a close button. These are used when there is a clear hierarchy of actions - you go "back" to the previous action, or you "confirm" the current action. These windows must have a "Back" button in the bottom-left corner, and may have a "Confirm" button in the bottom-right corner. Other buttons on the bottom row are optional and should be used sparingly.
  • Compact windows have neither a titlebar nor a dialog row. These are usually mini-GUIs that are opened/closed automatically as a result of some user action. There are no set rules for these kinds of GUIs, it entirely depends on what they're used for.

Titlebar

Draggable vs. non-draggable windows.

Each non-compact window must have a titlebar. All titlebars include a title, and for windows that are meant to be draggable, the titlebar includes a drag handle. Standard windows also include a close button. Other frame action buttons may be added to the left of the close button, but should be used sparingly.

Titlebars are created using a simple horizontal flow with no special edits - the default style is perfect for this case.

  • The title text is a label using the frame_title style. Set ignored_by_interaction on this element, so the dragging functionality will work.
  • The "drag handle" is an empty-widget element with the draggable_space_header style. You will need to apply horizontally_stretchable to the element's style, and set the height to 24. If adding a close button or other frame action button, set the right_margin to 4. This element also requires ignored_by_interaction to be true, so the dragging functionality will work.
  • Close buttons, or any other frame action buttons you are adding, are created with sprite-button using the frame_action_button style. The default sprite should be colored (RGB) 227,227,227, and the hovered and clicked sprites should be colored (RGB) 29,29,29. Custom frame action sprites should be 26x26 with a 3px padding around the edges, making for a file size of 32x32. As of the time of writing, the base game does not use mipmaps for these icons, but it would probably be a good idea to add them to your own icons just in case.
  • When creating draggable windows, drag_target should be set on the flow element that comprises the titlebar, not the "drag handle" itself.
  • If your window is not in screen or is otherwise non-draggable, DO NOT add a drag handle. Instead, use an empty-widget with horizontally_stretchable enabled.

Content frame

An example of inside_shallow_frame_with_padding, demonstrating the built-in 12px padding.

Each non-compact window must have at least one "content frame" (the light grey pane seen in the above screenshots). This is where the meat of your interface will go.

Content frames are created using the inside_shallow_frame_with_padding style. This will give you 12px of padding in the frame. If you need to have zero padding (i.e. for adding a scroll pane or a toolbar), use inside_shallow_frame instead.

It is good practice to separate different "purposes" in a GUI with different content panes. For example, Recipe Book uses different content panes for search and information:

TODO add image

If you add multiple content panes, add them to a flow element with horizontal_spacing or vertical_spacing set to 12.

Dialog Row

The dialog row is the row of buttons at the bottom of a dialog window. Generally, a window will have one or two of these, but more can be added if necessary.

The game uses a left-to-right methodology for its navigation. Therefore, the leftmost dialog button is the "back" or "cancel" action, while the rightmost is the "confirm" action. Because dialogs have an actual "confirm" action, changes to the content of the dialog should not be saved until the "confirm" button is clicked and the window closed.

TODO list styles

Toolbar

Toolbars are a great place to keep a content pane's "title" as well as tools used in that pane. You can see two examples of toolbars in the Recipe Book screenshot above.

Toolbars are created using the subheader_frame style. There are a few locations where they are acceptable:

  • At the top of an inside_shallow_frame (no padding)
  • At the top of an inside_deep_frame (usually above a tabbed pane)
  • Below the tab row in a tabbed pane. In this case, use a custom style TODO SHOW STYLE