Skip to content
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

UI node graph #565

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

UI node graph #565

wants to merge 4 commits into from

Conversation

chaosprint
Copy link
Contributor

2023-07-06.13-39-27.mp4

@chaosprint chaosprint marked this pull request as draft July 6, 2023 11:41
Copy link
Contributor

@philpax philpax left a 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() {
Copy link
Contributor

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 {
Copy link
Contributor

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);
// }
Copy link
Contributor

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() {
Copy link
Contributor

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(&ltw);
Copy link
Contributor

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?

Copy link
Contributor Author

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");
Copy link
Contributor

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 {
Copy link
Contributor

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);
Copy link
Contributor

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()
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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?

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest NodeGraph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants