Open mnemoli opened 4 years ago
Is there any way to write tests for the logic of CanvasItem components? Seems difficult since the logic and rendering are combined, and the RenderingServer isn't available in unit tests. Don't feel comfortable moving to selection caching without unit tests, there's a lot of spaghetti in that class.
@mnemoli You'd need to create a test project that takes screenshots automatically when run, and compare the screenshots to check for differences across revisions.
See this plugin for an example of taking screenshots. It can be adapted to take screenshots in a programmatic manner as a project is running.
The current (godot 4.3 -dev5)tree multi-selection cannot determine whether the selection is completed.,Has this issue been resolved? Or is there any other way to know if the multi-select is complete?
Describe the project you are working on: Editor plugin which triggers an event as a result of FileSystem selections.
Describe the problem or limitation you are having in your project: Multi-select trees (i.e. what the filesystem dock uses) currently emit a
multi_selected
signal for each item which has changed. That is:multi_selected
events.multi_selected
events as there are items selected. These are raised at the time each item is processed.Anyone who wishes to trigger something as a result of the user's selection must therefore understand the following unintuitive things:
multi_selected
is raised for items which have actually been UNselectedmulti_selected
event.get_editor_interface().get_current_path()
,tree.get_selected()
ortree.get_next_selected()
while processing amulti_selected
event may return the 'wrong' thing, since the full selection hasn't been processed yetmulti_selected
event for item1 will be raised BEFORE the deselectedmulti_selected
event for item2 is raised. You will erroneously think that both items were selected simultaneously for some period of time, whereas from the user's point of view, they weren't.Describe the feature / enhancement and how it helps to overcome the problem or limitation: I propose a "multi_select_complete" signal which is emitted only when selection is complete. This signal will only raise for multi-select trees, and will contain a list of the TreeItems selected. This provides a much simpler and more intuitive way for users writing GUIs to process such events.
The FileSystem dock can connect to this and raise a "files_selected" event (since the tree is not easily accessible from the filesystem itself) with an array of selected paths. Possibly similar for the scene tree dock.
Additionally, it seems that getting the tree selection currently involves partially traversing the tree multiple times via
get_next_selected
. Can this be cached at selection time instead, and provided via a new function returning a full list?Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Draft here: https://github.com/godotengine/godot/compare/master...mnemoli:tree-enhance-master
(A bit inefficient at the moment, since it traverses the tree to get the selection right after we've just calculated the selection!)
If this enhancement will not be used often, can it be worked around with a few lines of script?: I see no way to work around it if you want to trigger at the point the selection is actually complete.
Is there a reason why this should be core and not an add-on in the asset library?: Involves the inner workings of a core gui node.