Add editor contribution guides.

This commit is contained in:
Lukas Tenbrink
2025-07-30 15:47:37 +02:00
parent 7976f7812a
commit f9fb12572e
5 changed files with 288 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
.. _doc_editor_icons:
Editor icons
============
When a new class is created and exposed to scripting, the editor's interface
will display it with a default icon representing the base class it inherits
from. In most cases, it's still recommended to create icons for new classes to
improve the user experience.
Creating icons
~~~~~~~~~~~~~~
To create new icons, you first need a vector graphics editor installed.
For instance, you can use the open source `Inkscape <https://inkscape.org/>`_ editor.
Clone the ``godot`` repository containing all the editor icons:
.. code-block:: bash
git clone https://github.com/godotengine/godot.git
The icons must be created in a vector graphics editor in SVG format. There are
two main requirements to follow:
- Icons must be 16×16. In Inkscape, you can configure the document size in
**File > Document Properties**.
- Lines should be snapped to pixels whenever possible to remain crisp at lower DPI.
You can create a 16×16 grid in Inkscape to make this easier.
Once you're satisfied with the icon's design, save the icon in the cloned
repository's ``editor/icons`` folder. The icon name should match the intended
name in a case-sensitive manner. For example, to create an icon for
CPUParticles2D, name the file ``CPUParticles2D.svg``.
Color conversion for light editor themes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If the user has configured their editor to use a light theme, Godot will
convert the icon's colors based on a
`set of predefined color mappings <https://github.com/godotengine/godot/blob/master/editor/themes/editor_color_map.cpp>`__.
This is to ensure the icon always displays with a sufficient contrast rate.
Try to restrict your icon's color palette to colors found in the list above.
Otherwise, your icon may become difficult to read on a light background.
Icon optimization
~~~~~~~~~~~~~~~~~
Because the editor renders SVGs once at load time, they need to be small
in size so they can be efficiently parsed. When the
:ref:`pre-commit hook <doc_code_style_guidelines_pre_commit_hook>` runs, it automatically optimizes
the SVG using `svgo <https://github.com/svg/svgo>`_.
.. note::
While this optimization step won't impact the icon's quality noticeably, it
will still remove editor-only information such as guides. Therefore, it's
recommended to keep the source SVG around if you need to make further
changes.
Integrating and sharing the icons
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you're contributing to the engine itself, you should make a pull request to
add optimized icons to ``editor/icons`` in the main repository. Recompile the
engine to make it pick up new icons for classes.
It's also possible to create custom icons within a module. If you're creating
your own module and don't plan to integrate it with Godot, you don't need to
make a separate pull request for your icons to be available within the editor
as they can be self-contained.
For specific instructions on how to create module icons, refer to
:ref:`Creating custom module icons<doc_custom_module_icons>`.
Troubleshooting
~~~~~~~~~~~~~~~
If icons don't appear in the editor, make sure that:
1. Each icon's filename matches the naming requirement as described previously.
2. ``modules/svg`` is enabled (it should be enabled by default). Without it,
icons won't appear in the editor at all.
References
~~~~~~~~~~
- `editor/icons <https://github.com/godotengine/godot/tree/master/editor/icons>`__

View File

@@ -0,0 +1,98 @@
.. _doc_editor_style_guide:
Editor style guide
==================
Introduction
------------
Thanks for your interest in contributing to the Godot editor!
This page describes the grammar and writing style used throughout the Godot
editor. Following this style guide will help your contribution get merged faster
since there will be fewer review steps required.
Writing style
-------------
- **Write messages (errors, warnings, ...) as full sentences.** They should start
with an uppercase letter and end with a period.
- **Try to keep sentences short.** This makes it more likely that their translations
will be short as well, which is a good thing to avoid UI bugs.
- **Use contractions.** For example, use "isn't" instead of "is not". An exception
to this rule can be made when you specifically want to emphasize one of the
contraction's words.
- **Use double quotes in messages** (``""``) instead of single quotes (``''``).
Double quotes should be used to quote user input, file paths and possibly
other things depending on the context.
.. seealso::
Try to follow the :ref:`doc_docs_writing_guidelines` in addition to the
guidelines outlined above.
Button and menu texts
---------------------
Capitalize text in buttons and menu actions:
- **Good:** *Open Editor Data Folder*
- **Bad:** *Open editor data folder*
If a menu action opens a modal dialog, suffix it with an ellipsis (``...``).
- **Good:** *Editor Settings...*
- **Bad:** *Editor Settings*
Inspector sections
------------------
In general, don't create sections that contain less than 3 items. Sections that
contain few items make it difficult to navigate the inspector, while missing the
benefits of using sections such as folding.
There are some valid exceptions for this, such as material features in
:ref:`class_StandardMaterial3D`.
This advice also applies to the Project Settings and Editor Settings.
Inspector performance hints
---------------------------
Enum properties that noticeably impact performance should have a performance
hint associated. The hint should refer to the *absolute* performance impact,
rather than being relative to the other options provided in the enum. Here are
some examples taken from the Godot editor:
- **Screen-space antialiasing:** *Disabled (Fastest), FXAA (Fast)*
- **MSAA quality:** *Disabled (Fastest), 2x (Fast), 4x (Average), 8x (Slow), 16x
(Slower)*
- **DirectionalLight mode:** *Orthogonal (Fast), PSSM 2 Splits
(Average), PSSM 4 Splits (Slow)*
For consistency, try to stick to the terms below (from fastest to slowest):
- *Fastest, Faster, Fast, Average, Slow, Slower, Slowest*
Their usage doesn't have to be contiguous. For example, you can use only "Fast"
and "Slow" from the list above.
If you're adding a new enum, its values should be ordered from the fastest
option to the slowest option.
Tooltips
--------
Consider adding tooltips whenever the action performed by a button or menu
action isn't obvious. You can also provide additional context or highlight
caveats in the tooltip.
You can do this by calling ``set_tooltip(TTR("Text here."))`` on the
Control-based node in question. If the tooltip is particularly long (more than
~80 characters), wrap it over several lines by adding line breaks using ``\n``.
Tooltips should follow the writing style described above. In addition to this,
use indicative mood instead of imperative mood:
- **Good:** *Computes global illumination for the selected GIProbe.*
- **Bad:** *Compute global illumination for the selected GIProbe.*

