Skip to content

Commit

Permalink
Style override for Linear sliders
Browse files Browse the repository at this point in the history
- Theoretical Inc/Dec override support, but suffers from same bug as for
regular LnF on Inc/Dec buttons
- Fixed #51 (Ableton doesn't auto-add Button into Automation list)
- Fixed problem whereby all buttons were disabled in Read Only mode
(e.g. for loader layout)
- Fixed issue with Inc/Dec drag mode sending double slider drag
notifications
  • Loading branch information
wellis committed Oct 19, 2014
1 parent 2a7dc13 commit d7428eb
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 51 deletions.
34 changes: 24 additions & 10 deletions Juce/ScopeSyncShared/Components/BCMSlider.cpp
Expand Up @@ -287,28 +287,42 @@ bool BCMSlider::isRotary() const
|| getSliderStyle() == RotaryVerticalDrag
|| getSliderStyle() == RotaryHorizontalVerticalDrag;
}

void BCMSlider::overrideStyle()
{
if (isRotary())
{
ConfigurationManagerCallout* configurationManagerCallout = new ConfigurationManagerCallout(scopeSyncGUI.getScopeSync(), 550, 60);
configurationManagerCallout->setRotaryStyleOverridePanel(styleOverride, getName(), findColour(Slider::rotarySliderFillColourId).toString());
configurationManagerCallout->addChangeListener(this);
CallOutBox::launchAsynchronously(configurationManagerCallout, getScreenBounds(), nullptr);
}
String fillColourString;

if (getSliderStyle() == IncDecButtons)
fillColourString = findColour(TextButton::buttonColourId).toString();
else if (isRotary())
fillColourString = findColour(Slider::rotarySliderFillColourId).toString();
else
BCMParameterWidget::overrideStyle();
fillColourString = findColour(Slider::thumbColourId).toString();

ConfigurationManagerCallout* configurationManagerCallout = new ConfigurationManagerCallout(scopeSyncGUI.getScopeSync(), 550, 60);
configurationManagerCallout->setStyleOverridePanel(styleOverride, Ids::slider, getName(), fillColourString);
configurationManagerCallout->addChangeListener(this);
CallOutBox::launchAsynchronously(configurationManagerCallout, getScreenBounds(), nullptr);
}

void BCMSlider::applyLookAndFeel(bool noStyleOverride)
{
BCMWidget::applyLookAndFeel(noStyleOverride);

if (!noStyleOverride && isRotary())
if (!noStyleOverride)
{
String fillColourString = styleOverride.getProperty(Ids::fillColour);

if (fillColourString.isNotEmpty())
setColour(Slider::rotarySliderFillColourId, Colour::fromString(fillColourString));
{
if (getSliderStyle() == IncDecButtons)
setColour(TextButton::buttonColourId, Colour::fromString(fillColourString));
else if (isRotary())
setColour(Slider::rotarySliderFillColourId, Colour::fromString(fillColourString));
else
setColour(Slider::thumbColourId, Colour::fromString(fillColourString));
}
}

sendLookAndFeelChange();
}
6 changes: 6 additions & 0 deletions Juce/ScopeSyncShared/Components/BCMTextButton.cpp
Expand Up @@ -307,6 +307,9 @@ void BCMTextButton::mouseDown(const MouseEvent& event)
}
else
{
if (hasParameter())
scopeSync.beginParameterChangeGesture(getParameter());

TextButton::mouseDown(event);
}
}
Expand All @@ -325,6 +328,9 @@ void BCMTextButton::mouseUp(const MouseEvent& event)
scopeSyncGUI.getScopeSync().setParameterFromGUI(*(parameter), valueToSet);
}

if (hasParameter())
scopeSync.endParameterChangeGesture(getParameter());

