-
Notifications
You must be signed in to change notification settings - Fork 128
UI node graph #565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
UI node graph #565
Conversation
philpax
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I need to test it, but keen to see if it works :)
| hooks.use_frame({ | ||
| to_owned![id, mouse_over_count]; | ||
| move |world| { | ||
| if let Some(id) = *id.lock() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest let Some(id) = *id.lock() else { return; } to cut one layer of indentation
| Self { inner } | ||
| } | ||
| } | ||
| impl ElementComponent for DragArea { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest using the #[element_component] macro
| // if *state > 0 && next == 0 { | ||
| // // println!("mouse leave"); | ||
| // ambient_guest_bridge::window::set_cursor(world, CursorIcon::Default); | ||
| // } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove lines
| hooks.use_runtime_message::<messages::WindowMouseInput>({ | ||
| to_owned![id, mouse_over_count, set_moving]; | ||
| move |world, event| { | ||
| if let Some(id) = *id.lock() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto on let Some
| } | ||
|
|
||
| let ltw = world.get(*to_id, local_to_world()).unwrap(); | ||
| let (_, _, new_to_pos) = Mat4::to_scale_rotation_translation(<w); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use translation() for this, or is that not updated for UI code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used translation() before but this will require its parent's translation() as well. The DragArea is the parent while the main body and the dots are children.
| println!("no start id"); | ||
| } | ||
| } else { | ||
| println!("dropped to none inlet"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove printlns
| } | ||
|
|
||
| for id in in_id.lock().iter() { | ||
| if !event.pressed && event.button == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invert condition and use continue to remove indentation
| nodes | ||
| .iter() | ||
| .map(move |node| { | ||
| println!("node: {:?}", node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
|
|
||
| #[element_component] | ||
| fn App(_hooks: &mut Hooks) -> Element { | ||
| Graph::el() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this Graph spawn? Or is it an empty graph?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, how do you interact with the graph and get values out of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a good idea to e.g. make a calculator using this, so you can see how it works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, how do you interact with the graph and get values out of it?
Good question. I haven't got any idea yet on how to store the data structure. Still drafting this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this
Graphspawn? Or is it an empty graph?
It's just temporary. Might be good to change it to GraphEditor or something else, and perhaps this whole thing should be put into the editor folder.
|
|
||
| #[element_component] | ||
| /// A Graph Element that you can put lots of nodes | ||
| pub fn Graph(hooks: &mut Hooks) -> Element { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest NodeGraph
2023-07-06.13-39-27.mp4