Skip to content

Commit

Permalink
Long press now works for EffectChooser
Browse files Browse the repository at this point in the history
Used template specialization similarly to OWD, works nicely now!

Closes surge-synthesizer#5980.
  • Loading branch information
mkruselj committed Mar 29, 2022
1 parent f7edfbe commit ecea701
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/surge-xt/gui/widgets/EffectChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,28 @@ void EffectChooser::mouseDown(const juce::MouseEvent &event)
{
if (event.mods.isRightButtonDown())
{
auto sge = firstListenerOfType<SurgeGUIEditor>();
createFXMenu();
}
}
}

if (sge && sge->fxMenu)
{
auto c = localPointToGlobal(getEffectRectangle(currentClicked).getBottomLeft());
void EffectChooser::createFXMenu()
{
auto sge = firstListenerOfType<SurgeGUIEditor>();

auto where = sge->frame->getLocalPoint(nullptr, c);
sge->fxMenu->menu.showMenuAsync(sge->popupMenuOptions(where));
}
}
if (sge && sge->fxMenu)
{
auto c = localPointToGlobal(getEffectRectangle(currentClicked).getBottomLeft());

auto where = sge->frame->getLocalPoint(nullptr, c);
sge->fxMenu->menu.showMenuAsync(sge->popupMenuOptions(where));
}
}

void EffectChooser::mouseUp(const juce::MouseEvent &event)
{
mouseUpLongHold(event);

if (hasDragged)
{
setMouseCursor(juce::MouseCursor::NormalCursor);
Expand Down Expand Up @@ -337,8 +344,6 @@ void EffectChooser::mouseUp(const juce::MouseEvent &event)
hasDragged = false;
repaint();
}

mouseUpLongHold(event);
}

void EffectChooser::mouseDrag(const juce::MouseEvent &event)
Expand Down
9 changes: 9 additions & 0 deletions src/surge-xt/gui/widgets/EffectChooser.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ namespace Surge
{
namespace Widgets
{
struct EffectChooser;

template <> void LongHoldMixin<EffectChooser>::onLongHold();

struct EffectChooser : public juce::Component,
public WidgetBaseMixin<EffectChooser>,
public LongHoldMixin<EffectChooser>
Expand Down Expand Up @@ -121,11 +125,16 @@ struct EffectChooser : public juce::Component,
SurgeStorage *storage{nullptr};
void setStorage(SurgeStorage *s) { storage = s; }

void createFXMenu();

std::array<std::unique_ptr<juce::Component>, n_fx_slots> slotAccOverlays;
std::unique_ptr<juce::AccessibilityHandler> createAccessibilityHandler() override;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EffectChooser);
};

template <> inline void LongHoldMixin<EffectChooser>::onLongHold() { asT()->createFXMenu(); }

} // namespace Widgets
} // namespace Surge

Expand Down

0 comments on commit ecea701

Please sign in to comment.