TextButton::mouseUp(event);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Juce/ScopeSyncShared/Components/BCMWidget.cpp
Expand Up @@ -322,7 +322,7 @@ void BCMParameterWidget::editMappedParameter()
void BCMParameterWidget::overrideStyle()
{
ConfigurationManagerCallout* configurationManagerCallout = new ConfigurationManagerCallout(scopeSyncGUI.getScopeSync(), 550, 34);
configurationManagerCallout->setStyleOverridePanel(styleOverride, getComponentType(), parentWidget->getName());
configurationManagerCallout->setStyleOverridePanel(styleOverride, getComponentType(), parentWidget->getName(), Colours::transparentBlack.toString());
configurationManagerCallout->addChangeListener(this);
CallOutBox::launchAsynchronously(configurationManagerCallout, parentWidget->getScreenBounds(), nullptr);
}
Expand Down
17 changes: 6 additions & 11 deletions Juce/ScopeSyncShared/Configuration/ConfigurationManager.cpp
Expand Up @@ -252,23 +252,18 @@ void ConfigurationManagerCallout::setParameterPanel(ValueTree& parameter, BCMPar
configurationManagerCalloutMain->changePanel(new ParameterPanel(parameter, undoManager, paramType, scopeSync, commandManager, true));
}

void ConfigurationManagerCallout::setStyleOverridePanel(ValueTree& styleOverride, const Identifier& componentType, const String& componentName)
{
if (!(styleOverride.isValid()))
configurationManager.getConfiguration().addStyleOverride(componentType, componentName, styleOverride, -1, &undoManager);

configurationManagerCalloutMain->changePanel(new StyleOverridePanel(styleOverride, undoManager, scopeSync, commandManager, componentType, true));
}

void ConfigurationManagerCallout::setRotaryStyleOverridePanel(ValueTree& styleOverride, const String& componentName, const String& fillColour)
void ConfigurationManagerCallout::setStyleOverridePanel(ValueTree& styleOverride,
const Identifier& componentType,
const String& componentName,
const String& fillColour)
{
if (!(styleOverride.isValid()))
{
configurationManager.getConfiguration().addStyleOverride(Ids::slider, componentName, styleOverride, -1, &undoManager);
configurationManager.getConfiguration().addStyleOverride(componentType, componentName, styleOverride, -1, &undoManager);
styleOverride.setProperty(Ids::fillColour, fillColour, &undoManager);
}

configurationManagerCalloutMain->changePanel(new RotaryStyleOverridePanel(styleOverride, undoManager, scopeSync, commandManager, true));
configurationManagerCalloutMain->changePanel(new StyleOverridePanel(styleOverride, undoManager, scopeSync, commandManager, componentType, true));
}

void ConfigurationManagerCallout::paint(Graphics& g)
Expand Down
3 changes: 1 addition & 2 deletions Juce/ScopeSyncShared/Configuration/ConfigurationManager.h
Expand Up @@ -125,8 +125,7 @@ class ConfigurationManagerCallout : public Component,

void setMappingPanel(ValueTree& mapping, const Identifier& componentType, const String& componentName);
void setParameterPanel(ValueTree& parameter, BCMParameter::ParameterType paramType);
void setStyleOverridePanel(ValueTree& styleOverride, const Identifier& componentType, const String& componentName);
void setRotaryStyleOverridePanel(ValueTree& styleOverride, const String& componentName, const String& fillColour);
void setStyleOverridePanel(ValueTree& styleOverride, const Identifier& componentType, const String& componentName, const String& fillColour);

