Browse Source

Fixed some issues in the JUCE Demo project where colours weren't being updated when changing the LookAndFeel with the keyboard shortcuts

tags/2021-05-28
ed 8 years ago
parent
commit
63cf3e2057
15 changed files with 125 additions and 36 deletions
  1. +7
    -3
      examples/Demo/Source/Demos/AudioLatencyDemo.cpp
  2. +5
    -0
      examples/Demo/Source/Demos/AudioSettingsDemo.cpp
  3. +5
    -0
      examples/Demo/Source/Demos/Box2DDemo.cpp
  4. +5
    -0
      examples/Demo/Source/Demos/ChildProcessDemo.cpp
  5. +31
    -20
      examples/Demo/Source/Demos/CryptographyDemo.cpp
  6. +8
    -0
      examples/Demo/Source/Demos/FlexBoxDemo.cpp
  7. +5
    -0
      examples/Demo/Source/Demos/JavaScript.cpp
  8. +7
    -4
      examples/Demo/Source/Demos/KeyMappingsDemo.cpp
  9. +5
    -0
      examples/Demo/Source/Demos/MDIDemo.cpp
  10. +5
    -0
      examples/Demo/Source/Demos/NetworkingDemo.cpp
  11. +16
    -9
      examples/Demo/Source/Demos/OpenGLDemo.cpp
  12. +5
    -0
      examples/Demo/Source/Demos/SystemInfoDemo.cpp
  13. +5
    -0
      examples/Demo/Source/Demos/UnitTestsDemo.cpp
  14. +5
    -0
      examples/Demo/Source/Demos/WebBrowserDemo.cpp
  15. +11
    -0
      examples/Demo/Source/Demos/WidgetsDemo.cpp

+ 7
- 3
examples/Demo/Source/Demos/AudioLatencyDemo.cpp View File

@@ -308,9 +308,6 @@ public:
resultsBox.setCaretVisible (false); resultsBox.setCaretVisible (false);
resultsBox.setPopupMenuEnabled (true); resultsBox.setPopupMenuEnabled (true);
resultsBox.setColour (TextEditor::backgroundColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::widgetBackground,
Colour (0x32ffffff)));
resultsBox.setColour (TextEditor::outlineColourId, Colour (0x1c000000)); resultsBox.setColour (TextEditor::outlineColourId, Colour (0x1c000000));
resultsBox.setColour (TextEditor::shadowColourId, Colour (0x16000000)); resultsBox.setColour (TextEditor::shadowColourId, Colour (0x16000000));
@@ -368,6 +365,13 @@ private:
startTest(); startTest();
} }
void lookAndFeelChanged() override
{
resultsBox.setColour (TextEditor::backgroundColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::widgetBackground,
Colour (0x32ffffff)));
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioLatencyDemo) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioLatencyDemo)
}; };


+ 5
- 0
examples/Demo/Source/Demos/AudioSettingsDemo.cpp View File

@@ -113,6 +113,11 @@ private:
dumpDeviceInfo(); dumpDeviceInfo();
} }
void lookAndFeelChanged() override
{
diagnosticsBox.applyFontToAllText (diagnosticsBox.getFont());
}
static String getListOfActiveBits (const BitArray& b) static String getListOfActiveBits (const BitArray& b)
{ {
StringArray bits; StringArray bits;


+ 5
- 0
examples/Demo/Source/Demos/Box2DDemo.cpp View File

@@ -299,6 +299,11 @@ private:
} }
} }
void lookAndFeelChanged() override
{
instructions.applyFontToAllText (instructions.getFont());
}
static StringArray getTestsList() static StringArray getTestsList()
{ {
const char* tests[] = const char* tests[] =


+ 5
- 0
examples/Demo/Source/Demos/ChildProcessDemo.cpp View File

@@ -205,6 +205,11 @@ private:
testResultsBox.moveCaretToEnd(); testResultsBox.moveCaretToEnd();
} }
void lookAndFeelChanged() override
{
testResultsBox.applyFontToAllText (testResultsBox.getFont());
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChildProcessDemo) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChildProcessDemo)
}; };


