152 Commits

Author SHA1 Message Date
setzer22
809cdf80a9
Update README.md 2024-04-09 08:40:16 +02:00
setzer22
3068b8cd9b
Merge pull request #94 from kamirr/kek/dont_crash_on_removed_node
Allow inserting responses in draw_graph_editor
2023-05-21 12:49:47 +02:00
Kamil Koczurek
7cf8181c36 Allow inserting responses in draw_graph_editor
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.
2023-05-20 14:36:03 +02:00
setzer22
943cd4b94c
Merge pull request #90 from kamirr/kek/categories
node categories
2023-05-15 11:23:11 +02:00
setzer22
d2eaf38754
Merge pull request #92 from kamirr/kek/fix_cursor_in_graph
draw_graph_editor: fix cursor_in_editor
2023-05-15 11:22:56 +02:00
setzer22
6b3ca47db0
Merge pull request #89 from kamirr/kek/separator
custom separators
2023-05-15 11:21:41 +02:00
Kamil Koczurek
2c1b77d935 draw_graph_editor: fix cursor_in_editor
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.
2023-05-13 12:45:25 +02:00
Kamil Koczurek
02e625ccd7 Add AnyParameterId argument to NodeDataTrait::separator 2023-05-13 12:40:29 +02:00
Kamil Koczurek
671d1e6eed example: appease clippy in main.rs 2023-05-10 12:34:24 +02:00
Kamil Koczurek
006a5f3608 node finder: support node categories
* 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.
2023-05-10 12:34:19 +02:00
Kamil Koczurek
2976153046 Add NodeDataTrait::separator 2023-05-10 09:54:53 +02:00
Kamil Koczurek
fad164b88c NodeDataTrait::top_bar_ui fix doc comment 2023-05-09 16:54:09 +02:00
setzer22
0594981326
Merge pull request #86 from kamirr/kek/output_ui
add output ui
2023-05-09 16:41:06 +02:00
Kamil Koczurek
e92b934268 Add NodeDataTrait::output_ui
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.
2023-05-09 11:10:25 +02:00
setzer22
3336daa78f
Merge pull request #87 from kamirr/kek/input_ui
Add WidgetValueTrait::value_widget_always
2023-05-09 09:30:53 +02:00
setzer22
b914f167b8
Merge pull request #85 from hakolao/main
Update to egui 0.21 & fix the interaction bug
2023-05-09 09:28:56 +02:00
setzer22
e874f7d653
Merge pull request #88 from kamirr/kek/top_bar_ui
Add top bar UI
2023-05-09 09:28:08 +02:00
Kamil Koczurek
9c8d5f3258 update WidgetValueTrait::value_widget* comments 2023-05-08 10:41:02 +02:00
Kamil Koczurek
3b5198c050 Add WidgetValueTrait::value_widget_connected
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.
2023-05-08 10:19:21 +02:00
Kamil Koczurek
ba2a00ef76 Add top bar UI
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.
2023-05-07 18:46:18 +02:00
Okko Hakola
4cfe393412 Implement fix suggestions (interact area on resize) 2023-04-23 19:44:32 +03:00
Okko Hakola
790d9ef5f9 Fix node interaction bug 2023-04-23 01:53:51 +03:00
Okko Hakola
4ce43f5521 Update egui 2023-04-22 16:40:17 +03:00
Setzer22
78fe0265dd Bump version to 0.4.0 2022-12-10 12:55:13 +01:00
Setzer22
5d3ce74a85 Update CHANGELOG.md for 0.4.0 2022-12-10 12:52:43 +01:00
setzer22
d880c9c929
Merge pull request #74 from setzer22/feature/various_fixes
A couple minor bugfixes
2022-12-10 12:45:54 +01:00
setzer22
b5af1c745c
Merge pull request #76 from huisedenanhai/main
Node can decide whether it can be deleted
2022-12-10 12:43:55 +01:00
huisedenanhai
76ab0bd9e1 Collapse if statement 2022-11-21 22:32:32 +08:00
huisedenanhai
d2350d494a Node can decide whether it can be deleted 2022-11-19 22:16:48 +08:00
Setzer22
f4009fccc9 No more hack 2022-11-15 19:41:03 +01:00
Setzer22
70b60071ac Hack to fix node finder focus 2022-11-15 19:33:07 +01:00
Setzer22
1f79e61a72 Fix bug in cursor_in_finder computation 2022-11-15 19:06:33 +01:00
Setzer22
50b2ff94b2 Expose cursor_in_editor and cursor_in_finder 2022-11-15 18:55:34 +01:00
Setzer22
9f7826ae95 Add a scrollbar to the node finder 2022-11-13 16:05:46 +01:00
Setzer22
2607f55746 Fix mouse-related bugs
- 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
2022-11-13 15:54:24 +01:00
setzer22
070ff85bd3
Merge pull request #72 from setzer22/feature/box_selection
Box selection and multi-node movement
2022-11-12 18:21:23 +01:00
Setzer22
7b70b706b5 Handle moving multiple nodes at the same time with box selection
This also introduces a new NodeResponse to indicate node movement
2022-11-12 16:22:42 +01:00
Setzer22
14ca3b3b97 Remove dbg! 2022-11-12 16:13:50 +01:00
Setzer22
1fb512b8ae Handle selecting multiple nodes 2022-11-12 16:13:32 +01:00
setzer22
c2310e5f9b
Merge pull request #69 from setzer22/feature/user_state_in_value_widget
Expose UserState and the node id to value_widget
2022-11-12 15:28:59 +01:00
Setzer22
8706908d13 fmt 2022-11-06 09:18:21 +01:00
Setzer22
3fd60c532b Better documentation for the new Default trait bound 2022-10-29 18:29:57 +02:00
Setzer22
d6c1b324ee Also add NodeData parameter to value_widget 2022-10-29 18:22:50 +02:00
Setzer22
0ab08bd9ca Also expose UserState in NodeTemplateTrait 2022-10-29 17:22:14 +02:00
Setzer22
79fbe31482 Expose UserState and the node id to value_widget 2022-10-29 15:43:55 +02:00
setzer22
b65a780f35
Merge pull request #68 from kkngsm/default
implement Default in some struct
2022-10-07 19:13:55 +02:00
KOKI
36384258ab impl Default in some struct 2022-10-06 06:04:28 +09:00
setzer22
75308d0e72
Merge pull request #58 from kkngsm/outside-userstate
Change UserState to outside of GraphEditorState
2022-09-17 21:08:06 +02:00
KOKI
19ce5f4fa3 Changed the UserState args to mutable 2022-09-16 21:30:34 +09:00
KOKI
b32d864f0b Simplify NodeGraphExample::new() 2022-09-16 21:20:34 +09:00