src/UI/PropertyEditors.cpp
// draw a property editor for 2 double values in a list
draw a property editor for 2 double values in a list
draw a property editor for 2 double values in a list
static void Draw2DoubleValueEditor(
        AbstractPropertyEditor&,
        OpenSim::SimpleProperty<double> const& prop,
        std::optional<AbstractPropertyEditor::Response>& rv)
{
    if (prop.size() != 2)
    {
        return;
    }
    std::array<float, 2> vs =
    {
        static_cast<float>(prop.getValue(0)),
        static_cast<float>(prop.getValue(1))
    };
    ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth());
    if (ImGui::InputFloat2("##vec2editor", vs.data(), "%.3f") && ItemValueShouldBeSaved())
    {
        rv = AbstractPropertyEditor::Response{[vs](OpenSim::AbstractProperty& p)
        {
            auto* pd = dynamic_cast<OpenSim::Property<double>*>(&p);
            if (!pd)
            {
                return;
            }
            pd->setValue(0, static_cast<double>(vs[0]));
            pd->setValue(1, static_cast<double>(vs[1]));
        }};
    }
}
static void Draw2DoubleValueEditor ( AbstractPropertyEditor & , OpenSim :: SimpleProperty < double > const & prop , std :: optional < AbstractPropertyEditor :: Response > & rv ) { if ( prop . size ( ) != 2 ) { return ; } std :: array < float , 2 > vs = { static_cast < float > ( prop . getValue ( 0 ) ) , static_cast < float > ( prop . getValue ( 1 ) ) } ; ImGui :: SetNextItemWidth ( ImGui :: GetContentRegionAvailWidth ( ) ) ; if ( ImGui :: InputFloat2 ( " " , vs . data ( ) , " " ) && ItemValueShouldBeSaved ( ) ) { rv = AbstractPropertyEditor :: Response { [ vs ] ( OpenSim :: AbstractProperty & p ) { auto * pd = dynamic_cast < OpenSim :: Property < double > * > ( & p ) ; if ( ! pd ) { return ; } pd -> setValue ( 0 , static_cast < double > ( vs [ 0 ] ) ) ; pd -> setValue ( 1 , static_cast < double > ( vs [ 1 ] ) ) ; } } ; } }
draw a property editor for 2 double values in a list
draw a property editor for 2 double values in a list
// ERROR: wrong type passed into the updater at runtime