+ 31
- 20
examples/Demo/Source/Demos/CryptographyDemo.cpp View File

@@ -36,16 +36,6 @@ public:
addAndMakeVisible (rsaGroup); addAndMakeVisible (rsaGroup);
rsaGroup.setText ("RSA Encryption"); rsaGroup.setText ("RSA Encryption");
rsaGroup.setColour (GroupComponent::outlineColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::outline,
Colours::grey));
rsaGroup.setColour (GroupComponent::textColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::defaultText,
Colours::white));
rsaResultBox.setColour (TextEditor::backgroundColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::widgetBackground,
Colours::white.withAlpha (0.5f)));
bitSizeLabel.setText ("Num Bits to Use:", dontSendNotification); bitSizeLabel.setText ("Num Bits to Use:", dontSendNotification);
bitSizeLabel.attachToComponent (&bitSize, true); bitSizeLabel.attachToComponent (&bitSize, true);
@@ -120,6 +110,22 @@ private:
createRSAKey(); createRSAKey();
} }
void lookAndFeelChanged() override
{
rsaGroup.setColour (GroupComponent::outlineColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::outline,
Colours::grey));
rsaGroup.setColour (GroupComponent::textColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::defaultText,
Colours::white));
rsaResultBox.setColour (TextEditor::backgroundColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::widgetBackground,
Colours::white.withAlpha (0.5f)));
bitSize.applyFontToAllText (bitSize.getFont());
rsaResultBox.applyFontToAllText (rsaResultBox.getFont());
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RSAComponent) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RSAComponent)
}; };
@@ -133,16 +139,6 @@ public:
addAndMakeVisible (hashGroup); addAndMakeVisible (hashGroup);
hashGroup.setText ("Hashes"); hashGroup.setText ("Hashes");
hashGroup.setColour (GroupComponent::outlineColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::outline,
Colours::grey));
hashGroup.setColour (GroupComponent::textColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::defaultText,
Colours::white));
hashEntryBox.setColour (TextEditor::backgroundColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::widgetBackground,
Colours::white.withAlpha (0.5f)));
addAndMakeVisible (hashEntryBox); addAndMakeVisible (hashEntryBox);
hashEntryBox.setMultiLine (true); hashEntryBox.setMultiLine (true);
@@ -214,6 +210,21 @@ private:
void textEditorEscapeKeyPressed (TextEditor&) override { updateHashes(); } void textEditorEscapeKeyPressed (TextEditor&) override { updateHashes(); }
void textEditorFocusLost (TextEditor&) override { updateHashes(); } void textEditorFocusLost (TextEditor&) override { updateHashes(); }
void lookAndFeelChanged() override
{
hashGroup.setColour (GroupComponent::outlineColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::outline,
Colours::grey));
hashGroup.setColour (GroupComponent::textColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::defaultText,
Colours::white));
hashEntryBox.setColour (TextEditor::backgroundColourId,
getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::widgetBackground,
Colours::white.withAlpha (0.5f)));
hashEntryBox.applyFontToAllText (hashEntryBox.getFont());
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HashesComponent) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HashesComponent)
}; };


+ 8
- 0
examples/Demo/Source/Demos/FlexBoxDemo.cpp View File

@@ -124,6 +124,14 @@ struct DemoFlexPanel : public juce::Component,
r.reduced (4), Justification::bottomRight, 2); r.reduced (4), Justification::bottomRight, 2);
} }
void lookAndFeelChanged() override
{
flexOrderEditor.applyFontToAllText (flexOrderEditor.getFont());
flexGrowEditor.applyFontToAllText (flexGrowEditor.getFont());
flexShrinkEditor.applyFontToAllText (flexShrinkEditor.getFont());
flexBasisEditor.applyFontToAllText (flexBasisEditor.getFont());
}
FlexItem& flexItem; FlexItem& flexItem;
TextEditor flexOrderEditor, flexGrowEditor, flexShrinkEditor, flexBasisEditor; TextEditor flexOrderEditor, flexGrowEditor, flexShrinkEditor, flexBasisEditor;