private:
ScopeSync& scopeSync;
Expand Down
28 changes: 5 additions & 23 deletions Juce/ScopeSyncShared/Configuration/ConfigurationPanel.cpp
Expand Up @@ -550,6 +550,7 @@ StyleOverridePanel::StyleOverridePanel(ValueTree& mapping, UndoManager& um,

void StyleOverridePanel::rebuildProperties()
{
String componentTypeName = Configuration::getComponentTypeName(componentType);
PropertyListBuilder props;

props.clear();
Expand All @@ -564,8 +565,6 @@ void StyleOverridePanel::rebuildProperties()

componentNames.insert(0, "- No Component -");
componentValues.insert(0, String::empty);

String componentTypeName = Configuration::getComponentTypeName(componentType);

props.add(new ChoicePropertyComponent(valueTree.getPropertyAsValue(Ids::name, &undoManager), componentTypeName + " Name", componentNames, componentValues), "Choose the "+ componentTypeName + " to override style for");
}
Expand All @@ -583,26 +582,9 @@ void StyleOverridePanel::rebuildProperties()
lookAndFeelValues.insert(0, String::empty);

props.add(new ChoicePropertyComponent(valueTree.getPropertyAsValue(Ids::lookAndFeelId, &undoManager), "LookAndFeel", lookAndFeelIds, lookAndFeelValues), "Choose the LookAndFeel to use");


if (componentType == Ids::slider)
props.add(new ComponentBackgroundColourProperty(valueTree.getPropertyAsValue(Ids::fillColour, &undoManager), "Fill Colour"), "Choose the Colour to fill this " + componentTypeName + " with");

propertyPanel.addProperties(props.components);
}

/* =========================================================================
* RotaryStyleOverridePanel
*/
RotaryStyleOverridePanel::RotaryStyleOverridePanel(ValueTree& mapping, UndoManager& um,
ScopeSync& ss, ApplicationCommandManager* acm,
bool calloutView)
: StyleOverridePanel(mapping, um, ss, acm, Ids::slider, calloutView)
{
rebuildProperties();
}

void RotaryStyleOverridePanel::rebuildProperties()
{
PropertyListBuilder props;

props.clear();
props.add(new ComponentBackgroundColourProperty(valueTree.getPropertyAsValue(Ids::fillColour, &undoManager), "Fill Colour"), "Choose the Colour to fill this Rotary Slider with");
propertyPanel.addProperties(props.components);
}
16 changes: 12 additions & 4 deletions Juce/ScopeSyncShared/Core/ScopeSync.cpp
Expand Up @@ -207,8 +207,12 @@ void ScopeSync::beginParameterChangeGesture(BCMParameter* parameter)
{
#ifndef __DLL_EFFECT__
int hostIdx = parameter->getHostIdx();
pluginProcessor->beginParameterChangeGesture(hostIdx);
changingParams.setBit(hostIdx);

if (!changingParams[hostIdx])
{
pluginProcessor->beginParameterChangeGesture(hostIdx);
changingParams.setBit(hostIdx);
}
#else
parameter->setAffectedByUI(true);
#endif // __DLL_EFFECT__
Expand All @@ -221,8 +225,12 @@ void ScopeSync::endParameterChangeGesture(BCMParameter* parameter)
{
#ifndef __DLL_EFFECT__
int hostIdx = parameter->getHostIdx();
pluginProcessor->endParameterChangeGesture(hostIdx);
changingParams.clearBit(hostIdx);

if (changingParams[hostIdx])
{
pluginProcessor->endParameterChangeGesture(hostIdx);
changingParams.clearBit(hostIdx);
}
#else
parameter->setAffectedByUI(false);
#endif // __DLL_EFFECT__
Expand Down
11 changes: 11 additions & 0 deletions Juce/ScopeSyncShared/Core/ScopeSyncGUI.cpp
Expand Up @@ -426,6 +426,17 @@ void ScopeSyncGUI::getAllCommands(Array<CommandID>& commands)

commands.addArray (ids, numElementsInArray(ids));
}
else
{
const CommandID ids[] = { CommandIDs::snapshot,
CommandIDs::showUserSettings,
CommandIDs::chooseConfiguration
};

commands.addArray (ids, numElementsInArray(ids));
}


}

void ScopeSyncGUI::getCommandInfo(CommandID commandID, ApplicationCommandInfo& result)
Expand Down
Binary file modified Scope DLL/ScopeSync.dll
Binary file not shown.
Binary file modified VST Plugin/ScopeSyncVST-x64.dll
Binary file not shown.
Binary file modified VST Plugin/ScopeSyncVST-x64.vst3
Binary file not shown.
Binary file modified VST Plugin/ScopeSyncVST.dll
Binary file not shown.
Binary file modified VST Plugin/ScopeSyncVST.vst3
Binary file not shown.

0 comments on commit d7428eb

Please sign in to comment.