From 7bdb5c41a897b44acaaf0309b6190deb3242f577 Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Mon, 3 Aug 2020 18:31:27 +0300 Subject: [PATCH 1/2] Improve Inspector plugin tutorial with a better example --- .../editor/img/inspector_plugin_example.png | Bin 0 -> 12747 bytes .../plugins/editor/inspector_plugins.rst | 163 ++++++++++++------ 2 files changed, 108 insertions(+), 55 deletions(-) create mode 100644 tutorials/plugins/editor/img/inspector_plugin_example.png diff --git a/tutorials/plugins/editor/img/inspector_plugin_example.png b/tutorials/plugins/editor/img/inspector_plugin_example.png new file mode 100644 index 0000000000000000000000000000000000000000..774302b99171a2bda7fdc120231b50b97d14610d GIT binary patch literal 12747 zcmaKT1yodV_w5*nG}4kH4H5#cb9ZGDh&eCAl)D!-Q5ii-6P$dL%tthz4yMi z-hZvThFPpTx6b*Uz0cm~2FuBap&=6@Lm&_|32_kx2;|Wz_@40m8TiDCCn5uX9yut8 z2|<1j6K_EvuOJd4ACz2^_ZD1S6*m^{k7|qtswoeerWZLlJPvS0pHn;$>eaDgo6Fl9 zF3uu(Yl9 zrLl&I=j7Ij8eTa=4t+J4=PTE6m2-KLhofwM7|lQd2Xp@Wll-C(0TJO`g+wTbR6$E& zwqT7CCWOkz*uu4N_f9E$P`U8E*)CzJcUkXUtyBox>=BRy5`_LkC;y@P_rR&OeaodC^CLHDMY zfK<%`sxn+U;k2s-*P4ef5=s^;-Ryb(rI zJQ^AiS}RmI?a#PTqlvd-bYxbbfc}0|8VkE6JNL_APRo*Czkas9_o0>{7+9j9o6_!{ znF+=nz++=&dR8$bBDqaheK0Texey5=C`hIPYfAp{*yRXJJl0;#f(_TMr92i&>cl$^M$461G z)kCL|P03i|5!Sj`@WA&)3@mklJt9^PA57&&6B9!exHsU1T>RFMkV_YYQIY24RK*rV z(@Yn&I1epc!r_NqlY99}^mxq4fmvA;Ndj|{ii&JDO(&5<$Df9VAeGhC)tVP&t1Crn z)d~5%wn&YoL{SGEQ3uWBE96bm1(tIG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sXviIMD_9H5m7X1?wKenv!JZ|}3#g`u!Ihujk|_c>X737#_;!h7`I$cO+4 z5fy6#DS#0{9t_@ZzK?skU79;aRDx1p!K93U0{=OZ zd0j3?A4?l6+1SKKH>Rw0Lb@Gx2FC9`Pw(u^o!gFE#4|NjV=j=x_xbugX-@1)* z>D-(Mnwy#Jo?bWZu7oAg(J@veswhvuM|MUVwvTs^p}2q*U%aR2`D4>QudY}eVJeg6 zR}z7rBmk57h~JK`mtUNfo&6n*0Ry>q=X9y#*~v+ofPY#EMh5wZhe@;OaCsda2`f$} zClF6CRm@`I$miWGkSx)Hbs0YE?BHMw#sNHQ?-T_VFS!BxXocJ}H8t;#;?)-x;-&n4 z47Sj&ZyYfe4cIC;cl$?GV`f+1+j94ygOt0pH727P`eB|&53SAI=kl8}6jjz-47aOsX9 z>N>(U2WhCmL{bq-_OhcZ^kYn1Y;f%IQ_9Uoljc9y87!BGqqQ+8t(WlCrYrBA8h(Ix<~`B=Rx90cgHJ*iDOzQ?Yko zw*9Mzb+RtKkvDSx+&3c*BncJ~wuG(ihK+AxYNUTsA%p3N2^coo%HOLnb(pTWfPkse zd9Nu}00OSSg#F(A%+s?`-RZ&}%(Mc4EUNe54iC4Q3pUSV139+5sLT)?j%;&1KWVcp z?M}^RD!o(cb86~ Date: Sat, 10 Oct 2020 13:06:57 -0600 Subject: [PATCH 2/2] Edit inspector_plugins.rst --- .../plugins/editor/inspector_plugins.rst | 135 +++++++++--------- 1 file changed, 70 insertions(+), 65 deletions(-) diff --git a/tutorials/plugins/editor/inspector_plugins.rst b/tutorials/plugins/editor/inspector_plugins.rst index aa9b82a0e..dace101ee 100644 --- a/tutorials/plugins/editor/inspector_plugins.rst +++ b/tutorials/plugins/editor/inspector_plugins.rst @@ -3,39 +3,43 @@ Inspector plugins ================= -The inspector dock supports custom plugins to create your own widgets for -editing properties. This can be beneficial when working with custom datatypes -and resources, but may be used to change the default behavior for built-in -types as well. It is possible to introduce custom controls for specific properties, -entire objects, and even detached controls associated with particular datatypes. +The inspector dock allows you to create custom widgets to edit properties +through plugins. This can be beneficial when working with custom datatypes and +resources, although you can use the feature to change the inspector widgets for +built-in types. You can design custom controls for specific properties, entire +objects, and even separate controls associated with particular datatypes. -This tutorial explains how to use the :ref:`class_EditorInspectorPlugin` -and :ref:`class_EditorProperty` classes to create a custom control for each -property of the integer type, replacing the default behavior with a button -that generates random values between numbers 0 and 99. +This guide explains how to use the :ref:`class_EditorInspectorPlugin` and +:ref:`class_EditorProperty` classes to create a custom interface for integers, +replacing the default behavior with a button that generates random values +between 0 and 99. .. figure:: img/inspector_plugin_example.png :align: center - The default behavior on the left, and the end result on the right. + The default behavior on the left and the end result on the right. -Setup ------ +Setting up your plugin +---------------------- -Follow the :ref:`doc_making_plugins` guide to setup the framework for your -new plugin. Lets assume you've called your plugin folder ``my_inspector_plugin``. -If so, you should end up with a new ``addons/my_inspector_plugin`` folder -that contains two files: ``plugin.cfg`` and ``plugin.gd``. +Create a new empty plugin to get started. + +.. seealso:: See :ref:`doc_making_plugins` guide to set up your new plugin. + +Let's assume you've called your plugin folder ``my_inspector_plugin``. If so, +you should end up with a new ``addons/my_inspector_plugin`` folder that contains +two files: ``plugin.cfg`` and ``plugin.gd``. As before, ``plugin.gd`` is a script extending :ref:`class_EditorPlugin` and you -need to introduce new code for its ``_enter_tree`` and ``_exit_tree`` methods. To -setup your inspector plugin you must load its script and then create and add -the instance using ``add_inspector_plugin``. If the plugin is disabled you should -remove the instance you have added using ``remove_inspector_plugin``. +need to introduce new code for its ``_enter_tree`` and ``_exit_tree`` methods. +To set up your inspector plugin, you must load its script, then create and add +the instance by calling ``add_inspector_plugin()``. If the plugin is disabled, +you should remove the instance you have added by calling +``remove_inspector_plugin()``. -.. note:: Take note, that here you are loading a script and not a packed scene. - Therefore you should use ``new()`` instead of ``instance()``. +.. note:: Here, you are loading a script and not a packed scene. Therefore you + should use ``new()`` instead of ``instance()``. .. tabs:: .. code-tab:: gdscript GDScript @@ -55,28 +59,30 @@ remove the instance you have added using ``remove_inspector_plugin``. remove_inspector_plugin(plugin) -EditorInspectorPlugin ---------------------- +Interacting with the inspector +------------------------------ -To be able to interact with the inspector dock, your ``MyInspectorPlugin.gd`` script -must extend the :ref:`class_EditorInspectorPlugin` class. This class provides -several virtual methods that can be implemented to affect the way the inspector -is handling properties. +To interact with the inspector dock, your ``MyInspectorPlugin.gd`` script must +extend the :ref:`class_EditorInspectorPlugin` class. This class provides several +virtual methods that affect how the inspector handles properties. -To have any effect at all the script must implement the ``can_handle()`` method. This -function is called for each edited :ref:`class_Object` and must return ``true`` if -this plugin should handle the object or its properties (including any :ref:`class_Resource` -that is embedded!). +To have any effect at all, the script must implement the ``can_handle()`` +method. This function is called for each edited :ref:`class_Object` and must +return ``true`` if this plugin should handle the object or its properties. -There are 4 other methods that can be implemented to add controls to the inspector at -specific positions. The ``parse_begin()`` and ``parse_end()`` functions are called only once -at the beginning and the end of parsing for each object, respectively. They can be used to -add controls at the very top or very bottom of the inspector layout with ``add_custom_control``. +.. note:: This includes any :ref:`class_Resource` attached to the object. -As the object is parsed the ``parse_category()`` and ``parse_property()`` functions are -called. In addition to ``add_custom_control`` both ``add_property_editor`` and -``add_property_editor_for_multiple_properties`` can be utilized. These methods are used -specifically to add :ref:`class_EditorProperty`-based controls. +You can implement four other methods to add controls to the inspector at +specific positions. The ``parse_begin()`` and ``parse_end()`` methods are called +only once at the beginning and the end of parsing for each object, respectively. +They can add controls at the top or bottom of the inspector layout by calling +``add_custom_control()``. + +As the editor parses the object, it calls the ``parse_category()`` and +``parse_property()`` methods. There, in addition to ``add_custom_control()``, +you can call both ``add_property_editor()`` and +``add_property_editor_for_multiple_properties()``. Use these last two methods to +specifically add :ref:`class_EditorProperty`-based controls. .. tabs:: .. code-tab:: gdscript GDScript @@ -88,44 +94,44 @@ specifically to add :ref:`class_EditorProperty`-based controls. func can_handle(object): - # We will support all objects in this example. + # We support all objects in this example. return true func parse_property(object, type, path, hint, hint_text, usage): - # We will handle properties of type integer. + # We handle properties of type integer. if type == TYPE_INT: # Create an instance of the custom property editor and register # it to a specific property path. add_property_editor(path, RandomIntEditor.new()) - # Inform the editor to remove the default property editor for + # Inform the editor to remove the default property editor for # this property type. return true else: return false +Adding an interface to edit properties +-------------------------------------- -EditorProperty --------------- +The :ref:`class_EditorProperty` class is a special type of :ref:`class_Control` +that can interact with the inspector dock's edited objects. It doesn't display +anything but can house any other control nodes, including complex scenes. -The :ref:`class_EditorProperty` class is a special type of :ref:`class_Control` that -can interact with edited objects inside of the inspector dock. By itself it doesn't -display anything, but can house any other control nodes, including complex -scenes. +There are three essential parts to the script extending +:ref:`class_EditorProperty`: -There are three essential parts to the script extending :ref:`class_EditorProperty`: +1. You must define the ``_init()`` method to set up the control nodes' + structure. -1. There must be the ``_init`` method that sets up the node structure of the control. +2. You should implement the ``update_property()`` to handle changes to the data + from the outside. -2. The ``update_property()`` method should be implemented to handle changes to the - data from the outside. +3. A signal must be emitted at some point to inform the inspector that the + control has changed the property using ``emit_changed``. -3. A signal must be emitted at some point to inform the inspector that the control has - changed the property using ``emit_changed``. - -You can display your custom widget in two ways. Use the default ``add_child`` method -to display it to the right of the property name, and ``set_bottom_editor`` to position -it below the name. +You can display your custom widget in two ways. Use the default ``add_child()`` +method to display it to the right of the property name, and +``set_bottom_editor()`` to position it below the name. .. tabs:: .. code-tab:: gdscript GDScript @@ -156,7 +162,7 @@ it below the name. # Ignore the signal if the property is currently being updated. if (updating): return - + # Generate a new random integer between 0 and 99. current_value = randi() % 100 property_control.text = "Value: " + str(current_value) @@ -168,14 +174,13 @@ it below the name. var new_value = get_edited_object()[get_edited_property()] if (new_value == current_value): return - + # Update the control with the new value. updating = true current_value = new_value property_control.text = "Value: " + str(current_value) updating = false - -Using the example code above you should be able to make a custom widget -that replaces the default :ref:`class_SpinBox` control for integers with -a :ref:`class_Button` that generates random values. +Using the example code above you should be able to make a custom widget that +replaces the default :ref:`class_SpinBox` control for integers with a +:ref:`class_Button` that generates random values.