Skip to content

Commit

Permalink
Fix MSEG tooltip Y axis not refreshing (surge-synthesizer#7268)
Browse files Browse the repository at this point in the history
Fix MSEG tooltip showing by itself when changing Loop Mode
Fix certain MSEG node changing icon as if it's being clicked on, when changing Loop Mode
  • Loading branch information
mkruselj authored Oct 21, 2023
1 parent d5439c8 commit 6920190
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/surge-xt/gui/overlays/MSEGEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,8 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
if (ms->segments[i].duration > 0.01 &&
ms->segments[i].type != MSEGStorage::segment::HOLD)
{
/*
* Drop in a control point. But where and moving how?
*
* Here's some good defaults
*/
// Drop in a control point. But where and moving how?
// Here's some good defaults
bool verticalMotion = true;
bool horizontalMotion = false;
bool verticalScaleByValues = false;
Expand Down Expand Up @@ -1115,9 +1112,7 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
auto tpx = timeToPx();
auto pxt = pxToTime();

/*
* Now draw the loop region
*/
// Now draw the loop region
if (ms->loopMode != MSEGStorage::LoopMode::ONESHOT && ms->editMode != MSEGStorage::LFO)
{
int ls = (ms->loop_start >= 0 ? ms->loop_start : 0);
Expand Down Expand Up @@ -1181,8 +1176,8 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp

float pathFirstY, pathLastX, pathLastY, pathLastDef;

bool drawnLast =
false; // this slightly odd construct means we always draw beyond the last point
// this slightly odd construct means we always draw beyond the last point
bool drawnLast = false;
int priorEval = 0;

for (int q = 0; q <= drawArea.getWidth(); ++q)
Expand All @@ -1192,7 +1187,6 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
if (!drawnLast)
{
float iup = (int)up;

float fup = up - iup;
float v = Surge::MSEG::valueAt(iup, fup, 0, ms, &es, true);
float vdef = Surge::MSEG::valueAt(iup, fup, lfodata->deform.val.f, ms, &esdf, true);
Expand All @@ -1206,6 +1200,7 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
vdef = v;

int compareWith = es.lastEval;

if (up >= ms->totalDuration)
compareWith = ms->n_activeSegments - 1;

Expand All @@ -1225,15 +1220,18 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
{
addP(highlightPath, i, valpx(ms->segments[priorEval].nv1));
}

priorEval = es.lastEval;
}

if (es.lastEval == hoveredSegment)
{
bool skipThisAdd = false;

// edge case when you go exactly up to 1 evenly. See #3940
if (up < ms->segmentStart[es.lastEval] || up > ms->segmentEnd[es.lastEval])
skipThisAdd = true;

if (!hlpathUsed)
{
// We always want to hit the start
Expand All @@ -1245,8 +1243,10 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
beginP(highlightPath, i, v);
beginP(highlightPath, i, v);
}

hlpathUsed = true;
}

if (!skipThisAdd)
{
addP(highlightPath, i, v);
Expand All @@ -1266,14 +1266,17 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
addP(defpath, i, vdef);
addP(fillpath, i, v);
}

pathLastX = i;
pathLastY = v;
pathLastDef = vdef;
}

drawnLast = up > ms->totalDuration;
}

int uniLimit = uni ? -1 : 0;

addP(fillpath, pathLastX, valpx(uniLimit));
addP(fillpath, uniLimit, valpx(uniLimit));
addP(fillpath, uniLimit, pathFirstY);
Expand Down Expand Up @@ -1479,17 +1482,18 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
int sz = 13;
int offx = 0, offy = 0;
bool showValue = false;
const bool isMouseDown = (mouseDownInitiation == MOUSE_DOWN_IN_DRAW_AREA);

if (h.active)
{
offy = 1;
showValue = true;
offy = isMouseDown ? 1 : 0;
showValue = isMouseDown;
}

if (h.dragging)
{
offy = 2;
showValue = true;
showValue = isMouseDown;
}

if (h.zoneSubType == hotzone::SEGMENT_CONTROL)
Expand Down Expand Up @@ -1543,9 +1547,8 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp

g.setFont(skin->fontManager->lfoTypeFont);

float val = h.associatedSegment >= ms->n_activeSegments - 1
? ms->segments[h.associatedSegment].v0
: ms->segments[h.associatedSegment].nv1;
float val = h.specialEndpoint ? ms->segments[h.associatedSegment].nv1
: ms->segments[h.associatedSegment].v0;

std::string txt = fmt::format("X: {:.{}f}", pxt(cx), prec),
txt2 = fmt::format("Y: {:.{}f}", val, prec);
Expand Down

0 comments on commit 6920190

Please sign in to comment.