diff --git a/Editor/foleys_PropertiesEditor.cpp b/Editor/foleys_PropertiesEditor.cpp index 993775ef..37d383ee 100644 --- a/Editor/foleys_PropertiesEditor.cpp +++ b/Editor/foleys_PropertiesEditor.cpp @@ -175,10 +175,15 @@ juce::ValueTree& PropertiesEditor::getNodeToEdit() void PropertiesEditor::createNewClass() { static juce::String editorID { "styleClass" }; +#if JUCE_VERSION > 0x60008 + auto iconType = juce::MessageBoxIconType::QuestionIcon; +#else + auto iconType = juce::AlertWindow::QuestionIcon; +#endif classNameInput = std::make_unique (TRANS ("New style class"), TRANS ("Enter a name:"), - juce::MessageBoxIconType::QuestionIcon, + iconType, this); classNameInput->addTextEditor (editorID, "class"); classNameInput->addButton (TRANS ("Cancel"), 0); diff --git a/Editor/foleys_StyleBoolPropertyComponent.cpp b/Editor/foleys_StyleBoolPropertyComponent.cpp index 624432a6..94984df7 100644 --- a/Editor/foleys_StyleBoolPropertyComponent.cpp +++ b/Editor/foleys_StyleBoolPropertyComponent.cpp @@ -68,9 +68,14 @@ void StyleBoolPropertyComponent::refresh() if (auto* toggle = dynamic_cast(editor.get())) { if (node == inheritedFrom) + { toggle->getToggleStateValue().referTo (node.getPropertyAsValue (property, &builder.getUndoManager())); + } else + { + toggle->getToggleStateValue().referTo (toggle->getToggleStateValue()); toggle->setToggleState (value, juce::dontSendNotification); + } } repaint(); diff --git a/Editor/foleys_StyleChoicePropertyComponent.cpp b/Editor/foleys_StyleChoicePropertyComponent.cpp index 6785826b..374ba320 100644 --- a/Editor/foleys_StyleChoicePropertyComponent.cpp +++ b/Editor/foleys_StyleChoicePropertyComponent.cpp @@ -97,9 +97,14 @@ void StyleChoicePropertyComponent::refresh() if (auto* combo = dynamic_cast(editor.get())) { if (node == inheritedFrom) + { proxy.referTo (node.getPropertyAsValue (property, &builder.getUndoManager())); + } else + { + proxy.referTo (proxy); combo->setText (value.toString(), juce::dontSendNotification); + } } repaint(); diff --git a/Editor/foleys_StyleColourPropertyComponent.cpp b/Editor/foleys_StyleColourPropertyComponent.cpp index 7204a69d..a0ebaf68 100644 --- a/Editor/foleys_StyleColourPropertyComponent.cpp +++ b/Editor/foleys_StyleColourPropertyComponent.cpp @@ -133,6 +133,7 @@ void StyleColourPropertyComponent::refresh() if (value.isVoid()) getLookAndFeelColourFallback(); + label->getTextValue().referTo (label->getTextValue()); label->setText (value.toString(), juce::dontSendNotification); } } diff --git a/Editor/foleys_StyleGradientPropertyComponent.cpp b/Editor/foleys_StyleGradientPropertyComponent.cpp index 4ff5b29a..4ec4f826 100644 --- a/Editor/foleys_StyleGradientPropertyComponent.cpp +++ b/Editor/foleys_StyleGradientPropertyComponent.cpp @@ -97,6 +97,7 @@ void StyleGradientPropertyComponent::refresh() } else { + label->getTextValue().referTo (label->getTextValue()); label->setText (value.toString(), juce::dontSendNotification); } } diff --git a/Editor/foleys_StyleTextPropertyComponent.cpp b/Editor/foleys_StyleTextPropertyComponent.cpp index 31a81628..04b87f93 100644 --- a/Editor/foleys_StyleTextPropertyComponent.cpp +++ b/Editor/foleys_StyleTextPropertyComponent.cpp @@ -68,9 +68,14 @@ void StyleTextPropertyComponent::refresh() if (auto* label = dynamic_cast(editor.get())) { if (node == inheritedFrom) + { label->getTextValue().referTo (node.getPropertyAsValue (property, &builder.getUndoManager())); + } else + { + label->getTextValue().referTo (label->getTextValue()); label->setText (value.toString(), juce::dontSendNotification); + } } repaint(); diff --git a/Editor/foleys_ToolBox.cpp b/Editor/foleys_ToolBox.cpp index 874596dc..d7b40b09 100644 --- a/Editor/foleys_ToolBox.cpp +++ b/Editor/foleys_ToolBox.cpp @@ -379,6 +379,9 @@ void ToolBox::updateToolboxPosition() void ToolBox::setLastLocation(juce::File file) { + if (file.getFullPathName().isEmpty()) + return; + if (file.isDirectory()) file = file.getChildFile ("magic.xml"); diff --git a/General/foleys_MagicJUCEFactories.cpp b/General/foleys_MagicJUCEFactories.cpp index a152f54a..75793fb6 100644 --- a/General/foleys_MagicJUCEFactories.cpp +++ b/General/foleys_MagicJUCEFactories.cpp @@ -413,6 +413,30 @@ class LabelItem : public GuiItem label.setEditable (getProperty (pEditable)); + auto parameterName = getProperty (IDs::parameter).toString(); + if (parameterName.isNotEmpty()) + { + auto* parameter = getMagicState().getParameter (parameterName); + if (parameter) + { + label.setEditable (true); + attachment = std::make_unique( + *parameter, + [&, parameter](float value) + { + auto normalised = parameter->convertTo0to1 (value); + label.setText (parameter->getText (normalised, 0), + juce::dontSendNotification); + }); + label.onTextChange = [&, parameter] + { + auto denormalised = parameter->convertFrom0to1 (parameter->getValueForText (label.getText())); + attachment->setValueAsCompleteGesture (denormalised); + }; + attachment->sendInitialUpdate(); + } + } + auto propertyPath = getProperty (pValue).toString(); if (propertyPath.isNotEmpty()) label.getTextValue().referTo (getMagicState().getPropertyAsValue (propertyPath)); @@ -425,6 +449,7 @@ class LabelItem : public GuiItem props.push_back ({ configNode, pJustification, SettableProperty::Choice, {}, magicBuilder.createChoicesMenuLambda (getAllKeyNames (makeJustificationsChoices())) }); props.push_back ({ configNode, pFontSize, SettableProperty::Number, {}, {} }); props.push_back ({ configNode, pEditable, SettableProperty::Toggle, {}, {} }); + props.push_back ({ configNode, IDs::parameter, SettableProperty::Choice, {}, magicBuilder.createParameterMenuLambda() }); props.push_back ({ configNode, pValue, SettableProperty::Choice, {}, magicBuilder.createPropertiesMenuLambda() }); return props; } @@ -435,7 +460,8 @@ class LabelItem : public GuiItem } private: - juce::Label label; + juce::Label label; + std::unique_ptr attachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LabelItem) }; diff --git a/README.md b/README.md index 7b09bfdf..45adfb66 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,22 @@ The `foleys::MagicProcessor` takes care of saving and restoring the parameters a You can add your own values to the ValueTree in the `magicState`. There is a callback after restoring that you can override, in case you need to do some additional action. +Additionally to saving the values in the plugin state you can have settings across all instances of your plugin. +To use that you need to setup the path to a file. After that the settings are synchronised in the +settings of the magicState: +``` +// in constructor +magicState.setApplicationSettingsFile (juce::File::getSpecialLocation (juce::File::userApplicationDataDirectory) + .getChildFile (ProjectInfo::companyName) + .getChildFile (ProjectInfo::projectName + juce::String (".settings"))); + +// use it like +presetNode = magicState.getSettings().getOrCreateChildWithName ("presets", nullptr); +presetNode.setProperty ("foo", 100, nullptr); +``` + +Other than the juce::ApplicationSettings this is not a flat list but can deal with hierarchical data in form of ValueTrees. +PluginGuiMagic will deal with interprocess safety and update if the file has changed. Bake in the xml --------------- diff --git a/VERSION.md b/VERSION.md index 16fda3f2..c8c1b10d 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1,9 +1,16 @@ PluginGuiMagic - Versions history ================================ -1.3.4 +1.3.5 ----- +- Fixed AlertWindow::IconType to a backward compatible version +- Add ParameterAttachment for Label +- Added a fix when undo after a edit-drag operation + +1.3.4 - 01.08.2021 +------------------ + - Removed modal loops (needed for JUCE 6.0.9) - Added PopupMenu background and colours in ComboBox for all shipped LookAndFeels - Made Tooltip colours configurable diff --git a/foleys_gui_magic.h b/foleys_gui_magic.h index 2c066860..4e5914ec 100644 --- a/foleys_gui_magic.h +++ b/foleys_gui_magic.h @@ -37,7 +37,7 @@ ID: foleys_gui_magic vendor: Foleys Finest Audio - version: 1.3.3 + version: 1.3.5 name: Foleys GUI magic description: This module allows to create GUI with a drag and drop editor dependencies: juce_core, juce_audio_basics, juce_audio_devices, juce_audio_formats,