12
engine/editor/index.rst Normal file
View File

@@ -0,0 +1,12 @@
:allow_comments: False
Contributing to the editor
==========================
.. toctree::
:maxdepth: 1
:name: toc-devel-editor
introduction_to_editor_development
creating_icons
editor_style_guide

View File

@@ -0,0 +1,88 @@
.. _doc_introduction_to_editor_development:
Introduction to editor development
==================================
On this page, you will learn:
- The **design decisions** behind the Godot editor.
- How to work efficiently on the Godot editor's C++ code.
This guide is aimed at current or future engine contributors.
To create editor plugins in GDScript, see :ref:`doc_making_plugins` instead.
.. seealso::
If you are new to Godot, we recommended you to read
:ref:`doc_godot_design_philosophy` before continuing. Since the Godot editor
is a Godot project written in C++, much of the engine's philosophy applies
to the editor.
Technical choices
-----------------
The Godot editor is drawn using Godot's renderer and
:ref:`UI system <doc_user_interface>`. It does *not* rely on a toolkit
such as GTK or Qt. This is similar in spirit to software like Blender.
While using toolkits makes it easier to achieve a "native" appearance, they are
also quite heavy and their licensing is not compatible with Godot's.
The editor is fully written in C++. It can't contain any GDScript or C# code.
Directory structure
-------------------
The editor's code is fully self-contained in the
`editor/ <https://github.com/godotengine/godot/tree/master/editor>`__ folder
of the Godot source repository.
Some editor functionality is also implemented via
:ref:`modules <doc_custom_modules_in_cpp>`. Some of these are only enabled in
editor builds to decrease the binary size of export templates. See the
`modules/ <https://github.com/godotengine/godot/tree/master/modules>`__ folder
in the Godot source repository.
Some important files in the editor are:
- `editor/editor_node.cpp <https://github.com/godotengine/godot/blob/master/editor/editor_node.cpp>`__:
Main editor initialization file. Effectively the "main scene" of the editor.
- `editor/project_manager.cpp <https://github.com/godotengine/godot/blob/master/editor/project_manager.cpp>`__:
Main Project Manager initialization file. Effectively the "main scene" of the Project Manager.
- `editor/plugins/canvas_item_editor_plugin.cpp <https://github.com/godotengine/godot/blob/master/editor/plugins/canvas_item_editor_plugin.cpp>`__:
The 2D editor viewport and related functionality (toolbar at the top, editing modes, overlaid helpers/panels, …).
- `editor/plugins/node_3d_editor_plugin.cpp <https://github.com/godotengine/godot/blob/master/editor/plugins/node_3d_editor_plugin.cpp>`__:
The 3D editor viewport and related functionality (toolbar at the top, editing modes, overlaid panels, …).
- `editor/plugins/node_3d_editor_gizmos.cpp <https://github.com/godotengine/godot/blob/master/editor/plugins/node_3d_editor_gizmos.cpp>`__:
Where the 3D editor gizmos are defined and drawn.
This file doesn't have a 2D counterpart as 2D gizmos are drawn by the nodes themselves.
Editor dependencies in ``scene/`` files
---------------------------------------
When working on an editor feature, you may have to modify files in
Godot's GUI nodes, which you can find in the ``scene/`` folder.
One rule to keep in mind is that you must **not** introduce new dependencies to
``editor/`` includes in other folders such as ``scene/``. This applies even if
you use ``#ifdef TOOLS_ENABLED``.
To make the codebase easier to follow and more self-contained, the allowed
dependency order is:
- ``editor/`` -> ``scene/`` -> ``servers/`` -> ``core/``
This means that files in ``editor/`` can depend on includes from ``scene/``,
``servers/``, and ``core/``. But, for example, while ``scene/`` can depend on includes
from ``servers/`` and ``core/``, it cannot depend on includes from ``editor/``.
Currently, there are some dependencies to ``editor/`` includes in ``scene/``
files, but
`they are in the process of being removed <https://github.com/godotengine/godot/issues/53295>`__.
Development tips
----------------
To iterate quickly on the editor, we recommend to set up a test project and
:ref:`open it from the command line <doc_command_line_tutorial>` after compiling
the editor. This way, you don't have to go through the Project Manager every
time you start Godot.