+ 5
- 0
examples/Demo/Source/Demos/JavaScript.cpp View File

@@ -152,6 +152,11 @@ private:
outputDisplay.setBounds (r.withTrimmedTop (8)); outputDisplay.setBounds (r.withTrimmedTop (8));
} }
void lookAndFeelChanged() override
{
outputDisplay.applyFontToAllText (outputDisplay.getFont());
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JavaScriptDemo) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JavaScriptDemo)
}; };


+ 7
- 4
examples/Demo/Source/Demos/KeyMappingsDemo.cpp View File

@@ -36,10 +36,6 @@ public:
{ {
setOpaque (true); setOpaque (true);
addAndMakeVisible (keyMappingEditor); addAndMakeVisible (keyMappingEditor);
LookAndFeel* lf = &LookAndFeel::getDefaultLookAndFeel();
keyMappingEditor.setColours (lf->findColour (KeyMappingEditorComponent::backgroundColourId),
lf->findColour (KeyMappingEditorComponent::textColourId));
} }
void paint (Graphics& g) override void paint (Graphics& g) override
@@ -56,6 +52,13 @@ public:
private: private:
KeyMappingEditorComponent keyMappingEditor; KeyMappingEditorComponent keyMappingEditor;
void lookAndFeelChanged() override
{
auto* lf = &LookAndFeel::getDefaultLookAndFeel();
keyMappingEditor.setColours (lf->findColour (KeyMappingEditorComponent::backgroundColourId),
lf->findColour (KeyMappingEditorComponent::textColourId));
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KeyMappingsDemo) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KeyMappingsDemo)
}; };


+ 5
- 0
examples/Demo/Source/Demos/MDIDemo.cpp View File

@@ -114,6 +114,11 @@ private:
changed(); changed();
} }
void lookAndFeelChanged() override
{
editor.applyFontToAllText (editor.getFont());
}
void textEditorReturnKeyPressed (TextEditor&) override {} void textEditorReturnKeyPressed (TextEditor&) override {}
void textEditorEscapeKeyPressed (TextEditor&) override {} void textEditorEscapeKeyPressed (TextEditor&) override {}
void textEditorFocusLost (TextEditor&) override {} void textEditorFocusLost (TextEditor&) override {}


+ 5
- 0
examples/Demo/Source/Demos/NetworkingDemo.cpp View File

@@ -118,6 +118,11 @@ private:
fetchButton.triggerClick(); fetchButton.triggerClick();
} }
void lookAndFeelChanged() override
{
urlBox.applyFontToAllText (urlBox.getFont());
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NetworkingDemo) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NetworkingDemo)
}; };


+ 16
- 9
examples/Demo/Source/Demos/OpenGLDemo.cpp View File

