Skip to content

Commit

Permalink
Implement arrow cursor for waveshaper and filter type icon
Browse files Browse the repository at this point in the history
Also repaints MSEG editor on double-click and mouse up.

Closes #5109
  • Loading branch information
mkruselj committed Sep 18, 2021
1 parent 46aa953 commit 1d6fd27
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 9 deletions.
21 changes: 19 additions & 2 deletions src/surge-xt/gui/overlays/MSEGEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,13 +1683,15 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
// Lin doesn't cursor hide so this hand is bad there
setMouseCursor(juce::MouseCursor::DraggingHandCursor);
}

return;
}

void mouseDoubleClick(const juce::MouseEvent &event) override
{
auto ha = getHAxisDoubleClickArea();
auto where = event.position.toInt();

if (ha.contains(where))
{
zoomToFull();
Expand All @@ -1714,7 +1716,6 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
{
case hotzone::SEGMENT_ENDPOINT:
{

if (event.mods.isShiftDown() && h.associatedSegment >= 0)
{
Surge::MSEG::deleteSegment(ms, ms->segmentStart[h.associatedSegment]);
Expand All @@ -1723,14 +1724,20 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
{
Surge::MSEG::unsplitSegment(ms, t);
}

modelChanged();
repaint();

return;
}
case hotzone::SEGMENT_CONTROL:
{
// Reset the controlpoint to duration half value middle
// Reset the control point to duration half value middle
Surge::MSEG::resetControlPoint(ms, t);

modelChanged();
repaint();

return;
}
case hotzone::LOOP_START:
Expand All @@ -1751,16 +1758,23 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
{
Surge::MSEG::splitSegment(ms, t, v);
}

modelChanged();
repaint();

return;
}
else
{
Surge::MSEG::extendTo(ms, t, v);

modelChanged();
repaint();

return;
}
}

guaranteeCursorShown();
}

Expand All @@ -1784,6 +1798,7 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
{
lassoSelector.reset(nullptr);
}

return;
}

Expand Down Expand Up @@ -1818,6 +1833,8 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp

h.active = false;
h.dragging = false;

repaint();
}

snapGuard = nullptr;
Expand Down
35 changes: 28 additions & 7 deletions src/surge-xt/gui/widgets/MenuForDiscreteParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,38 +76,59 @@ struct MenuForDiscreteParams : public juce::Component,
LEFT,
RIGHT
} glyphLocation = LEFT;

void setDragGlyph(SurgeImage *d, int boxSize)
{
dragGlyph = d;
dragGlyphBoxSize = boxSize;
}

void setDragGlyphHover(SurgeImage *d) { dragGlyphHover = d; }
juce::Rectangle<float> glyphPosition;

void setGlyphMode(bool b) { glyphMode = b; }
juce::Rectangle<float> glyphPosition;
bool glyphMode{false};
SurgeImage *bg{nullptr}, *bghover{nullptr};

void setGlyphMode(bool b) { glyphMode = b; }
void setBackgroundDrawable(SurgeImage *d) { bg = d; }
void setHoverBackgroundDrawable(SurgeImage *d) { bghover = d; }
SurgeImage *bg{nullptr}, *bghover{nullptr};

void paint(juce::Graphics &g) override;

bool isHovered{false};
void mouseEnter(const juce::MouseEvent &e) override

void mouseEnter(const juce::MouseEvent &event) override
{
isHovered = true;
repaint();
}
void mouseExit(const juce::MouseEvent &e) override

void mouseMove(const juce::MouseEvent &event) override
{
isHovered = false;
repaint();
if (glyphMode && glyphPosition.contains(event.position))
{
setMouseCursor(juce::MouseCursor::UpDownResizeCursor);
}
else
{
setMouseCursor(juce::MouseCursor::NormalCursor);
}
}

void mouseExit(const juce::MouseEvent &event) override { endHover(); }

void endHover() override
{
isHovered = false;

if (glyphMode)
{
setMouseCursor(juce::MouseCursor::NormalCursor);
}

repaint();
}

juce::Point<int> mouseDownOrigin;
bool isDraggingGlyph{false};
float lastDragDistance{0};
Expand Down
13 changes: 13 additions & 0 deletions src/surge-xt/gui/widgets/WaveShaperSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,27 @@ struct WaveShaperSelector : public juce::Component, public WidgetBaseMixin<WaveS
void mouseMove(const juce::MouseEvent &event) override
{
bool shouldH = false;

if (labelArea.contains(event.position.toInt()))
{
shouldH = true;
setMouseCursor(juce::MouseCursor::NormalCursor);
}

if (shouldH != isLabelHovered)
{
isLabelHovered = shouldH;
repaint();
}

bool shouldWH = false;

if (waveArea.contains(event.position.toInt()))
{
shouldWH = true;
setMouseCursor(juce::MouseCursor::UpDownResizeCursor);
}

if (shouldWH != isWaveHovered)
{
isWaveHovered = shouldWH;
Expand All @@ -60,6 +71,8 @@ struct WaveShaperSelector : public juce::Component, public WidgetBaseMixin<WaveS
{
isWaveHovered = false;
isLabelHovered = false;

setMouseCursor(juce::MouseCursor::NormalCursor);
repaint();
}

Expand Down

0 comments on commit 1d6fd27

Please sign in to comment.