142 Commits

Author SHA1 Message Date
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
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
setzer22
0395039920
Merge pull request #62 from setzer22/fix/incompatible_port_snap
Fix/incompatible port snap
2022-09-15 12:11:00 +02:00
Setzer22
234d377302 Fix bug when reconnecting port
There was a bug where removing an existing connection and re-wiring it
to the same port would not work. This is now fixed
2022-09-15 12:03:37 +02:00
Setzer22
c0ba6fe227 Do not snap incompatible ports
This takes care of the second half of #54, where ports snapped
to incompatible colors even when the connection was not possible.
2022-09-15 11:38:02 +02:00
setzer22
d540805c25
Merge pull request #61 from bpostlethwaite/reorder-remove-node-responses
return disconnect responses before removal response
2022-09-07 14:59:52 +00:00
bpostlethwaite
0747ab595d return disconnect responses before removal response
This allows for a more logical order of cleanup operations in user
code. Disconnect and clean up the node before removal.
2022-09-06 10:53:10 -07:00
setzer22
4db5eea1ab
Merge pull request #59 from kkngsm/constant-snap
fix ConstantOnly bug of port snapping
2022-08-30 16:31:19 +00:00
KOKI
3eef3acb34 fix ConstantOnly bug of port snapping 2022-08-26 14:27:42 +09:00
KOKI
9c662f8ae1 fix clippy 2022-08-26 13:50:50 +09:00
KOKI
d3fa4d3ff2 fix NodeGraphExample::new() 2022-08-26 13:27:07 +09:00
KOKI
be08862056 Merge branch 'persistence' into outside-userstate 2022-08-26 03:17:46 +09:00