Skip to content

Commit 26ea8bf

Browse files
committed
Fix libraries and paths not updating, add toggle to enable Gem
1 parent b6c2b14 commit 26ea8bf

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

Source/Dialogs/PathsSettingsPanel.h

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ class SearchPathPanel final : public Component
273273
paths.clear();
274274

275275
for (auto& child : SettingsFile::getInstance()->getProperty<VarArray>("paths")) {
276-
paths.add(child);
276+
auto path = child.toString();
277+
if(path.isNotEmpty()) paths.add(path);
277278
}
278279

279280
listBox.updateContent();
@@ -508,7 +509,6 @@ class LibraryLoadPanel final : public Component
508509
auto [x, newWidth] = getContentXAndWidth();
509510

510511
if (rowIsSelected) {
511-
512512
bool const roundTop = rowNumber == 0;
513513
Path p;
514514
p.addRoundedRectangle(x, 0.0f, newWidth, height, Corners::largeCornerRadius, Corners::largeCornerRadius, roundTop, roundTop, false, false);
@@ -574,7 +574,8 @@ class LibraryLoadPanel final : public Component
574574
librariesToLoad.clear();
575575

576576
for (auto& child : SettingsFile::getInstance()->getProperty<VarArray>("libraries")) {
577-
librariesToLoad.addIfNotAlreadyThere(child.toString());
577+
auto library = child.toString();
578+
if(library.isNotEmpty()) librariesToLoad.add(library);
578579
}
579580

580581
listBox.updateContent();
@@ -681,20 +682,47 @@ class LibraryLoadPanel final : public Component
681682
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LibraryLoadPanel)
682683
};
683684

685+
class EnableGemToggle : public PropertiesPanel::BoolComponent
686+
{
687+
public:
688+
EnableGemToggle() : PropertiesPanel::BoolComponent("Enable GEM", Value(), {"No", "Yes"})
689+
{
690+
toggleStateValue.referTo(SettingsFile::getInstance()->getPropertyAsValue("enable_gem"));
691+
}
692+
693+
private:
694+
void paint(Graphics& g) override
695+
{
696+
auto b = getLocalBounds().reduced(2);
697+
StackShadow::drawShadowForRect(g, b.reduced(3), 8, Corners::largeCornerRadius, 0.4f);
698+
699+
g.setColour(PlugDataColours::panelForegroundColour);
700+
g.fillRoundedRectangle(b.toFloat(), Corners::largeCornerRadius);
701+
702+
g.setColour(PlugDataColours::toolbarOutlineColour);
703+
g.drawRoundedRectangle(b.toFloat(), Corners::largeCornerRadius, 1.0f);
704+
705+
PropertiesPanel::BoolComponent::paint(g);
706+
}
707+
};
708+
684709
class PathsSettingsPanel final : public SettingsDialogPanel
685710
, public ComponentListener {
686711
public:
687712
PathsSettingsPanel()
688713
{
689714
container.addAndMakeVisible(searchPathsPanel);
690715
container.addAndMakeVisible(libraryLoadPanel);
716+
container.addAndMakeVisible(enableGemToggle);
691717

692718
searchPathsPanel.onChange = [this] {
693719
updateBounds();
720+
SettingsFile::getInstance()->triggerSettingsChange("paths");
694721
};
695722

696723
libraryLoadPanel.onChange = [this] {
697724
updateBounds();
725+
SettingsFile::getInstance()->triggerSettingsChange("libraries");
698726
};
699727

700728
container.setVisible(true);
@@ -709,7 +737,8 @@ class PathsSettingsPanel final : public SettingsDialogPanel
709737
private:
710738
void updateBounds()
711739
{
712-
searchPathsPanel.setSize(getWidth(), 96.0f + (searchPathsPanel.getNumRows() + 1) * 32.0f);
740+
enableGemToggle.setBounds(getLocalBounds().withTrimmedTop(4).removeFromTop(50).reduced(40, 8));
741+
searchPathsPanel.setBounds(0, 46, getWidth(), 96.0f + (searchPathsPanel.getNumRows() + 1) * 32.0f);
713742
libraryLoadPanel.setBounds(libraryLoadPanel.getX(), searchPathsPanel.getBottom() + 4.0f, getWidth(), 52.0f + (libraryLoadPanel.getNumRows() + 1) * 32.0f);
714743

715744
container.setBounds(getLocalBounds().getUnion(searchPathsPanel.getBounds()).getUnion(libraryLoadPanel.getBounds()));
@@ -721,6 +750,7 @@ class PathsSettingsPanel final : public SettingsDialogPanel
721750
updateBounds();
722751
}
723752

753+
EnableGemToggle enableGemToggle;
724754
SearchPathPanel searchPathsPanel;
725755
LibraryLoadPanel libraryLoadPanel;
726756

Source/Pd/Library.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ class Library final : public FileSystemWatcher::Listener
9494
ProjectInfo::appDataDir.getChildFile("Abstractions"),
9595
ProjectInfo::appDataDir.getChildFile("Externals"),
9696
ProjectInfo::appDataDir.getChildFile("Extra").getChildFile("else"),
97-
ProjectInfo::appDataDir.getChildFile("Extra").getChildFile("Gem"),
9897
ProjectInfo::appDataDir.getChildFile("Extra") };
9998

10099
static inline StringArray objectOrigins = { "vanilla", "ELSE", "cyclone", "Gem", "heavylib", "pdlua", "MERDA" };

Source/PluginProcessor.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,6 @@ void PluginProcessor::updateSearchPaths()
549549

550550
// Load startup libraries that the user defined in settings
551551
for (auto library : librariesTree) {
552-
553552
auto const libName = library.toString();
554553
// Load the library: this must be done after updating paths
555554
// If the library is already loaded, it will return true
@@ -559,6 +558,11 @@ void PluginProcessor::updateSearchPaths()
559558
}
560559
}
561560

561+
if(SettingsFile::getInstance()->getProperty<bool>("enable_gem")) {
562+
libpd_add_to_search_path(ProjectInfo::appDataDir.getChildFile("Abstractions").getChildFile("Gem").getFullPathName().toRawUTF8());
563+
loadLibrary("Gem");
564+
}
565+
562566
unlockAudioThread();
563567
}
564568

@@ -776,6 +780,13 @@ bool PluginProcessor::isBusesLayoutSupported(BusesLayout const& layouts) const
776780
return ninch <= 32 && noutch <= 32;
777781
}
778782

783+
void PluginProcessor::settingsChanged(String const& name, var const& value)
784+
{
785+
if(name == "paths" || name == "libraries" || name == "enable_gem") {
786+
updateSearchPaths();
787+
}
788+
}
789+
779790
void PluginProcessor::settingsFileReloaded()
780791
{
781792
auto const newTheme = settingsFile->getProperty<String>("theme");

Source/PluginProcessor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class PluginProcessor final : public AudioProcessor
127127
return nbus > 0;
128128
}
129129

130+
void settingsChanged(String const& name, var const& value) override;
130131
void settingsFileReloaded() override;
131132

132133
static bool initialiseFilesystem();

Source/Utility/SettingsFile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ class SettingsFile final
164164
{ "hvcc_mode", var(false) },
165165
{ "heavy_state", var(new DynamicObject()) },
166166
{ "touch_mode", var(false) },
167+
{ "enable_gem", var(false) },
167168
{ "keymap", var("") },
168169
{ "last_welcome_panel", var(0) },
169170
{ "active_themes", var(Array<var> { "light", "dark" }) },

0 commit comments

Comments
 (0)