-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Effect Button Parameters #281
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
054dc9d
Implement switch type parameters
badescunicu 51f93f7
Create a base class for EffectParameterSlot and EffectButtonParameter…
badescunicu 69afb58
Move updated() signal to EffectParameterSlotBase
badescunicu 3cf5afe
Use EffectParameterSlotBasePointer inside WEffectParameter
badescunicu c3ed5e9
Display labels for button parameters; also create a base class for WE…
badescunicu e51f379
Fix DOM element's name (Parameters --> ButtonParameters)
badescunicu 9fd86c4
Set kEffectDebugOutput to false
badescunicu 829be5d
Remove ASCII art from headers
badescunicu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#include <QtDebug> | ||
|
||
#include "controleffectknob.h" | ||
#include "effects/effectbuttonparameterslot.h" | ||
#include "controlobject.h" | ||
#include "controlpushbutton.h" | ||
|
||
EffectButtonParameterSlot::EffectButtonParameterSlot(const unsigned int iRackNumber, | ||
const unsigned int iChainNumber, | ||
const unsigned int iSlotNumber, | ||
const unsigned int iParameterNumber) | ||
: EffectParameterSlotBase(iRackNumber, iChainNumber, iSlotNumber, | ||
iParameterNumber) { | ||
QString itemPrefix = formatItemPrefix(iParameterNumber); | ||
m_pControlLoaded = new ControlObject( | ||
ConfigKey(m_group, itemPrefix + QString("_loaded"))); | ||
m_pControlLinkType = new ControlPushButton( | ||
ConfigKey(m_group, itemPrefix + QString("_link_type"))); | ||
m_pControlLinkType->setButtonMode(ControlPushButton::TOGGLE); | ||
m_pControlLinkType->setStates(EffectManifestParameter::NUM_LINK_TYPES); | ||
m_pControlValue = new ControlPushButton( | ||
ConfigKey(m_group, itemPrefix)); | ||
m_pControlValue->setButtonMode(ControlPushButton::POWERWINDOW); | ||
m_pControlType = new ControlObject( | ||
ConfigKey(m_group, itemPrefix + QString("_type"))); | ||
|
||
connect(m_pControlLinkType, SIGNAL(valueChanged(double)), | ||
this, SLOT(slotLinkType(double))); | ||
connect(m_pControlValue, SIGNAL(valueChanged(double)), | ||
this, SLOT(slotValueChanged(double))); | ||
|
||
// Read-only controls. | ||
m_pControlType->connectValueChangeRequest( | ||
this, SLOT(slotValueType(double)), Qt::AutoConnection); | ||
m_pControlLoaded->connectValueChangeRequest( | ||
this, SLOT(slotLoaded(double)), Qt::AutoConnection); | ||
|
||
clear(); | ||
} | ||
|
||
EffectButtonParameterSlot::~EffectButtonParameterSlot() { | ||
//qDebug() << debugString() << "destroyed"; | ||
delete m_pControlValue; | ||
} | ||
|
||
void EffectButtonParameterSlot::loadEffect(EffectPointer pEffect) { | ||
//qDebug() << debugString() << "loadEffect" << (pEffect ? pEffect->getManifest().name() : "(null)"); | ||
clear(); | ||
if (pEffect) { | ||
m_pEffect = pEffect; | ||
// Returns null if it doesn't have a parameter for that number | ||
m_pEffectParameter = pEffect->getButtonParameter(m_iParameterNumber); | ||
|
||
if (m_pEffectParameter) { | ||
//qDebug() << debugString() << "Loading effect parameter" << m_pEffectParameter->name(); | ||
double dValue = m_pEffectParameter->getValue().toDouble(); | ||
double dMinimum = m_pEffectParameter->getMinimum().toDouble(); | ||
double dMinimumLimit = dMinimum; // TODO(rryan) expose limit from EffectParameter | ||
double dMaximum = m_pEffectParameter->getMaximum().toDouble(); | ||
double dMaximumLimit = dMaximum; // TODO(rryan) expose limit from EffectParameter | ||
double dDefault = m_pEffectParameter->getDefault().toDouble(); | ||
|
||
if (dValue > dMaximum || dValue < dMinimum || | ||
dMinimum < dMinimumLimit || dMaximum > dMaximumLimit || | ||
dDefault > dMaximum || dDefault < dMinimum) { | ||
qWarning() << debugString() << "WARNING: EffectParameter does not satisfy basic sanity checks."; | ||
} | ||
|
||
// qDebug() << debugString() | ||
// << QString("Val: %1 Min: %2 MinLimit: %3 Max: %4 MaxLimit: %5 Default: %6") | ||
// .arg(dValue).arg(dMinimum).arg(dMinimumLimit).arg(dMaximum).arg(dMaximumLimit).arg(dDefault); | ||
|
||
m_pControlValue->set(dValue); | ||
m_pControlValue->setDefaultValue(dDefault); | ||
EffectManifestParameter::ControlHint type = m_pEffectParameter->getControlHint(); | ||
// TODO(rryan) expose this from EffectParameter | ||
m_pControlType->setAndConfirm(static_cast<double>(type)); | ||
// Default loaded parameters to loaded and unlinked | ||
m_pControlLoaded->setAndConfirm(1.0); | ||
m_pControlLinkType->set(m_pEffectParameter->getLinkType()); | ||
|
||
connect(m_pEffectParameter, SIGNAL(valueChanged(QVariant)), | ||
this, SLOT(slotParameterValueChanged(QVariant))); | ||
} | ||
|
||
// Update the newly loaded parameter to match the current chain | ||
// superknob if it is linked. | ||
onChainParameterChanged(m_dChainParameter); | ||
} | ||
emit(updated()); | ||
} | ||
|
||
void EffectButtonParameterSlot::clear() { | ||
//qDebug() << debugString() << "clear"; | ||
if (m_pEffectParameter) { | ||
m_pEffectParameter->disconnect(this); | ||
m_pEffectParameter = NULL; | ||
} | ||
|
||
m_pEffect.clear(); | ||
m_pControlLoaded->setAndConfirm(0.0); | ||
m_pControlValue->set(0.0); | ||
m_pControlValue->setDefaultValue(0.0); | ||
m_pControlType->setAndConfirm(0.0); | ||
m_pControlLinkType->set(EffectManifestParameter::LINK_NONE); | ||
emit(updated()); | ||
} | ||
|
||
void EffectButtonParameterSlot::slotParameterValueChanged(QVariant value) { | ||
//qDebug() << debugString() << "slotParameterValueChanged" << value.toDouble(); | ||
m_pControlValue->set(value.toDouble()); | ||
} | ||
|
||
void EffectButtonParameterSlot::onChainParameterChanged(double parameter) { | ||
m_dChainParameter = parameter; | ||
if (m_pEffectParameter != NULL) { | ||
switch (m_pEffectParameter->getLinkType()) { | ||
case EffectManifestParameter::LINK_INVERSE: | ||
parameter = 1.0 - parameter; | ||
// Intentional fall-through. | ||
case EffectManifestParameter::LINK_LINKED: | ||
if (parameter < 0.0 || parameter > 1.0) { | ||
return; | ||
} | ||
m_pControlValue->setParameterFrom(parameter, NULL); | ||
break; | ||
case EffectManifestParameter::LINK_NONE: | ||
default: | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#ifndef EFFECTBUTTONPARAMETERSLOT_H | ||
#define EFFECTBUTTONPARAMETERSLOT_H | ||
|
||
#include <QObject> | ||
#include <QVariant> | ||
#include <QString> | ||
|
||
#include "util.h" | ||
#include "controlobject.h" | ||
#include "effects/effect.h" | ||
#include "effects/effectparameterslotbase.h" | ||
|
||
class ControlObject; | ||
class ControlPushButton; | ||
|
||
class EffectButtonParameterSlot; | ||
typedef QSharedPointer<EffectButtonParameterSlot> EffectButtonParameterSlotPointer; | ||
|
||
class EffectButtonParameterSlot : public EffectParameterSlotBase { | ||
Q_OBJECT | ||
public: | ||
EffectButtonParameterSlot(const unsigned int iRackNumber, | ||
const unsigned int iChainNumber, | ||
const unsigned int iSlotNumber, | ||
const unsigned int iParameterNumber); | ||
virtual ~EffectButtonParameterSlot(); | ||
|
||
static QString formatItemPrefix(const unsigned int iParameterNumber) { | ||
return QString("button_parameter%1").arg(iParameterNumber + 1); | ||
} | ||
|
||
// Load the parameter of the given effect into this EffectButtonParameterSlot | ||
void loadEffect(EffectPointer pEffect); | ||
|
||
void onChainParameterChanged(double parameter); | ||
|
||
private slots: | ||
// Solely for handling control changes | ||
void slotParameterValueChanged(QVariant value); | ||
|
||
private: | ||
QString debugString() const { | ||
return QString("EffectButtonParameterSlot(%1,%2)").arg(m_group).arg(m_iParameterNumber); | ||
} | ||
|
||
// Clear the currently loaded effect | ||
void clear(); | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// Controls exposed to the rest of Mixxx | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
ControlPushButton* m_pControlValue; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(EffectButtonParameterSlot); | ||
}; | ||
|
||
#endif // EFFECTBUTTONPARAMETERSLOT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not use ASCII-arts in Mixxx code