0.2.0-dev Download ZIP
49 lines ·3.1 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="EditorResourceTooltipPlugin" inherits="RefCounted" api_type="editor" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | A plugin that advanced tooltip for its handled resource type. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | Resource tooltip plugins are used by [FileSystemDock] to generate customized tooltips for specific resources. E.g. tooltip for a [Texture2D] displays a bigger preview and the texture's dimensions. |
| 8 | A plugin must be first registered with [method FileSystemDock.add_resource_tooltip_plugin]. When the user hovers a resource in filesystem dock which is handled by the plugin, [method _make_tooltip_for_path] is called to create the tooltip. It works similarly to [method Control._make_custom_tooltip]. |
| 9 | </description> |
| 10 | <tutorials> |
| 11 | </tutorials> |
| 12 | <methods> |
| 13 | <method name="_handles" qualifiers="virtual const"> |
| 14 | <return type="bool" /> |
| 15 | <param index="0" name="type" type="String" /> |
| 16 | <description> |
| 17 | Return [code]true[/code] if the plugin is going to handle the given [Resource] [param type]. |
| 18 | </description> |
| 19 | </method> |
| 20 | <method name="_make_tooltip_for_path" qualifiers="virtual const"> |
| 21 | <return type="Control" /> |
| 22 | <param index="0" name="path" type="String" /> |
| 23 | <param index="1" name="metadata" type="Dictionary" /> |
| 24 | <param index="2" name="base" type="Control" /> |
| 25 | <description> |
| 26 | Create and return a tooltip that will be displayed when the user hovers a resource under the given [param path] in filesystem dock. |
| 27 | The [param metadata] dictionary is provided by preview generator (see [method EditorResourcePreviewGenerator._generate]). |
| 28 | [param base] is the base default tooltip, which is a [VBoxContainer] with a file name, type and size labels. If another plugin handled the same file type, [param base] will be output from the previous plugin. For best result, make sure the base tooltip is part of the returned [Control]. |
| 29 | [b]Note:[/b] It's unadvised to use [method ResourceLoader.load], especially with heavy resources like models or textures, because it will make the editor unresponsive when creating the tooltip. You can use [method request_thumbnail] if you want to display a preview in your tooltip. |
| 30 | [b]Note:[/b] If you decide to discard the [param base], make sure to call [method Node.queue_free], because it's not freed automatically. |
| 31 | [codeblock] |
| 32 | func _make_tooltip_for_path(path, metadata, base): |
| 33 | var t_rect = TextureRect.new() |
| 34 | request_thumbnail(path, t_rect) |
| 35 | base.add_child(t_rect) # The TextureRect will appear at the bottom of the tooltip. |
| 36 | return base |
| 37 | [/codeblock] |
| 38 | </description> |
| 39 | </method> |
| 40 | <method name="request_thumbnail" qualifiers="const"> |
| 41 | <return type="void" /> |
| 42 | <param index="0" name="path" type="String" /> |
| 43 | <param index="1" name="control" type="TextureRect" /> |
| 44 | <description> |
| 45 | Requests a thumbnail for the given [TextureRect]. The thumbnail is created asynchronously by [EditorResourcePreview] and automatically set when available. |
| 46 | </description> |
| 47 | </method> |
| 48 | </methods> |
| 49 | </class> |