1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-01 03:10:06 +00:00

Projucer: Selected colour scheme is now stored and recalled. Multiple fixes for unreadable text in the GUI editor

This commit is contained in:
ed 2017-05-08 17:20:44 +01:00
parent 359238f0ed
commit cf0e97fcc7
13 changed files with 151 additions and 69 deletions

View file

@ -117,6 +117,8 @@ void ProjucerApplication::initialise (const String& commandLine)
settings->appearance.refreshPresetSchemeList();
setColourScheme (settings->getGlobalProperties().getIntValue ("COLOUR SCHEME"), false);
// do further initialisation in a moment when the message loop has started
triggerAsyncUpdate();
}
@ -499,32 +501,7 @@ void ProjucerApplication::handleMainMenuCommand (int menuItemID)
}
else if (menuItemID >= colourSchemeBaseID && menuItemID < colourSchemeBaseID + 3)
{
auto& appearanceSettings = getAppSettings().appearance;
if (menuItemID == colourSchemeBaseID)
{
lookAndFeel.setColourScheme (LookAndFeel_V4::getDarkColourScheme());
appearanceSettings.selectPresetScheme (0);
}
else if (menuItemID == colourSchemeBaseID + 1)
{
lookAndFeel.setColourScheme (LookAndFeel_V4::getGreyColourScheme());
appearanceSettings.selectPresetScheme (0);
}
else if (menuItemID == colourSchemeBaseID + 2)
{
lookAndFeel.setColourScheme (LookAndFeel_V4::getLightColourScheme());
appearanceSettings.selectPresetScheme (1);
}
lookAndFeel.setupColours();
mainWindowList.sendLookAndFeelChange();
if (utf8Window != nullptr) utf8Window->sendLookAndFeelChange();
if (svgPathWindow != nullptr) svgPathWindow->sendLookAndFeelChange();
if (globalPreferencesWindow != nullptr) globalPreferencesWindow->sendLookAndFeelChange();
if (aboutWindow != nullptr) aboutWindow->sendLookAndFeelChange();
if (applicationUsageDataWindow != nullptr) applicationUsageDataWindow->sendLookAndFeelChange();
setColourScheme (menuItemID - colourSchemeBaseID, true);
}
else
{
@ -801,3 +778,43 @@ void ProjucerApplication::initCommandManager()
registerGUIEditorCommands();
}
void ProjucerApplication::setColourScheme (int index, bool saveSetting)
{
auto& appearanceSettings = getAppSettings().appearance;
if (index == 0)
{
lookAndFeel.setColourScheme (LookAndFeel_V4::getDarkColourScheme());
appearanceSettings.selectPresetScheme (0);
}
else if (index == 1)
{
lookAndFeel.setColourScheme (LookAndFeel_V4::getGreyColourScheme());
appearanceSettings.selectPresetScheme (0);
}
else if (index == 2)
{
lookAndFeel.setColourScheme (LookAndFeel_V4::getLightColourScheme());
appearanceSettings.selectPresetScheme (1);
}
lookAndFeel.setupColours();
mainWindowList.sendLookAndFeelChange();
if (utf8Window != nullptr) utf8Window->sendLookAndFeelChange();
if (svgPathWindow != nullptr) svgPathWindow->sendLookAndFeelChange();
if (globalPreferencesWindow != nullptr) globalPreferencesWindow->sendLookAndFeelChange();
if (aboutWindow != nullptr) aboutWindow->sendLookAndFeelChange();
if (applicationUsageDataWindow != nullptr) applicationUsageDataWindow->sendLookAndFeelChange();
auto* mcm = ModalComponentManager::getInstance();
for (auto i = 0; i < mcm->getNumModalComponents(); ++i)
mcm->getModalComponent (i)->sendLookAndFeelChange();
if (saveSetting)
{
auto& properties = settings->getGlobalProperties();
properties.setValue ("COLOUR SCHEME", index);
}
}

View file

@ -148,4 +148,6 @@ private:
void handleAsyncUpdate() override;
void initCommandManager();
void setColourScheme (int index, bool saveSetting);
};

View file

