This allows a user to trigger an event externally as if it was created
by UI. For example, to remove a node one just needs to insert a
NodeRespone::DeleteNodeUi. Without this feature one needs to remove the
node from the graph *and* adjust the internal state of GraphEditorState.
Previously the editor assumed that if the editor_rect contained the
cursor, then the editor should act like it is hovered. This works as
long as the editor is the only widget in the central panel, but it broke
when interacting with windows.
If a window was covering some part of the editor widget:
1. You could open the node finder while hovering the window, which is
terrible for interacting with widgets within that window.
2. You could not close the node finder by clicking on the window (this
click was considered neither a background click, nor an out-of-editor
click).
This is fixed by using egui sense to detect hover, which will
automatically handle any widgets overlapping the editor.
* Add CategoryTrait that gives a name to a category of nodes. Provide
implementations for String, &str and ().
* Add NodeTemplateTrait::node_finder_categories to list categories to
which the template belongs, defaults to an empty vector.
* Node finder now displays at the top a collapsible header for each
category and corresponding nodes inside of them. Nodes without a
category are displayed below, so the behavior of programs that don't
adapt to use categories remains the same. The collapsible headers
behave as follows:
- For empty query, all categories are collapsed
- Otherwise:
1. Categories that contain no matching nodes are ommited.
2. Matching categories are now opened by default -- it's assumed
that filtered results are more manageable and can now be
unwrapped.
3. The user can normally un/collapse each category, but if the
query is changed, the default is applied.
* Update the example to use this feature.
This change will break all existing programs and the simplest fix to
that is adding `type CategoryType = ();` in the implementation of
`NodeTemplateTrait`. Default associated types are not supported, so
this can't be avoided with this design.
This method draws the UI for each of the outputs corresponding to the
node. Defaults to the label that was the previous hard-coded behavior.
The default impl also means this isn't a breaking change.
Depending on the usage of value widgets, we might wish to display an
alternative UI if the input is connected.
Motivating example: consider a node with an input representing some
amount of time in the context of digital signal processing. Multiple
valuable representations of time may be desired as inputs:
* number of seconds
* number of samples
* wavelength corresponding to some frequency in Hz
In such a case we would use value_widget to display a widget for
selecting both the number and the unit, and value_widget_connected for
only selecting the unit, because the numerical value would already be
supplied by another node.
Users can specify UI that will be added to the top bar of a node via the
new top_bar_ui method in NodeDataTrait. A default definition is provided
because it's not core to the functionality and so as to avoid
unnecessarily breaking existing programs.
- The box selection should only be activated by the primary mouse
- Now that egui finally supports it, make the node finder trigger be a
mouse click, not a "mouse down". This prevents a weird behavior where
you could drag around the node finder when clicking and dragging with
the left mouse button