Fattorino / ImNodeFlow

Node based editor/blueprints for ImGui
MIT License
119 stars 15 forks source link

Forwarding Arguments to Derived Node Constructor #3

Closed avlec closed 4 months ago

avlec commented 4 months ago

It would be useful to have the option to forward constructor arguments to the derived class when performing addNode to get more reusable behaviour out of user defined node types without having to pass them in through some alternate mechanism.

Fattorino commented 4 months ago

Could you provide a small example? I'm not sure if I understood your message correctly

avlec commented 4 months ago

Something like this

struct A : ImFlow::BaseNode {
  explicit A(const std::string &name, ImVec2 pos, ImFlow::ImNodeFlow *inf, int numIns)
  : BaseNode(name, pos, inf)
  {
     // Do something with numIns like dynamically sizing number of inputs
  }
  // Rest of methods
};

addNode<A>("A", 2); // not sure if this exact syntax is possible