@ -264,7 +264,6 @@ public:
addAndMakeVisible (cancelButton = new TextButton ("Cancel Button"));
cancelButton->setButtonText (TRANS("Cancel"));
cancelButton->addListener (this);
cancelButton->setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
addAndMakeVisible (changeLogLabel = new Label ("Change Log Label",
TRANS("Release Notes:")));
@ -303,6 +302,8 @@ public:
BinaryData::juce_icon_pngSize);
setSize (518, overwritePath ? 345 : 269);
lookAndFeelChanged();
}
~UpdateUserDialog()
@ -394,6 +395,13 @@ private:
ScopedPointer<TextButton> overwriteButton;
ScopedPointer<Drawable> juceIcon;
void lookAndFeelChanged() override
{
cancelButton->setColour (TextButton::buttonColourId,
findColour (secondaryButtonBackgroundColourId));
changeLog->applyFontToAllText (changeLog->getFont());
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UpdateUserDialog)
};

View file

@ -34,7 +34,7 @@ PathSettingsTab::PathSettingsTab (DependencyPathOS os)
{
const int maxChars = 1024;
StoredSettings& settings = getAppSettings();
auto& settings = getAppSettings();
vst3PathComponent = pathComponents.add (new TextPropertyComponent (settings.getGlobalPath (Ids::vst3Path, os), "VST3 SDK", maxChars, false));
@ -46,11 +46,11 @@ PathSettingsTab::PathSettingsTab (DependencyPathOS os)
androidSdkPathComponent = pathComponents.add (new TextPropertyComponent (settings.getGlobalPath (Ids::androidSDKPath, os), "Android SDK", maxChars, false));
androidNdkPathComponent = pathComponents.add (new TextPropertyComponent (settings.getGlobalPath (Ids::androidNDKPath, os), "Android NDK", maxChars, false));
for (TextPropertyComponent** component = pathComponents.begin(); component != pathComponents.end(); ++component)
for (auto component : pathComponents)
{
addAndMakeVisible (**component);
(*component)->addListener (this);
textPropertyComponentChanged (*component);
addAndMakeVisible (component);
component->addListener (this);
textPropertyComponentChanged (component);
}
}
@ -60,9 +60,9 @@ PathSettingsTab::~PathSettingsTab()
void PathSettingsTab::textPropertyComponentChanged (TextPropertyComponent* textPropertyComponent)
{
Identifier keyName = getKeyForPropertyComponent (textPropertyComponent);
auto keyName = getKeyForPropertyComponent (textPropertyComponent);
Colour textColour = getAppSettings().isGlobalPathValid (File::getCurrentWorkingDirectory(), keyName, textPropertyComponent->getText())
auto textColour = getAppSettings().isGlobalPathValid (File::getCurrentWorkingDirectory(), keyName, textPropertyComponent->getText())
? findColour (widgetTextColourId)
: Colours::red;
@ -96,13 +96,18 @@ void PathSettingsTab::resized()
{
const int componentHeight = 25;
for (TextPropertyComponent** component = pathComponents.begin(); component != pathComponents.end(); ++component)
for (auto component : pathComponents)
{
const int elementNumber = pathComponents.indexOf (*component);
(*component)->setBounds (0, componentHeight * elementNumber, getWidth(), componentHeight);
const auto elementNumber = pathComponents.indexOf (component);
component->setBounds (10, componentHeight * elementNumber, getWidth() - 20, componentHeight);
}
}
void PathSettingsTab::lookAndFeelChanged()
{
for (auto* comp : pathComponents)
textPropertyComponentChanged (comp);
}
//==============================================================================
struct AppearanceEditor
@ -124,7 +129,7 @@ struct AppearanceEditor
g.setColour (findColour (defaultTextColourId));
g.drawFittedText ("Scanning for fonts..", getLocalBounds(), Justification::centred, 2);
const int size = 30;
const auto size = 30;
getLookAndFeel().drawSpinningWaitAnimation (g, Colours::white, (getWidth() - size) / 2, getHeight() / 2 - 50, size, size);
}
@ -136,7 +141,7 @@ struct AppearanceEditor
{
getAppSettings().monospacedFontNames = fontsFound;
if (AppearanceSettingsTab* tab = findParentComponentOfClass<AppearanceSettingsTab>())
if (auto* tab = findParentComponentOfClass<AppearanceSettingsTab>())
tab->changeContent (new EditorPanel());
}
else
@ -154,7 +159,7 @@ struct AppearanceEditor
{
const Font font (name, 20.0f, Font::plain);
const int width = font.getStringWidth ("....");
const auto width = font.getStringWidth ("....");
return width == font.getStringWidth ("WWWW")
&& width == font.getStringWidth ("0000")
@ -185,14 +190,14 @@ struct AppearanceEditor
void rebuildProperties()
{
AppearanceSettings& scheme = getAppSettings().appearance;
auto& scheme = getAppSettings().appearance;
Array<PropertyComponent*> props;
Value fontValue (scheme.getCodeFontValue());
auto fontValue = scheme.getCodeFontValue();
props.add (FontNameValueSource::createProperty ("Code Editor Font", fontValue));
props.add (FontSizeValueSource::createProperty ("Font Size", fontValue));
const StringArray colourNames (scheme.getColourNames());
const auto colourNames = scheme.getColourNames();
for (int i = 0; i < colourNames.size(); ++i)
props.add (new ColourPropertyComponent (nullptr, colourNames[i],
@ -205,8 +210,8 @@ struct AppearanceEditor
void resized() override
{
Rectangle<int> r (getLocalBounds());
panel.setBounds (r.removeFromTop (getHeight() - 28).reduced (4, 2));
auto r = getLocalBounds();
panel.setBounds (r.removeFromTop (getHeight() - 28).reduced (10, 2));
loadButton.setBounds (r.removeFromLeft (getWidth() / 2).reduced (10, 4));
saveButton.setBounds (r.reduced (10, 3));
}
@ -249,6 +254,12 @@ struct AppearanceEditor
rebuildProperties();
}
void lookAndFeelChanged() override
{
loadButton.setColour (TextButton::buttonColourId,
findColour (secondaryButtonBackgroundColourId));
}
JUCE_DECLARE_NON_COPYABLE (EditorPanel)
};
@ -264,7 +275,7 @@ struct AppearanceEditor
void setValue (const var& newValue) override
{
Font font (Font::fromString (sourceValue.toString()));
auto font = Font::fromString (sourceValue.toString());
font.setTypefaceName (newValue.toString().isEmpty() ? Font::getDefaultMonospacedFontName()
: newValue.toString());
sourceValue = font.toString();
@ -272,7 +283,7 @@ struct AppearanceEditor
static ChoicePropertyComponent* createProperty (const String& title, const Value& value)
{
StringArray fontNames = getAppSettings().monospacedFontNames;
auto fontNames = getAppSettings().monospacedFontNames;
Array<var> values;
values.add (Font::getDefaultMonospacedFontName());
@ -321,7 +332,7 @@ void AppearanceSettings::showGlobalPreferences (ScopedPointer<Component>& ownerP
else
new FloatingToolWindow ("Preferences",
"globalPreferencesEditorPos",
new GlobalPreferencesComponent,
new GlobalPreferencesComponent(),
ownerPointer, false,
500, 500, 500, 500, 500, 500);
}
@ -369,3 +380,14 @@ GlobalPreferencesComponent::GlobalPreferencesComponent()
for (GlobalPreferencesTab** tab = preferenceTabs.begin(); tab != preferenceTabs.end(); ++tab)
addTab ((*tab)->getName(), findColour (backgroundColourId, true), (*tab)->getContent(), true);
}
void GlobalPreferencesComponent::paint (Graphics& g)
{
g.fillAll (findColour (backgroundColourId));
}
void GlobalPreferencesComponent::lookAndFeelChanged()
{
for (auto* tab : preferenceTabs)
tab->getContent()->sendLookAndFeelChange();
}

View file

@ -63,6 +63,8 @@ private:
Identifier getKeyForPropertyComponent (TextPropertyComponent*) const;
void lookAndFeelChanged() override;
OwnedArray<TextPropertyComponent> pathComponents;
TextPropertyComponent* vst3PathComponent;
@ -103,8 +105,11 @@ class GlobalPreferencesComponent : public TabbedComponent
{
public:
GlobalPreferencesComponent();
void paint (Graphics&) override;
private:
void lookAndFeelChanged() override;
OwnedArray<GlobalPreferencesTab> preferenceTabs;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GlobalPreferencesComponent)