mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
AudioProcessor: Use std::optional in TrackProperties
This commit is contained in:
parent
59ca34daaf
commit
9b959bd223
9 changed files with 42 additions and 17 deletions
|
|
@ -24,6 +24,25 @@ The previous behavior, where hasStreamFinished never returned true, was
|
|||
incorrect. This update ensures the method works as intended.
|
||||
|
||||
|
||||
## Change
|
||||
|
||||
AudioProcessor::TrackProperties now uses std::optional.
|
||||
|
||||
**Possible Issues**
|
||||
|
||||
Code that accessed TrackProperties properties directly will no longer compile.
|
||||
|
||||
**Workaround**
|
||||
|
||||
Use std::optional::has_value() to check if a property is set. Or Access the
|
||||
property value safely using std::optional::value() or operator*.
|
||||
|
||||
**Rationale**
|
||||
|
||||
Previously, it was not possible to distinguish whether a TrackProperty was
|
||||
explicitly set or if the default value was being used.
|
||||
|
||||
|
||||
## Change
|
||||
|
||||
Support for Arm32 in Projucer has been removed for Windows targets.
|
||||
|
|
|
|||
|
|
@ -470,8 +470,8 @@ private:
|
|||
auto trackColour = getProcessor().getTrackProperties().colour;
|
||||
auto& lf = getLookAndFeel();
|
||||
|
||||
backgroundColour = (trackColour == Colour() ? lf.findColour (ResizableWindow::backgroundColourId)
|
||||
: trackColour.withAlpha (1.0f).withBrightness (0.266f));
|
||||
backgroundColour = (trackColour.has_value() ? trackColour->withAlpha (1.0f).withBrightness (0.266f)
|
||||
: lf.findColour (ResizableWindow::backgroundColourId));
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1322,7 +1322,7 @@ namespace AAXClasses
|
|||
if (data != nullptr)
|
||||
{
|
||||
AudioProcessor::TrackProperties props;
|
||||
props.name = String::fromUTF8 (static_cast<const AAX_IString*> (data)->Get());
|
||||
props.name = std::make_optional (String::fromUTF8 (static_cast<const AAX_IString*> (data)->Get()));
|
||||
|
||||
pluginInstance->updateTrackProperties (props);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2589,7 +2589,7 @@ private:
|
|||
&& juceFilter != nullptr && GetContextName() != nullptr)
|
||||
{
|
||||
AudioProcessor::TrackProperties props;
|
||||
props.name = String::fromCFString (GetContextName());
|
||||
props.name = std::make_optional (String::fromCFString (GetContextName()));
|
||||
|
||||
juceFilter->updateTrackProperties (props);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ public:
|
|||
if (str != nullptr)
|
||||
{
|
||||
AudioProcessor::TrackProperties props;
|
||||
props.name = nsStringToJuce (str);
|
||||
props.name = std::make_optional (nsStringToJuce (str));
|
||||
|
||||
getAudioProcessor().updateTrackProperties (props);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1171,14 +1171,14 @@ public:
|
|||
{
|
||||
Vst::String128 channelName;
|
||||
if (list->getString (Vst::ChannelContext::kChannelNameKey, channelName, sizeof (channelName)) == kResultTrue)
|
||||
trackProperties.name = toString (channelName);
|
||||
trackProperties.name = std::make_optional (toString (channelName));
|
||||
}
|
||||
|
||||
{
|
||||
Steinberg::int64 colour;
|
||||
if (list->getInt (Vst::ChannelContext::kChannelColorKey, colour) == kResultTrue)
|
||||
trackProperties.colour = Colour (Vst::ChannelContext::GetRed ((uint32) colour), Vst::ChannelContext::GetGreen ((uint32) colour),
|
||||
Vst::ChannelContext::GetBlue ((uint32) colour), Vst::ChannelContext::GetAlpha ((uint32) colour));
|
||||
trackProperties.colour = std::make_optional (Colour (Vst::ChannelContext::GetRed ((uint32) colour), Vst::ChannelContext::GetGreen ((uint32) colour),
|
||||
Vst::ChannelContext::GetBlue ((uint32) colour), Vst::ChannelContext::GetAlpha ((uint32) colour)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1612,9 +1612,9 @@ public:
|
|||
//==============================================================================
|
||||
void updateTrackProperties (const TrackProperties& properties) override
|
||||
{
|
||||
if (properties.name.isNotEmpty())
|
||||
if (properties.name.has_value())
|
||||
{
|
||||
CFObjectHolder<CFStringRef> contextName { properties.name.toCFString() };
|
||||
CFObjectHolder<CFStringRef> contextName { properties.name->toCFString() };
|
||||
AudioUnitSetProperty (audioUnit, kAudioUnitProperty_ContextName, kAudioUnitScope_Global,
|
||||
0, &contextName.object, sizeof (contextName.object));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3142,8 +3142,11 @@ public:
|
|||
{
|
||||
if (! std::strcmp (id, Vst::ChannelContext::kChannelNameKey))
|
||||
{
|
||||
Steinberg::String str (props.name.toRawUTF8());
|
||||
str.copyTo (string, 0, (Steinberg::int32) jmin (size, (Steinberg::uint32) std::numeric_limits<Steinberg::int32>::max()));
|
||||
if (props.name.has_value())
|
||||
{
|
||||
Steinberg::String str (props.name->toRawUTF8());
|
||||
str.copyTo (string, 0, (Steinberg::int32) jmin (size, (Steinberg::uint32) std::numeric_limits<Steinberg::int32>::max()));
|
||||
}
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
|
@ -3153,9 +3156,12 @@ public:
|
|||
|
||||
tresult PLUGIN_API getInt (AttrID id, Steinberg::int64& value) override
|
||||
{
|
||||
if (! std::strcmp (Vst::ChannelContext::kChannelNameLengthKey, id)) value = props.name.length();
|
||||
else if (! std::strcmp (Vst::ChannelContext::kChannelColorKey, id)) value = static_cast<Steinberg::int64> (props.colour.getARGB());
|
||||
else return kResultFalse;
|
||||
if (! std::strcmp (Vst::ChannelContext::kChannelNameLengthKey, id))
|
||||
value = props.name.value_or (String{}).length();
|
||||
else if (! std::strcmp (Vst::ChannelContext::kChannelColorKey, id))
|
||||
value = static_cast<Steinberg::int64> (props.colour.value_or (Colours::transparentBlack).getARGB());
|
||||
else
|
||||
return kResultFalse;
|
||||
|
||||
return kResultTrue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1305,8 +1305,8 @@ public:
|
|||
AudioProcessor is loaded. */
|
||||
struct TrackProperties
|
||||
{
|
||||
String name; // The name of the track - this will be empty if the track name is not known
|
||||
Colour colour; // The colour of the track - this will be transparentBlack if the colour is not known
|
||||
std::optional<String> name; // The name of the track - this will be empty if the track name is not known
|
||||
std::optional<Colour> colour; // The colour of the track - this will be empty if the colour is not known
|
||||
|
||||
// other properties may be added in the future
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue