From 4e788b9814af0f176e4681715dec334b0e31199e Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Thu, 5 Dec 2019 14:43:19 -0500 Subject: [PATCH] Modify a slider handle when TempoSynced Surge didn't have a way to show a parameter was TempoSynced. Now it does! Closes #1397 --- src/common/gui/CSurgeSlider.cpp | 51 +++++++++++++++++++++++++++++++ src/common/gui/CSurgeSlider.h | 3 ++ src/common/gui/SurgeGUIEditor.cpp | 10 ++++++ 3 files changed, 64 insertions(+) diff --git a/src/common/gui/CSurgeSlider.cpp b/src/common/gui/CSurgeSlider.cpp index 6d9ac466d7e..872c8e01c19 100644 --- a/src/common/gui/CSurgeSlider.cpp +++ b/src/common/gui/CSurgeSlider.cpp @@ -7,6 +7,7 @@ #include "MouseCursorControl.h" #include "CScalableBitmap.h" #include "SurgeBitmaps.h" +#include using namespace VSTGUI; using namespace std; @@ -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 diff --git a/src/common/gui/CSurgeSlider.h b/src/common/gui/CSurgeSlider.h index 34c50e2defa..5d705fd7496 100644 --- a/src/common/gui/CSurgeSlider.h +++ b/src/common/gui/CSurgeSlider.h @@ -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) @@ -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; diff --git a/src/common/gui/SurgeGUIEditor.cpp b/src/common/gui/SurgeGUIEditor.cpp index 1548738e1cb..16bfa07e1a3 100644 --- a/src/common/gui/SurgeGUIEditor.cpp +++ b/src/common/gui/SurgeGUIEditor.cpp @@ -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; } @@ -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; @@ -2093,6 +2097,12 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl* control, CButtonState b if( this->lfodisplay ) this->lfodisplay->invalid(); + auto *css = dynamic_cast(control); + if( css ) + { + css->setTempoSync(p->temposync); + css->invalid(); + } }); contextMenu->checkEntry(eid, p->temposync); eid++;