Skip to content

Commit

Permalink
Modify a slider handle when TempoSynced
Browse files Browse the repository at this point in the history
Surge didn't have a way to show a parameter was TempoSynced.
Now it does!

Closes surge-synthesizer#1397
  • Loading branch information
baconpaul committed Dec 5, 2019
1 parent d8a92bd commit 4e788b9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/common/gui/CSurgeSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "MouseCursorControl.h"
#include "CScalableBitmap.h"
#include "SurgeBitmaps.h"
#include <iostream>

using namespace VSTGUI;
using namespace std;
Expand Down Expand Up @@ -250,9 +251,59 @@ void CSurgeSlider::draw(CDrawContext* dc)
}

if (style & CSlider::kHorizontal)
{
pHandle->draw(dc, hrect, CPoint(0, 24 * typehy), modmode ? 0x7f : 0xff);
if( is_temposync )
{
dc->setFont(displayFont);
dc->setFontColor(CColor(80,80,100));
auto newRect = hrect;
newRect.top += 1;
newRect.left += 1;
newRect.bottom = newRect.top + 15;
newRect.right = newRect.left + 21;

auto tRect = newRect;
tRect.right = tRect.left + 11;
tRect.left += 2;

auto sRect = newRect;
sRect.left += 11;
sRect.right -= 2;
dc->drawString("T", tRect, kCenterText, true);
dc->drawString("S", sRect, kCenterText, true);

}
}
else
{
pHandle->draw(dc, hrect, CPoint(0, 28 * typehy), modmode ? 0x7f : 0xff);
if( is_temposync )
{
auto newRect = hrect;
newRect.top += 1;
newRect.left += 1;
newRect.bottom = newRect.top + 20;
newRect.right = newRect.left + 16;

dc->setFont(displayFont);
dc->setFontColor(CColor(80,80,100));

auto tRect = newRect;
tRect.bottom = tRect.top + 11;
tRect.top += 2;

auto sRect = newRect;
sRect.top += 11;
sRect.bottom -= 2;

dc->drawString("T", tRect, kCenterText, true);
dc->drawString("S", sRect, kCenterText, true);

}

}

}

// draw mod-fader
Expand Down
3 changes: 3 additions & 0 deletions src/common/gui/CSurgeSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class CSurgeSlider : public CCursorHidingControl
virtual void setValue(float val);
virtual void setBipolar(bool);

virtual void setTempoSync( bool b ) { is_temposync = b; }

void SetQuantitizedDispValue(float f);

CLASS_METHODS(CSurgeSlider, CControl)
Expand Down Expand Up @@ -93,6 +95,7 @@ class CSurgeSlider : public CCursorHidingControl
int typex, typey;
int typehx, typehy;
bool has_modulation, has_modulation_current;
bool is_temposync = false;
VSTGUI::CPoint lastpoint, sourcepoint;
float oldVal, *edit_value;
int drawcount_debug;
Expand Down
10 changes: 10 additions & 0 deletions src/common/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,8 @@ void SurgeGUIEditor::openOrRecreateEditor()
hs->setValue(p->get_value_f01());
hs->setLabel(p->get_name());
hs->setMoveRate(p->moverate);
if( p->can_temposync() )
hs->setTempoSync(p->temposync);
frame->addView(hs);
param[i] = hs;
}
Expand All @@ -1318,6 +1320,8 @@ void SurgeGUIEditor::openOrRecreateEditor()
hs->setDefaultValue(p->get_default_value_f01());
hs->setLabel(p->get_name());
hs->setMoveRate(p->moverate);
if( p->can_temposync() )
hs->setTempoSync(p->temposync);
frame->addView(hs);
param[i] = hs;

Expand Down Expand Up @@ -2093,6 +2097,12 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl* control, CButtonState b

if( this->lfodisplay )
this->lfodisplay->invalid();
auto *css = dynamic_cast<CSurgeSlider *>(control);
if( css )
{
css->setTempoSync(p->temposync);
css->invalid();
}
});
contextMenu->checkEntry(eid, p->temposync);
eid++;
Expand Down

0 comments on commit 4e788b9

Please sign in to comment.