Comments (6)
Hi! You are right, there is no reason I can think of to have UserState
live inside the graph state. Users could manage the lifetime of their state struct more flexibly if it was a separate struct.
I am thinking of changing some the UserState arguments from &UserState to &mut UserState, is there any reason why it should be &UserState?
When the user state struct was inside the graph, it wasn't possible to pass it as an exclusive reference to some methods. If that is possible now after your PR, it may help simplify some things so I wouldn't be against it 🤔
I still like the current design where people are encouraged to defer mutations to the user state until the end via the Response
object. But I don't want to be overly opinionated on this.
from egui_node_graph.
I like that the current example showcases the custom user response feature. Deferring side effects is useful, because it lets you decouple the UI code from the business logic. Showing that in the example helps users understand why there's a custom response type to begin with.
This would be more obvious if there was more complex logic attached to the "set active" action, but then that would complicate the example unnecessarily.
from egui_node_graph.
Ok, I just realized I misunderstood your original comment. Sorry about that @kkngsm!
Yes, I'm all for an example like SumScalar
using the response mechanism, and then having the simpler "Set active" button simply using mutation. Yours is a great example of why the response mechanism is necessary, because you can't modify the graph while you're drawing it, and some side-effects need to be deferred.
from egui_node_graph.
I am thinking of changing some the UserState arguments from &UserState to &mut UserState, is there any reason why it should be &UserState?
from egui_node_graph.
Making user_state mutable in bottom_ui() makes the following line unnecessary, but requires an example of response usage.
egui_node_graph/egui_node_graph_example/src/app.rs
Lines 404 to 409 in 75308d0
I suggest adding a node such as AddScalarByUi (related #25).
from egui_node_graph.
how about adding a SumScalar that can increase input param?
Responses will be as follows
match user_event {
MyResponse::AddInputParam {
node_id,
name,
typ,
value,
kind,
shown_inline,
} => {
self.state.graph.add_input_param(
node_id,
name,
typ,
value,
kind,
shown_inline,
);
}
}
from egui_node_graph.
Related Issues (20)
- Please add minimalistic example using bevy_egui HOT 11
- Buttons drawn on (after) the graph doesn't working. HOT 4
- The example doesn't work with version 0.3.0 HOT 3
- Would be nice with an example using Bevy and bevy-egui together with this project HOT 1
- Right click output - create node and connect HOT 1
- Incorrect draw order HOT 1
- Hide close button of node widget HOT 3
- New crates.io release HOT 1
- Cant Compile to web HOT 1
- Remove Widget on input connection HOT 1
- Cannot use because Color32 is not in epaint::color::Color32 HOT 4
- Feature request - allow labeling of edges HOT 2
- Add topological iterator to Graph class HOT 1
- Easy way to create pre-existing graph state? HOT 1
- Performance concerns HOT 1
- give example the ability to zoom in/out and scroll side to side HOT 1
- missing input on Connection Only and then Connection/Constant node
- Handling disconnection events on node deletion is a bit cumbersome
- Persistence HOT 1
- Suggestion: Read-only mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from egui_node_graph.