gui_using_theme_editor.rst 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. .. _doc_gui_using_theme_editor:
  2. Using the theme editor
  3. ======================
  4. This article explains how to create and manage UI themes using the Godot
  5. editor and its theme editor tool. We recommend getting familiar with the
  6. basics behind GUI skinning/theming by reading :ref:`doc_gui_skinning` before starting.
  7. The theme editor is a bottom panel tool that activates automatically, when
  8. a :ref:`Theme <class_Theme>` resource is selected for editing. It contains
  9. the necessary UI for adding, removing, and adjusting theme types and theme
  10. items. It features a preview section for testing your changes live, as well
  11. as a window dialog for doing bulk operations of the theme items.
  12. Creating a theme
  13. ----------------
  14. Like any other resources, themes can be created directly in the file system dock
  15. by right-clicking and selecting **New Resource...**, then selecting **Theme**
  16. and clicking **Create**. This is especially useful for creating project-wide
  17. themes.
  18. Themes also can be created from any control node. Select a control node in the scene
  19. hierarchy, then in the inspector go to the ``theme`` property. From there you can
  20. select **New Theme**.
  21. .. figure:: img/new_theme.png
  22. :align: center
  23. This will create an empty theme and open up the theme editor. Keep in mind that
  24. resources created this way are bundled with the scene by default. Use the context
  25. menu to save the new theme to a file instead.
  26. While the theme editor provides the tools to manage theme types and items, themes also
  27. include the default, fallback font that you can edit only using the Inspector dock.
  28. Same applies to the contents of complex resource types, such as :ref:`StyleBoxes <class_StyleBox>`
  29. and icons — they open for editing in the Inspector.
  30. .. figure:: img/default_font.png
  31. :align: center
  32. Theme editor overview
  33. ---------------------
  34. .. figure:: img/theme_editor.png
  35. :align: center
  36. The theme editor has two main parts. The main theme editor, located at the bottom of
  37. the Godot editor, aims to provide users with tools to quickly create, edit, and delete
  38. theme items and types. It gives visual tools for picking and changing controls, abstracting
  39. the underlying theme concepts. The **Manage Theme Items** dialog, on the other hand,
  40. tries to address the needs of those who want to change themes manually. It's also
  41. useful for creating a new editor theme.
  42. Theme previews
  43. ~~~~~~~~~~~~~~
  44. The left-hand side of the main editor has a set of preview tabs. The **Default Preview**
  45. tab is visible out of the box and contains most of the frequently used controls in various
  46. states. Previews are interactive, so intermediate states (e.g. hover) can be previewed as well.
  47. .. figure:: img/default_preview.png
  48. :align: center
  49. Additional tabs can be created from arbitrary scenes in your project. The scene
  50. must have a control node as its root to function as a preview. To add a new tab
  51. click the **Add Preview** button and select the saved scene from your file system.
  52. .. figure:: img/scene_preview.png
  53. :align: center
  54. If you make changes to the scene, they will not be reflected in the preview
  55. automatically. To update the preview click the reload button on the toolbar.
  56. Previews can also be used to quickly select the theme type to edit. Select the
  57. picker tool from the toolbar and hover over the preview area to highlight control
  58. nodes. Highlighted control nodes display their class name, or type variation if available.
  59. Clicking on the highlighted control opens it for editing on the right-hand side.
  60. .. figure:: img/theme_preview_picker.png
  61. :align: center
  62. Theme types and items
  63. ~~~~~~~~~~~~~~~~~~~~~
  64. The right-hand side of the theme editor provides a list of theme types available
  65. in the edited theme resource, and the contents of the selected type. The list of
  66. type's items is divided into several tabs, corresponding to each data type available
  67. in the theme (colors, constants, styles, etc.). If the **Show Default** option is
  68. enabled, then for each built-in type its default theme values are displayed, greyed
  69. out. If the option is disabled, only the items available in the edited theme itself
  70. are displayed.
  71. .. figure:: img/theme_type_editor.png
  72. :align: center
  73. Individual items from the default theme can be added to the current theme by
  74. clicking on the **Override** button next to the item. You can also override all
  75. the default items of the selected theme type by clicking on the **Override All**
  76. button. Overridden properties can then be removed with the **Remove Item** button.
  77. Properties can also be renamed using the **Rename Item** button, and completely
  78. custom properties can be added to the list using the text field below it.
  79. Overridden theme items can be edited directly in the right-hand panel, unless they
  80. are resources. Resources have rudimentary controls available for them, but must be
  81. edited in the Inspector dock instead.
  82. .. figure:: img/theme_item_inspector.png
  83. :align: center
  84. Styleboxes have a unique feature available, where you can pin an individual
  85. stylebox from the list. Pinned stylebox acts like the leader of the pack, and
  86. all styleboxes of the same type are updated alongside it when you change its
  87. properties. This allows you to edit properties of several styleboxes at the
  88. same time.
  89. .. figure:: img/theme_pin_the_stylebox.png
  90. :align: center
  91. While theme types can be picked from a preview, they can also be added manually.
  92. Clicking the plus button next to the type list opens the **Add item Type** menu.
  93. In that menu you can either select a type from the list, or you can enter an
  94. arbitrary name to create a custom type. Text field also filters the list of control
  95. nodes.
  96. .. figure:: img/add_item_type.png
  97. :align: center
  98. Manage and import items
  99. -----------------------
  100. Clicking the **Manage Items** button brings up the **Manage Theme Items** dialog. In
  101. the **Edit Items** tab you can view and add theme types, as well as view and edit
  102. the theme items of the selected type.
  103. .. figure:: img/manage_items.png
  104. :align: center
  105. You can create, rename and remove individual theme items here by clicking the
  106. corresponding **Add X Item** and specifying their name. You can also mass delete
  107. theme items either by their data type (using the brush icon in the list) or by
  108. their quality. **Remove Class Items** will remove all built-in theme items you
  109. have customized for a control node type. **Remove Custom Items** will remove all
  110. the custom theme items for the selected type. Finally, **Remove All Items** will
  111. remove everything from the type.
  112. From the **Import Items** tab you can import theme items from other themes. You can
  113. import items from the default Godot theme, the Godot editor theme, or another custom
  114. theme. You can import individual or multiple items, and you can decide whether to
  115. copy or omit their data as well. There are several ways you can select and deselect the
  116. items, including by hand, by hierarchy, by data type, and everything. Opting to
  117. include the data will copy all theme items as they are to your theme. Omitting the data
  118. will create the items of the corresponding data type and name, but will leave them empty,
  119. creating a template of a theme in a way.
  120. .. figure:: img/import_items.png
  121. :align: center