diff --git a/vstgui/standalone/examples/standalone/source/testappdelegate.cpp b/vstgui/standalone/examples/standalone/source/testappdelegate.cpp index 82db77376..93e61d2ba 100644 --- a/vstgui/standalone/examples/standalone/source/testappdelegate.cpp +++ b/vstgui/standalone/examples/standalone/source/testappdelegate.cpp @@ -222,6 +222,7 @@ class DatePickerController : public DelegationController Delegate::Delegate () : Application::DelegateAdapter ({"VSTGUI Standalone", "1.0.0", VSTGUI_STANDALONE_APP_URI}) { + CFrame::kDefaultKnobMode = CKnobMode::kLinearMode; } //------------------------------------------------------------------------ diff --git a/vstgui/tests/unittest/uidescription/uiviewcreator/cknobcreator_test.cpp b/vstgui/tests/unittest/uidescription/uiviewcreator/cknobcreator_test.cpp index 3f761eae5..0d47e6224 100644 --- a/vstgui/tests/unittest/uidescription/uiviewcreator/cknobcreator_test.cpp +++ b/vstgui/tests/unittest/uidescription/uiviewcreator/cknobcreator_test.cpp @@ -31,6 +31,13 @@ TEST_CASE (CKnobCreatorTest, AngleRange) }); } +TEST_CASE (CKnobCreatorTest, KnobRange) +{ + DummyUIDescription uidesc; + testAttribute (kCKnob, kAttrKnobRange, 200., &uidesc, + [&] (CKnob* v) { return v->getKnobRange () == 200.; }); +} + TEST_CASE (CKnobCreatorTest, ValueInset) { DummyUIDescription uidesc; diff --git a/vstgui/uidescription/detail/uiviewcreatorattributes.h b/vstgui/uidescription/detail/uiviewcreatorattributes.h index 2516394dc..01efff7d6 100644 --- a/vstgui/uidescription/detail/uiviewcreatorattributes.h +++ b/vstgui/uidescription/detail/uiviewcreatorattributes.h @@ -216,6 +216,7 @@ static const std::string kAttrSegmentNames = "segment-names"; //----------------------------------------------------------------------------- static const std::string kAttrAngleStart = "angle-start"; static const std::string kAttrAngleRange = "angle-range"; +static const std::string kAttrKnobRange = "knob-range"; static const std::string kAttrValueInset = "value-inset"; static const std::string kAttrCoronaInset = "corona-inset"; static const std::string kAttrCoronaColor = "corona-color"; diff --git a/vstgui/uidescription/viewcreator/knobcreator.cpp b/vstgui/uidescription/viewcreator/knobcreator.cpp index fbe78dc6d..5ba6f4187 100644 --- a/vstgui/uidescription/viewcreator/knobcreator.cpp +++ b/vstgui/uidescription/viewcreator/knobcreator.cpp @@ -35,6 +35,8 @@ bool KnobBaseCreator::apply (CView* view, const UIAttributes& attributes, d = d / 180.f * static_cast (Constants::pi); knob->setRangeAngle (static_cast (d)); } + if (attributes.getDoubleAttribute (kAttrKnobRange, d)) + knob->setKnobRange (static_cast (d)); if (attributes.getDoubleAttribute (kAttrValueInset, d)) knob->setInsetValue (d); if (attributes.getDoubleAttribute (kAttrZoomFactor, d)) @@ -48,6 +50,7 @@ bool KnobBaseCreator::getAttributeNames (StringList& attributeNames) const { attributeNames.emplace_back (kAttrAngleStart); attributeNames.emplace_back (kAttrAngleRange); + attributeNames.emplace_back (kAttrKnobRange); attributeNames.emplace_back (kAttrValueInset); attributeNames.emplace_back (kAttrZoomFactor); return true; @@ -60,6 +63,8 @@ auto KnobBaseCreator::getAttributeType (const string& attributeName) const -> At return kFloatType; if (attributeName == kAttrAngleRange) return kFloatType; + if (attributeName == kAttrKnobRange) + return kFloatType; if (attributeName == kAttrValueInset) return kFloatType; if (attributeName == kAttrZoomFactor) @@ -87,6 +92,11 @@ bool KnobBaseCreator::getAttributeValue (CView* view, const string& attributeNam UIAttributes::doubleToString ((knob->getRangeAngle () / Constants::pi * 180.), 5); return true; } + if (attributeName == kAttrKnobRange) + { + stringValue = UIAttributes::doubleToString (knob->getKnobRange (), 5); + return true; + } if (attributeName == kAttrValueInset) { stringValue = UIAttributes::doubleToString (knob->getInsetValue ());