Skip to content

Commit

Permalink
add new knob range attribute to uidesc editor
Browse files Browse the repository at this point in the history
  • Loading branch information
scheffle committed Oct 22, 2023
1 parent 7fae3ab commit 4728884
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

//------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ TEST_CASE (CKnobCreatorTest, AngleRange)
});
}

TEST_CASE (CKnobCreatorTest, KnobRange)
{
DummyUIDescription uidesc;
testAttribute<CKnob> (kCKnob, kAttrKnobRange, 200., &uidesc,
[&] (CKnob* v) { return v->getKnobRange () == 200.; });
}

TEST_CASE (CKnobCreatorTest, ValueInset)
{
DummyUIDescription uidesc;
Expand Down
1 change: 1 addition & 0 deletions vstgui/uidescription/detail/uiviewcreatorattributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
10 changes: 10 additions & 0 deletions vstgui/uidescription/viewcreator/knobcreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ bool KnobBaseCreator::apply (CView* view, const UIAttributes& attributes,
d = d / 180.f * static_cast<float> (Constants::pi);
knob->setRangeAngle (static_cast<float> (d));
}
if (attributes.getDoubleAttribute (kAttrKnobRange, d))
knob->setKnobRange (static_cast<float> (d));
if (attributes.getDoubleAttribute (kAttrValueInset, d))
knob->setInsetValue (d);
if (attributes.getDoubleAttribute (kAttrZoomFactor, d))
Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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 ());
Expand Down

0 comments on commit 4728884

Please sign in to comment.