Skip to content

Commit

Permalink
Show values in the step sequencer (#1937)
Browse files Browse the repository at this point in the history
Show values in the step sequencer when you edit with the mouse
(Still to do: Wheel). Addresses #1887
  • Loading branch information
baconpaul authored May 23, 2020
1 parent 2b179f5 commit ce15d7e
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/common/gui/CLFOGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,69 @@ void CLFOGui::drawStepSeq(VSTGUI::CDrawContext *dc, VSTGUI::CRect &maindisp, VST
dc->setFrameColor( grabMarker );
dc->drawLine( CPoint( rect_ls.left, 0), CPoint( rect_ls.left, h-margin2 ) );
dc->drawLine( CPoint( rect_le.right, 0), CPoint( rect_le.right, h-margin2 ) );

// Finally draw the drag label
if( controlstate == cs_steps && draggedStep >= 0 && draggedStep < n_stepseqsteps )
{
int prec = 3;
if( storage )
{
int detailedMode = Surge::Storage::getUserDefaultValue(storage, "highPrecisionReadouts", 0);
if( detailedMode )
{
prec = 7;
}
}

int dragX, dragY;
int dragW = 28, dragH = 12;

if( prec > 4 )
dragW = 48;

auto sr = steprect[draggedStep];
if( draggedStep < n_stepseqsteps / 2 )
{
// Draw to the right
dragX = sr.right;
}
else
{
dragX = sr.left - dragW;
}

float yTop;
if (lfodata->unipolar.val.b)
{
auto sv = std::max( ss->steps[draggedStep], 0.f );
yTop = sr.bottom - (int)(sr.getHeight() * sv );
}
else
{
yTop = sr.bottom - (int)((float)0.5f + sr.getHeight() * (0.5f + 0.5f * ss->steps[draggedStep]));
}

if( yTop > sr.getHeight() / 2 )
{
dragY = yTop - dragH;
}
else
{
dragY = yTop;
}

CRect labelR( dragX, dragY, dragX + dragW, dragY + dragH );
fillr( labelR, skin->getColor( "lfo.stepseq.valueborder", stepMarker ) );
labelR.inset( 1, 1 );
fillr( labelR, skin->getColor( "lfo.stepseq.valuebackground", kWhiteCColor ) );
dc->setFontColor( skin->getColor( "lfo.stepseq.valueforeground", stepMarker ) );
char txt[ 256 ];
sprintf( txt, "%.*f", prec, ss->steps[draggedStep] );

dc->setFont( lfoTypeFont );
labelR.left += 1;
dc->drawString(txt, labelR, VSTGUI::kLeftText, true );
}
}

// These data structures are used for mouse hit detection so have to translate them back to screen
Expand Down Expand Up @@ -801,6 +864,8 @@ CMouseEventResult CLFOGui::onMouseUp(CPoint& where, const CButtonState& buttons)
{
// onMouseMoved(where,buttons);
controlstate = cs_null;
if( lfodata->shape.val.i == ls_stepseq )
invalid();
}
return kMouseEventHandled;
}
Expand Down Expand Up @@ -867,6 +932,7 @@ CMouseEventResult CLFOGui::onMouseMoved(CPoint& where, const CButtonState& butto
{
if ((where.x > steprect[i].left) && (where.x < steprect[i].right))
{
draggedStep = i;
float f = (float)(steprect[i].bottom - where.y) / steprect[i].getHeight();

if (buttons & (kControl | kRButton)) {
Expand Down
2 changes: 2 additions & 0 deletions src/common/gui/CLFOGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class CLFOGui : public VSTGUI::CControl, public Surge::UI::SkinConsumingComponnt
bool edit_trigmask;
int controlstate;
int selectedSSrow = -1;

int draggedStep = -1;

CLASS_METHODS(CLFOGui, VSTGUI::CControl)
};

0 comments on commit ce15d7e

Please sign in to comment.