Giter Club home page Giter Club logo

Comments (6)

setzer22 avatar setzer22 commented on June 24, 2024 1

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.

setzer22 avatar setzer22 commented on June 24, 2024 1

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.

setzer22 avatar setzer22 commented on June 24, 2024 1

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.

kkngsm avatar kkngsm commented on June 24, 2024

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.

kkngsm avatar kkngsm commented on June 24, 2024

Making user_state mutable in bottom_ui() makes the following line unnecessary, but requires an example of response usage.

if let NodeResponse::User(user_event) = node_response {
match user_event {
MyResponse::SetActiveNode(node) => self.user_state.active_node = Some(node),
MyResponse::ClearActiveNode => self.user_state.active_node = None,
}
}

I suggest adding a node such as AddScalarByUi (related #25).

from egui_node_graph.

kkngsm avatar kkngsm commented on June 24, 2024

how about adding a SumScalar that can increase input param?
image
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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.