Skip to content

Commit

Permalink
Use OS DarkMode from sst; Use strnatcmp from sst (#5887)
Browse files Browse the repository at this point in the history
sst_plugininfra provides an isDarkMode API (currently only
returning correct values on macOS). This diff does the following

1. Move the menu colors to either follow OS or follow skin
2. Since that involves an upgrade to sstplugininfra, also fix
the strnatcmp dependency, addressing #5868
  • Loading branch information
baconpaul authored Feb 13, 2022
1 parent e0065b4 commit 3e966c5
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 273 deletions.
9 changes: 0 additions & 9 deletions libs/strnatcmp/CMakeLists.txt

This file was deleted.

22 changes: 0 additions & 22 deletions libs/strnatcmp/README.md

This file was deleted.

185 changes: 0 additions & 185 deletions libs/strnatcmp/strnatcmp.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions libs/strnatcmp/strnatcmp.h

This file was deleted.

3 changes: 1 addition & 2 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ project(surge-common)
surge_add_lib_subdirectory(airwindows)
surge_add_lib_subdirectory(eurorack)
surge_add_lib_subdirectory(fmt)
surge_add_lib_subdirectory(strnatcmp)
surge_add_lib_subdirectory(oddsound-mts)
if(MINGW)
set(HAVE_VISIBILITY 0 CACHE INTERNAL "Force-disable libsamplerate's visibility check on MinGW")
Expand Down Expand Up @@ -323,10 +322,10 @@ target_link_libraries(${PROJECT_NAME}
sst-plugininfra
sst-plugininfra::filesystem
sst-plugininfra::tinyxml
sst-plugininfra::strnatcmp

surge::oddsound-mts
surge::sqlite
surge::strnatcmp
surge-common-binary
tuning-library
PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion src/common/ModulatorPresetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "SurgeStorage.h"
#include "tinyxml/tinyxml.h"
#include "DebugHelpers.h"
#include "strnatcmp.h"
#include "sst/plugininfra/strnatcmp.h"

namespace Surge
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/SkinModelImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <cstring>
#include "resource.h"
#include "SkinColors.h"
#include "strnatcmp.h"
#include "sst/plugininfra/strnatcmp.h"

/*
* This file implements the innards of the Connector class and the SkinColor class
Expand Down
2 changes: 1 addition & 1 deletion src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "UserDefaults.h"
#include "version.h"

#include "strnatcmp.h"
#include "sst/plugininfra/strnatcmp.h"
#include "libMTSClient.h"
#include "FxPresetAndClipboardManager.h"
#include "ModulatorPresetManager.h"
Expand Down
2 changes: 1 addition & 1 deletion src/surge-testrunner/UnitTestsINFRA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "QuadFilterUnit.h"
#include "MemoryPool.h"

#include "strnatcmp.h"
#include "sst/plugininfra/strnatcmp.h"

#include "catch2/catch2.hpp"

Expand Down
8 changes: 3 additions & 5 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3657,11 +3657,9 @@ juce::PopupMenu SurgeGUIEditor::makeSkinMenu(const juce::Point<int> &where)
Surge::Storage::updateUserDefaultValue(&(synth->storage), Surge::Storage::MenuLightness, i);
juceEditor->surgeLF->onSkinChanged();
};
skinSubMenu.addItem(Surge::GUI::toOSCaseForMenu("Always Dark Menus"), true, menuMode == 0,
[resetMenuTo]() { resetMenuTo(0); });
skinSubMenu.addItem(Surge::GUI::toOSCaseForMenu("Always Light Menus"), true, menuMode == 1,
[resetMenuTo]() { resetMenuTo(1); });
skinSubMenu.addItem(Surge::GUI::toOSCaseForMenu("Menus From Skin"), true, menuMode == 2,
skinSubMenu.addItem(Surge::GUI::toOSCaseForMenu("Menu Follows OS Light/Dark Mode"), true,
menuMode == 1, [resetMenuTo]() { resetMenuTo(1); });
skinSubMenu.addItem(Surge::GUI::toOSCaseForMenu("Menus Follows Skin"), true, menuMode == 2,
[resetMenuTo]() { resetMenuTo(2); });
skinSubMenu.addSeparator();

Expand Down
32 changes: 18 additions & 14 deletions src/surge-xt/gui/SurgeJUCELookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <juce_audio_utils/juce_audio_utils.h>
#include "UserDefaults.h"
#include "sst/plugininfra/misc_platform.h"

// here and only here we using namespace juce so I can copy and override stuff from v4 easily
using namespace juce;
Expand Down Expand Up @@ -50,21 +51,24 @@ void SurgeJUCELookAndFeel::onSkinChanged()
menuMode = Surge::Storage::getUserDefaultValue(storage, Surge::Storage::MenuLightness, 2);
if (menuMode == 1)
{
setColour(PopupMenu::backgroundColourId, Colour(255, 255, 255));
setColour(PopupMenu::highlightedBackgroundColourId, Colour(220, 220, 230));
setColour(PopupMenu::textColourId, juce::Colours::black);
setColour(PopupMenu::headerTextColourId, juce::Colours::black);
setColour(PopupMenu::highlightedTextColourId, juce::Colour(0, 0, 40));
}
else if (menuMode == 0) // FIXME = mode 2 is follow skin
{
setColour(PopupMenu::backgroundColourId, Colour(48, 48, 48));
setColour(PopupMenu::highlightedBackgroundColourId, Colour(96, 96, 96));
setColour(PopupMenu::textColourId, juce::Colours::white);
setColour(PopupMenu::headerTextColourId, juce::Colours::white);
setColour(PopupMenu::highlightedTextColourId, juce::Colour(240, 240, 250));
if (sst::plugininfra::misc_platform::isDarkMode())
{
setColour(PopupMenu::backgroundColourId, Colour(48, 48, 48));
setColour(PopupMenu::highlightedBackgroundColourId, Colour(96, 96, 96));
setColour(PopupMenu::textColourId, juce::Colours::white);
setColour(PopupMenu::headerTextColourId, juce::Colours::white);
setColour(PopupMenu::highlightedTextColourId, juce::Colour(240, 240, 250));
}
else
{
setColour(PopupMenu::backgroundColourId, Colour(255, 255, 255));
setColour(PopupMenu::highlightedBackgroundColourId, Colour(220, 220, 230));
setColour(PopupMenu::textColourId, juce::Colours::black);
setColour(PopupMenu::headerTextColourId, juce::Colours::black);
setColour(PopupMenu::highlightedTextColourId, juce::Colour(0, 0, 40));
}
}
else if (menuMode == 2)
else
{
setColour(PopupMenu::backgroundColourId, skin->getColor(Colors::PopupMenu::Background));
setColour(PopupMenu::highlightedBackgroundColourId,
Expand Down

0 comments on commit 3e966c5

Please sign in to comment.