You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using visit_struct to declare structs with parameters and automatically link specific option values to GUI widgets. It works great for simple cases.
However, more often than not I would like to define additional metadata where I specify the options in the struct. For example for numeric options, I would like to specify a range with minimum and maximum acceptable value, such that a slider with the correct limits can be created in the GUI.
I'm currently working around this by using some custom types for the struct member variables, e.g.
template <classT>
structranged {
using ValueType = T;
T val {0};
const T min {0};
const T max {100};
};
structFoo {
BEGIN_VISITABLES(Foo);
VISITABLE_INIT(bool, foo, true);
VISITABLE_DIRECT_INIT(ranged<double>, bar, {0.5, 0, 1});
END_VISITABLES;
};
However this is a bit awkward, as a I have to access the actual value always via the val member.
Foo foo;
foo.bar.val = 0.1;
Would it be possible to extend visit_struct to allow declaring additional (typed) meta-data for every member in such a way, that it is transparent (i.e. foo.bar refers to the actual value, not some enclosing struct containing also the metadata), and it is (optionally) accessible during visitation.
I guess for my use-cases I so far only need constant meta-data.
I'm mostly interested in the intrusive syntax, since I want to define "all in one place", but one might also consider adding metadata to existing structs with a non-intrusive syntax.
The text was updated successfully, but these errors were encountered:
I'm using
visit_struct
to declare structs with parameters and automatically link specific option values to GUI widgets. It works great for simple cases.However, more often than not I would like to define additional metadata where I specify the options in the struct. For example for numeric options, I would like to specify a range with minimum and maximum acceptable value, such that a slider with the correct limits can be created in the GUI.
I'm currently working around this by using some custom types for the struct member variables, e.g.
However this is a bit awkward, as a I have to access the actual value always via the
val
member.Foo foo; foo.bar.val = 0.1;
Would it be possible to extend visit_struct to allow declaring additional (typed) meta-data for every member in such a way, that it is transparent (i.e.
foo.bar
refers to the actual value, not some enclosing struct containing also the metadata), and it is (optionally) accessible during visitation.I guess for my use-cases I so far only need constant meta-data.
I'm mostly interested in the intrusive syntax, since I want to define "all in one place", but one might also consider adding metadata to existing structs with a non-intrusive syntax.
The text was updated successfully, but these errors were encountered: