Skip to content

Commit

Permalink
A continuous control RMB (#1346)
Browse files Browse the repository at this point in the history
- Add a popup to all continous controls created by the HasEditor
  helper (which is all of them except the depth slider)
- Delegate this to the SCXTEditor class.
- Just show the value right now but also add a set to default so
  we can test edits work (they do)

Addresses #1316
  • Loading branch information
baconpaul authored Sep 18, 2024
1 parent ad4dd31 commit 1a0030d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src-ui/app/HasEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct HasEditor

template <typename T> void updateValueTooltip(const T &attachment);
template <typename W, typename A>
void setupWidgetForValueTooltip(const W &widget, const A &attachment);
void setupWidgetForValueTooltip(W *widget, const A &attachment);
};
} // namespace scxt::ui::app
#endif // SHORTCIRCUIT_HASEDITOR_H
11 changes: 10 additions & 1 deletion src-ui/app/SCXTEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ struct SCXTEditor : sst::jucegui::components::WindowPanel, juce::DragAndDropCont
return r;
}
void configureHasDiscreteMenuBuilder(sst::jucegui::components::HasDiscreteParamMenuBuilder *);
void popupMenuForContinuous(sst::jucegui::components::ContinuousParamEditor *e);

// Serialization to Client Messages
void onErrorFromEngine(const scxt::messaging::client::s2cError_t &);
Expand Down Expand Up @@ -328,7 +329,7 @@ template <typename T> inline void HasEditor::updateValueTooltip(const T &at)
}

template <typename W, typename A>
inline void HasEditor::setupWidgetForValueTooltip(const W &w, const A &a)
inline void HasEditor::setupWidgetForValueTooltip(W *w, const A &a)
{
w->onBeginEdit = [this, &slRef = *w, &atRef = *a]() {
editor->showTooltip(slRef);
Expand All @@ -344,6 +345,14 @@ inline void HasEditor::setupWidgetForValueTooltip(const W &w, const A &a)
updateValueTooltip(atRef);
};
w->onIdleHoverEnd = [this]() { editor->hideTooltip(); };
if constexpr (std::is_base_of_v<sst::jucegui::components::ContinuousParamEditor,
std::remove_pointer_t<W>>)
{
w->onPopupMenu = [this, q = juce::Component::SafePointer(w)](auto &mods) {
editor->hideTooltip();
editor->popupMenuForContinuous(q);
};
}
}
} // namespace scxt::ui::app

Expand Down
2 changes: 1 addition & 1 deletion src-ui/app/edit-screen/components/ProcessorPane.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct ProcessorPane : sst::jucegui::components::NamedPanel, HasEditor, juce::Dr
sst::jucegui::components::Labeled<sst::jucegui::components::ContinuousParamEditor>>();
auto kn = std::make_unique<T>();
kn->setSource(at.get());
setupWidgetForValueTooltip(kn, at);
setupWidgetForValueTooltip(kn.get(), at);
kn->setTitle(at->getLabel());
kn->setDescription(at->getLabel());
getContentAreaComponent()->addAndMakeVisible(*kn);
Expand Down
29 changes: 29 additions & 0 deletions src-ui/app/editor-impl/SCXTEditorMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,33 @@ void SCXTEditor::addUIThemesMenu(juce::PopupMenu &p, bool addTitle)
}
}

void SCXTEditor::popupMenuForContinuous(sst::jucegui::components::ContinuousParamEditor *e)
{
auto data = e->continuous();
if (!data)
{
SCLOG("Continuous with no data - no popup to be had");
return;
}

if (!e->isEnabled())
{
SCLOG("No menu on non-enabled widget");
return;
}

auto p = juce::PopupMenu();
p.addSectionHeader(data->getLabel());
p.addSeparator();
p.addItem(data->getValueAsString(), []() {});
p.addSeparator();
p.addItem("Set to Default", [w = juce::Component::SafePointer(e)]() {
if (!w)
return;
w->continuous()->setValueFromGUI(w->continuous()->getDefaultValue());
});

p.showMenuAsync(defaultPopupMenuOptions());
}

} // namespace scxt::ui::app
6 changes: 3 additions & 3 deletions src-ui/app/mixer-screen/components/ChannelStrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ChannelStrip::ChannelStrip(SCXTEditor *e, MixerScreen *m, int bi, BusType t)
axs->setSource(ava.get());
addAndMakeVisible(*axs);
auxAttachments[idx] = std::move(ava);
setupWidgetForValueTooltip(axs, auxAttachments[idx]);
setupWidgetForValueTooltip(axs.get(), auxAttachments[idx]);
idx++;
}
idx = 0;
Expand Down Expand Up @@ -148,14 +148,14 @@ ChannelStrip::ChannelStrip(SCXTEditor *e, MixerScreen *m, int bi, BusType t)
panKnob = std::make_unique<jcmp::Knob>();
panKnob->setSource(panAttachment.get());
addAndMakeVisible(*panKnob);
setupWidgetForValueTooltip(panKnob, panAttachment);
setupWidgetForValueTooltip(panKnob.get(), panAttachment);

vcaAttachment = std::make_unique<attachment_t>(
datamodel::pmd().asCubicDecibelAttenuation().withName("Level").withDefault(1.0), onChange,
mixer->busSendData[busIndex].level);
vcaSlider = std::make_unique<jcmp::VSlider>();
vcaSlider->setSource(vcaAttachment.get());
setupWidgetForValueTooltip(vcaSlider, vcaAttachment);
setupWidgetForValueTooltip(vcaSlider.get(), vcaAttachment);
addAndMakeVisible(*vcaSlider);

if (t != BusType::MAIN)
Expand Down
2 changes: 1 addition & 1 deletion src-ui/app/mixer-screen/components/PartEffectsPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ template <typename T> T *PartEffectsPane::attachWidgetToFloat(int pidx)
w->setEnabled(true);
}

setupWidgetForValueTooltip(w, at);
setupWidgetForValueTooltip(w.get(), at);
addAndMakeVisible(*w);

if constexpr (std::is_same_v<T, jcmp::Knob>)
Expand Down

0 comments on commit 1a0030d

Please sign in to comment.