Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add WEffectMetaKnob, draws arc from default meta position #12638

Merged
merged 9 commits into from
May 30, 2024

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Jan 24, 2024

When an effect is loaded, the knob gets the default meta parameter from the effect manifest and draws the knob arc from there to current angle.

Closes #12634

Don't let this distract you from the 2.4 release, this can very well wait for 2.4.1 or later.

I added this widget only where arcs are or may be used, i.e. all skins except Shade.

@daschuer
Copy link
Member

This one looks now:
grafik
The Meta knob has the correct ring, but the parameter knob is still wrong.

@github-actions github-actions bot added the build label Apr 22, 2024
@ronso0
Copy link
Member Author

ronso0 commented Apr 22, 2024

No prob, fix second new feature is here.

This revealed some misplaced 'neutral point on scale' values, e.g. high freq. of Graphic EQ.

@ronso0 ronso0 marked this pull request as draft April 22, 2024 23:27
@ronso0
Copy link
Member Author

ronso0 commented Apr 22, 2024

Draft so I can clean up and force-push without disrupting a review.

@ronso0 ronso0 marked this pull request as ready for review April 22, 2024 23:44
@ronso0 ronso0 removed the build label Apr 23, 2024
@github-actions github-actions bot added the build label Apr 24, 2024
Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just brainstorming here. not trying to drag this out.

src/effects/effectknobparameterslot.cpp Outdated Show resolved Hide resolved
src/widget/wknobcomposed.h Outdated Show resolved Hide resolved
Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works perfect. Thank you.

src/widget/weffectmetaknob.h Show resolved Hide resolved
src/widget/weffectmetaknob.cpp Outdated Show resolved Hide resolved
src/widget/weffectmetaknob.cpp Outdated Show resolved Hide resolved
src/effects/effectknobparameterslot.cpp Outdated Show resolved Hide resolved
Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like ur currently missing a couple #include <optional>s.

Comment on lines 118 to 124
if (!parameter.has_value() || parameter.value() < 0 || parameter.value() > 1) {
m_defaultAngle = std::nullopt;
} else {
m_defaultAngle = std::lerp(m_dMinAngle, m_dMaxAngle, parameter.value());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a suggestion, just a preview of what would be possible in C++23. (imo easier to read and also faster because it only does a single has_value check.

Suggested change
if (!parameter.has_value() || parameter.value() < 0 || parameter.value() > 1) {
m_defaultAngle = std::nullopt;
} else {
m_defaultAngle = std::lerp(m_dMinAngle, m_dMaxAngle, parameter.value());
}
m_defaultAngle = parameter.transform([this](double value) {
return (parameter < 0 || parameter > 1) ?
std::nullopt :
std::lerp(m_dMinAngle, m_dMaxAngle, parameter);
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I would prefer to give m_defaultAngle a valid value here. It is better to have a variable that can be used unconditional in all cases.
The idea to have an indicator that the knob does not control an effect or just "---" is still open. Than the question is how to check that easily. Probably a topic of a follow up PR if we ever want to do it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I would prefer to give m_defaultAngle a valid value here. It is better to have a variable that can be used unconditional in all cases.

That defeats the purpose of the optional. This snippet of code here can't accurately determine what value is appropriate.

@daschuer
Copy link
Member

By the way: Is this a last minute 2.4 PR?
I don't mind. At least my latest comments are not intended blocking a merge.

@ronso0
Copy link
Member Author

ronso0 commented Apr 25, 2024

Yes, that can slip into 2.4.1 last minute!
(need to double-check all skins for regressions! though I need to quit now, can take care of it on sunday earliest)

Please check the rect commit and the fixup with your suggestion.

@daschuer
Copy link
Member

Please check the rect commit and the fixup with your suggestion.

Looks good. Thank you.

@ronso0
Copy link
Member Author

ronso0 commented Apr 27, 2024

Error: ../src/widget/wknobcomposed.cpp:118:45: error: 'value' is unavailable: introduced in macOS 10.13
if (!parameter.has_value() || parameter.value() < 0 || parameter.value() > 1) {
^
/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/optional:954:27: note: 'value' has been explicitly marked unavailable here
constexpr value_type& value() &
^

😞
Any ideas how to work around that?

Otherwise we may as well move this to 2.5

@Swiftb0y
Copy link
Member

Any ideas how to work around that?

No idea. Just AppleClang being completely outdated as usual...

Otherwise we may as well move this to 2.5

Yeah. maybe leave a TODO there so the next time someone stumbles over this, they can do the trivial refactoring.

@ronso0
Copy link
Member Author

ronso0 commented Apr 29, 2024

Alright, CI all green.

Please take a look, then I'll squash the fixups (had to fixup since the commit introducing std::optional couldn't be built).

Comment on lines +118 to +119
// TODO(xxx) Use m_defaultAngle->value() as soon as
// AppleClang 10.13+ is used.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally this just used the monadic operations from C++23 by then 😉

@ronso0
Copy link
Member Author

ronso0 commented May 6, 2024

Am I done here, all reviews addressed?

Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from my side, yes. almost

Comment on lines 54 to 56
virtual std::optional<double> neutralPointOnScale() const {
return std::nullopt;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we implement this right here already?

Suggested change
virtual std::optional<double> neutralPointOnScale() const {
return std::nullopt;
}
std::optional<double> neutralPointOnScale() const {
if (m_pManifestParameter == nullptr) {
return std::nullopt;
}
return m_pManifestParameter->neutralPointOnScale();
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we'd have to override it for EffectButtonParameterSlot, just for the possible case that the neutral point is requested for a button parameter?
That would otherwise return the unchanged default 0. Though, in that case (controlling a button parameter with a knob widget) a lot else wouldn't work quite as desired.
I don't mind..

Wdyt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we'd have to override it for EffectButtonParameterSlot, just for the possible case that the neutral point is requested for a button parameter?

Well if that makes sense for a button parameter, we should make sure the value also makes sense. If it doesn't make sense (which is what you are suggesting, right?) then we can also let the return value be nonsensical.

The advantage of implementing it in the base class is that we can avoid virtual dispatch.

I think the primary issue here is that neutralPointOnScale only makes sense on knobs, but the existing code infrastructure requires it to be implemented on the base-class. Is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, implemented as you suggested. In the unlikely button case it'll return the default 0.

@ronso0 ronso0 modified the milestones: 2.4.2, 2.5-beta May 29, 2024
@ronso0 ronso0 changed the base branch from 2.4 to 2.5 May 29, 2024 00:16
Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. sorry for having forgotten about this.

@Swiftb0y Swiftb0y merged commit e46c498 into mixxxdj:2.5 May 30, 2024
13 checks passed
@Swiftb0y
Copy link
Member

Thank you

@ronso0 ronso0 deleted the weffectmetaknob branch May 30, 2024 10:22
@ronso0
Copy link
Member Author

ronso0 commented May 30, 2024

LGTM. sorry for having forgotten about this.

Never mind, there was an unaddressed review and I've pushed this back until now.
Thanks for your review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

origins of effect Meta knob arcs are not consistent relative to their default positions
3 participants