@@ -368,18 +368,11 @@ struct OpenGLDemoClasses
addAndMakeVisible (showBackgroundToggle); addAndMakeVisible (showBackgroundToggle);
showBackgroundToggle.addListener (this); showBackgroundToggle.addListener (this);
Colour editorBackground = dynamic_cast<LookAndFeel_V4*> (&LookAndFeel::getDefaultLookAndFeel())
? getLookAndFeel().findColour (ResizableWindow::backgroundColourId)
: Colours::white;
addAndMakeVisible (tabbedComp); addAndMakeVisible (tabbedComp);
tabbedComp.setTabBarDepth (25); tabbedComp.setTabBarDepth (25);
tabbedComp.setColour (TabbedButtonBar::tabTextColourId, Colours::grey); tabbedComp.setColour (TabbedButtonBar::tabTextColourId, Colours::grey);
tabbedComp.addTab ("Vertex", editorBackground, &vertexEditorComp, false);
tabbedComp.addTab ("Fragment", editorBackground, &fragmentEditorComp, false);
vertexEditorComp.setColour (CodeEditorComponent::backgroundColourId, editorBackground);
fragmentEditorComp.setColour (CodeEditorComponent::backgroundColourId, editorBackground);
tabbedComp.addTab ("Vertex", Colours::transparentBlack, &vertexEditorComp, false);
tabbedComp.addTab ("Fragment", Colours::transparentBlack, &fragmentEditorComp, false);
vertexDocument.addListener (this); vertexDocument.addListener (this);
fragmentDocument.addListener (this); fragmentDocument.addListener (this);
@@ -409,6 +402,8 @@ struct OpenGLDemoClasses
addAndMakeVisible (textureLabel); addAndMakeVisible (textureLabel);
textureLabel.setText ("Texture:", dontSendNotification); textureLabel.setText ("Texture:", dontSendNotification);
textureLabel.attachToComponent (&textureBox, true); textureLabel.attachToComponent (&textureBox, true);
lookAndFeelChanged();
} }
void initialise() void initialise()
@@ -562,6 +557,18 @@ struct OpenGLDemoClasses
selectTexture (textureBox.getSelectedId()); selectTexture (textureBox.getSelectedId());
} }
void lookAndFeelChanged() override
{
auto editorBackground = getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground,
Colours::white);
for (int i = tabbedComp.getNumTabs(); i >= 0; --i)
tabbedComp.setTabBackgroundColour (i, editorBackground);
vertexEditorComp.setColour (CodeEditorComponent::backgroundColourId, editorBackground);
fragmentEditorComp.setColour (CodeEditorComponent::backgroundColourId, editorBackground);
}
OpenGLDemo& demo; OpenGLDemo& demo;
Label speedLabel, zoomLabel; Label speedLabel, zoomLabel;


+ 5
- 0
examples/Demo/Source/Demos/SystemInfoDemo.cpp View File

@@ -202,6 +202,11 @@ public:
private: private:
TextEditor resultsBox; TextEditor resultsBox;
void lookAndFeelChanged() override
{
resultsBox.applyFontToAllText (resultsBox.getFont());
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SystemInfoDemo) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SystemInfoDemo)
}; };


+ 5
- 0
examples/Demo/Source/Demos/UnitTestsDemo.cpp View File

@@ -186,6 +186,11 @@ struct UnitTestClasses
TextButton startTestButton; TextButton startTestButton;
TextEditor testResultsBox; TextEditor testResultsBox;
void lookAndFeelChanged() override
{
testResultsBox.applyFontToAllText (testResultsBox.getFont());
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UnitTestsDemo) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UnitTestsDemo)
}; };
}; };


+ 5
- 0
examples/Demo/Source/Demos/WebBrowserDemo.cpp View File

@@ -140,6 +140,11 @@ private:
webView->goToURL (addressTextBox.getText()); webView->goToURL (addressTextBox.getText());
} }
void lookAndFeelChanged() override
{
addressTextBox.applyFontToAllText (addressTextBox.getFont());
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebBrowserDemo) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebBrowserDemo)
}; };


+ 11
- 0
examples/Demo/Source/Demos/WidgetsDemo.cpp View File

@@ -447,6 +447,12 @@ struct MiscPage : public Component
comboBox.setSelectedId (1); comboBox.setSelectedId (1);
} }
void lookAndFeelChanged() override
{
textEditor1.applyFontToAllText (textEditor1.getFont());
textEditor2.applyFontToAllText (textEditor2.getFont());
}
TextEditor textEditor1, textEditor2; TextEditor textEditor1, textEditor2;
ComboBox comboBox; ComboBox comboBox;
}; };
@@ -1572,6 +1578,11 @@ private:
setTabBackgroundColour (i, getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); setTabBackgroundColour (i, getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
} }
} }
void lookAndFeelChanged() override
{
updateTabColours();
}
}; };
//============================================================================== //==============================================================================


Loading…
Cancel
Save