Awesome library and thanks for sharing/contributing. I find the API straightforward and intuitive but I ran into a problem related to selection when implementing a more flexible/serious UI.
The current API relating to selection is currently (if I haven't missed anything):
// Read (imnodes.h)
int NumSelectedNodes();
int NumSelectedLinks();
void GetSelectedNodes(int* node_ids);
void GetSelectedLinks(int* link_ids);
// Write (imnodes.h)
void ClearNodeSelection();
void ClearLinkSelection();
The issue I would like to discuss at the moment is the lack of possibility to set the selection from outside the translation unit imnodes.cpp.
It would be very useful to be able to do this in order to do e.g. "Select All", "Select by id", "Invert selection" etc. in "user-code".
Missing setters is also a bit inconsistent with the ClearXXXSelection methods since "write access" is already provided via "clear all" semantics. I see no added exposure by providing more fine-grained control.
Hence I propose the following changes:
Add a function that adds a node to the current set of selected nodes unless already selected, e.g. void SelectNode(int node_id).
Add a function that removes a currently selected node from the set, e.g.void ClearNodeSelection(int node_id).
Add a function that adds a link to the current set of selected links unless already selected, e.g. void SelectLink(int link_id).
Add a function that removes a currently selected link from the set, e.g.void ClearLinkSelection(int link_id).
If write operations on selections are available in the API, it also requires less "flag features" to be implemented as part of the library since each use-case might have different needs/opinions whether or what key-combinations or input device actions should actually lead to selection, clear selection etc. It might be beneficial to define this in "user-code" to not lock into a predefined behavior.
The linked PR f/selection_improvements contain an implementation proposal for above mentioned functionality.
Awesome library and thanks for sharing/contributing. I find the API straightforward and intuitive but I ran into a problem related to selection when implementing a more flexible/serious UI.
The current API relating to selection is currently (if I haven't missed anything):
The issue I would like to discuss at the moment is the lack of possibility to set the selection from outside the translation unit imnodes.cpp. It would be very useful to be able to do this in order to do e.g. "Select All", "Select by id", "Invert selection" etc. in "user-code". Missing setters is also a bit inconsistent with the ClearXXXSelection methods since "write access" is already provided via "clear all" semantics. I see no added exposure by providing more fine-grained control.
Hence I propose the following changes:
void SelectNode(int node_id)
.void ClearNodeSelection(int node_id)
.void SelectLink(int link_id)
.void ClearLinkSelection(int link_id)
.If write operations on selections are available in the API, it also requires less "flag features" to be implemented as part of the library since each use-case might have different needs/opinions whether or what key-combinations or input device actions should actually lead to selection, clear selection etc. It might be beneficial to define this in "user-code" to not lock into a predefined behavior.
The linked PR f/selection_improvements contain an implementation proposal for above mentioned functionality.