kopia lustrzana https://github.com/jameshball/osci-render
Improve performance of the interface and refresh look
rodzic
2e23c485b6
commit
58362b1508
|
@ -4,7 +4,7 @@
|
|||
OscirenderLookAndFeel::OscirenderLookAndFeel() {
|
||||
// slider
|
||||
setColour(juce::Slider::thumbColourId, Colours::veryDark);
|
||||
setColour(juce::Slider::textBoxOutlineColourId, juce::Colours::white);
|
||||
setColour(juce::Slider::textBoxOutlineColourId, Colours::veryDark);
|
||||
setColour(juce::Slider::textBoxBackgroundColourId, Colours::veryDark);
|
||||
setColour(juce::Slider::textBoxHighlightColourId, Colours::accentColor.withMultipliedAlpha(0.5));
|
||||
setColour(juce::Slider::trackColourId, juce::Colours::grey);
|
||||
|
@ -35,7 +35,8 @@ OscirenderLookAndFeel::OscirenderLookAndFeel() {
|
|||
|
||||
// text box
|
||||
setColour(juce::TextEditor::backgroundColourId, Colours::veryDark);
|
||||
setColour(juce::TextEditor::outlineColourId, juce::Colours::white);
|
||||
setColour(juce::TextEditor::outlineColourId, Colours::veryDark);
|
||||
setColour(juce::TextEditor::focusedOutlineColourId, Colours::accentColor);
|
||||
setColour(juce::CaretComponent::caretColourId, Dracula::foreground);
|
||||
setColour(juce::TextEditor::highlightColourId, Colours::grey);
|
||||
|
||||
|
@ -84,10 +85,74 @@ OscirenderLookAndFeel::OscirenderLookAndFeel() {
|
|||
getCurrentColourScheme().setUIColour(ColourScheme::widgetBackground, Colours::veryDark);
|
||||
getCurrentColourScheme().setUIColour(ColourScheme::UIColour::defaultFill, Colours::accentColor);
|
||||
|
||||
// setDefaultSansSerifTypeface(juce::Typeface::createSystemTypefaceFor(BinaryData::font_ttf, BinaryData::font_ttfSize));
|
||||
|
||||
// I have to do this, otherwise components are initialised before the look and feel is set
|
||||
juce::LookAndFeel::setDefaultLookAndFeel(this);
|
||||
}
|
||||
|
||||
void OscirenderLookAndFeel::drawLabel(juce::Graphics& g, juce::Label& label) {
|
||||
g.setColour(label.findColour(juce::Label::backgroundColourId));
|
||||
g.fillRoundedRectangle(label.getLocalBounds().toFloat(), RECT_RADIUS);
|
||||
|
||||
if (! label.isBeingEdited())
|
||||
{
|
||||
auto alpha = label.isEnabled() ? 1.0f : 0.5f;
|
||||
const juce::Font font (getLabelFont (label));
|
||||
|
||||
g.setColour (label.findColour (juce::Label::textColourId).withMultipliedAlpha (alpha));
|
||||
g.setFont (font);
|
||||
|
||||
auto textArea = getLabelBorderSize (label).subtractedFrom (label.getLocalBounds());
|
||||
|
||||
g.drawFittedText (label.getText(), textArea, label.getJustificationType(),
|
||||
juce::jmax (1, (int) ((float) textArea.getHeight() / font.getHeight())),
|
||||
label.getMinimumHorizontalScale());
|
||||
|
||||
g.setColour (label.findColour (juce::Label::outlineColourId).withMultipliedAlpha (alpha));
|
||||
}
|
||||
else if (label.isEnabled())
|
||||
{
|
||||
g.setColour (label.findColour (juce::Label::outlineColourId));
|
||||
}
|
||||
|
||||
g.drawRoundedRectangle(label.getLocalBounds().toFloat(), RECT_RADIUS, 1);
|
||||
}
|
||||
|
||||
void OscirenderLookAndFeel::fillTextEditorBackground(juce::Graphics& g, int width, int height, juce::TextEditor& textEditor) {
|
||||
if (dynamic_cast<juce::AlertWindow*> (textEditor.getParentComponent()) != nullptr)
|
||||
{
|
||||
g.setColour (textEditor.findColour (juce::TextEditor::backgroundColourId));
|
||||
g.fillRect (0, 0, width, height);
|
||||
|
||||
g.setColour (textEditor.findColour (juce::TextEditor::outlineColourId));
|
||||
g.drawHorizontalLine (height - 1, 0.0f, static_cast<float> (width));
|
||||
}
|
||||
else
|
||||
{
|
||||
g.setColour (textEditor.findColour (juce::TextEditor::backgroundColourId));
|
||||
g.fillRoundedRectangle(textEditor.getLocalBounds().toFloat(), RECT_RADIUS);
|
||||
}
|
||||
}
|
||||
|
||||
void OscirenderLookAndFeel::drawTextEditorOutline(juce::Graphics& g, int width, int height, juce::TextEditor& textEditor) {
|
||||
if (textEditor.isEnabled())
|
||||
{
|
||||
if (textEditor.hasKeyboardFocus (true) && ! textEditor.isReadOnly())
|
||||
{
|
||||
const int border = 2;
|
||||
|
||||
g.setColour (textEditor.findColour (juce::TextEditor::focusedOutlineColourId));
|
||||
g.drawRoundedRectangle(0, 0, width, height, RECT_RADIUS, border);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.setColour (textEditor.findColour (juce::TextEditor::outlineColourId));
|
||||
g.drawRoundedRectangle(0, 0, width, height, RECT_RADIUS, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OscirenderLookAndFeel::drawComboBox(juce::Graphics& g, int width, int height, bool, int, int, int, int, juce::ComboBox& box) {
|
||||
juce::Rectangle<int> boxBounds{0, 0, width, height};
|
||||
|
||||
|
@ -166,17 +231,16 @@ void OscirenderLookAndFeel::drawGroupComponentOutline(juce::Graphics& g, int wid
|
|||
|
||||
juce::Path background;
|
||||
background.addRoundedRectangle(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), RECT_RADIUS, RECT_RADIUS);
|
||||
auto ds = juce::DropShadow(juce::Colours::black, 3, juce::Point<int>(0, 0));
|
||||
ds.drawForPath(g, background);
|
||||
|
||||
g.setColour(group.findColour(groupComponentBackgroundColourId).withMultipliedAlpha(alpha));
|
||||
g.fillPath(background);
|
||||
|
||||
|
||||
auto header = bounds.removeFromTop(2 * textH);
|
||||
|
||||
juce::Path headerPath;
|
||||
headerPath.addRoundedRectangle(header.getX(), header.getY(), header.getWidth(), header.getHeight(), RECT_RADIUS, RECT_RADIUS);
|
||||
|
||||
g.setColour(group.findColour(groupComponentHeaderColourId).withMultipliedAlpha(alpha));
|
||||
g.fillRect(header);
|
||||
g.fillPath(headerPath);
|
||||
|
||||
g.setColour(group.findColour(juce::GroupComponent::textColourId).withMultipliedAlpha(alpha));
|
||||
g.setFont(f);
|
||||
|
@ -200,14 +264,14 @@ void OscirenderLookAndFeel::drawLinearSlider(juce::Graphics& g, int x, int y, in
|
|||
|
||||
juce::Path thumb;
|
||||
thumb.addEllipse(juce::Rectangle<float>(static_cast<float>(thumbWidth), static_cast<float>(thumbWidth)).withCentre(point));
|
||||
juce::DropShadow ds(juce::Colours::black, 1, { 0, 1 });
|
||||
|
||||
ds.drawForPath(g, thumb);
|
||||
g.setColour(slider.findColour(sliderThumbOutlineColourId).withAlpha(slider.isEnabled() ? 1.0f : 0.5f));
|
||||
g.strokePath(thumb, juce::PathStrokeType(1.0f));
|
||||
}
|
||||
|
||||
void OscirenderLookAndFeel::drawButtonBackground(juce::Graphics& g, juce::Button& button, const juce::Colour& backgroundColour, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) {
|
||||
button.setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
||||
|
||||
auto bounds = button.getLocalBounds().toFloat().reduced(0.5f, 0.5f);
|
||||
|
||||
auto baseColour = backgroundColour.withMultipliedSaturation(button.hasKeyboardFocus(true) ? 1.3f : 0.9f)
|
||||
|
@ -217,10 +281,10 @@ void OscirenderLookAndFeel::drawButtonBackground(juce::Graphics& g, juce::Button
|
|||
baseColour = baseColour.contrasting(shouldDrawButtonAsDown ? 0.2f : 0.05f);
|
||||
|
||||
g.setColour(baseColour);
|
||||
g.fillRect(bounds);
|
||||
g.fillRoundedRectangle(bounds, RECT_RADIUS);
|
||||
|
||||
g.setColour(button.findColour(juce::ComboBox::outlineColourId));
|
||||
g.drawRect(bounds, 1.0f);
|
||||
g.drawRoundedRectangle(bounds, RECT_RADIUS, 1.0f);
|
||||
}
|
||||
|
||||
void OscirenderLookAndFeel::drawMenuBarBackground(juce::Graphics& g, int width, int height, bool, juce::MenuBarComponent& menuBar) {
|
||||
|
|
|
@ -71,6 +71,9 @@ public:
|
|||
|
||||
static const int RECT_RADIUS = 5;
|
||||
|
||||
void drawLabel(juce::Graphics& g, juce::Label& label) override;
|
||||
void fillTextEditorBackground(juce::Graphics& g, int width, int height, juce::TextEditor& textEditor) override;
|
||||
void drawTextEditorOutline(juce::Graphics& g, int width, int height, juce::TextEditor& textEditor) override;
|
||||
void drawComboBox(juce::Graphics& g, int width, int height, bool, int, int, int, int, juce::ComboBox& box) override;
|
||||
void positionComboBoxText(juce::ComboBox& box, juce::Label& label) override;
|
||||
void drawTickBox(juce::Graphics& g, juce::Component& component,
|
||||
|
@ -79,6 +82,7 @@ public:
|
|||
const bool isEnabled,
|
||||
const bool shouldDrawButtonAsHighlighted,
|
||||
const bool shouldDrawButtonAsDown) override;
|
||||
static void drawGroupComponentDropShadow(juce::Graphics& g, juce::GroupComponent& group);
|
||||
void drawGroupComponentOutline(juce::Graphics&, int w, int h, const juce::String &text, const juce::Justification&, juce::GroupComponent&) override;
|
||||
void drawLinearSlider(juce::Graphics& g, int x, int y, int width, int height,
|
||||
float sliderPos,
|
||||
|
|
|
@ -244,13 +244,3 @@ void MainComponent::resized() {
|
|||
pluginEditor.visualiser.setBounds(bounds.withSizeKeepingCentre(minDim, minDim));
|
||||
}
|
||||
}
|
||||
|
||||
void MainComponent::paint(juce::Graphics& g) {
|
||||
juce::GroupComponent::paint(g);
|
||||
|
||||
if (!pluginEditor.visualiserFullScreen) {
|
||||
// add drop shadow to the visualiser
|
||||
auto dc = juce::DropShadow(juce::Colours::black, 30, juce::Point<int>(0, 0));
|
||||
dc.drawForRectangle(g, pluginEditor.visualiser.getBounds());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ public:
|
|||
~MainComponent() override;
|
||||
|
||||
void resized() override;
|
||||
void paint(juce::Graphics& g) override;
|
||||
void updateFileLabel();
|
||||
private:
|
||||
OscirenderAudioProcessor& audioProcessor;
|
||||
|
|
|
@ -36,12 +36,8 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioPr
|
|||
addAndMakeVisible(menuBar);
|
||||
}
|
||||
|
||||
addAndMakeVisible(layoutAnimation);
|
||||
layoutAnimation.setBounds(juce::Rectangle<int>(0, 0, 0, 0));
|
||||
|
||||
addAndMakeVisible(collapseButton);
|
||||
collapseButton.onClick = [this] {
|
||||
bool codeEditorVisible = false;
|
||||
{
|
||||
juce::SpinLock::ScopedLockType lock(audioProcessor.parsersLock);
|
||||
int originalIndex = audioProcessor.getCurrentFileIndex();
|
||||
|
@ -49,19 +45,8 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioPr
|
|||
if (originalIndex != -1 || editingCustomFunction) {
|
||||
codeEditors[index]->setVisible(!codeEditors[index]->isVisible());
|
||||
updateCodeEditor();
|
||||
codeEditorVisible = codeEditors[index]->isVisible();
|
||||
}
|
||||
}
|
||||
|
||||
if (codeEditorVisible) {
|
||||
layoutAnimation.setBounds(juce::Rectangle<int>(0, 0, getWidth(), 0));
|
||||
auto finalPos = juce::Rectangle<int>(0, 0, 2 * getWidth() / 3, 0);
|
||||
juce::Desktop::getInstance().getAnimator().animateComponent(&layoutAnimation, finalPos, 1.0, 200, false, 0.5, 0);
|
||||
} else {
|
||||
layoutAnimation.setBounds(juce::Rectangle<int>(0, 0, layout.getItemCurrentPosition(1), 0));
|
||||
auto finalPos = juce::Rectangle<int>(0, 0, getWidth(), 0);
|
||||
juce::Desktop::getInstance().getAnimator().animateComponent(&layoutAnimation, finalPos, 1.0, 200, false, 0.5, 0);
|
||||
}
|
||||
};
|
||||
juce::Path path;
|
||||
path.addTriangle(0.0f, 0.5f, 1.0f, 1.0f, 1.0f, 0.0f);
|
||||
|
@ -149,27 +134,6 @@ void OscirenderAudioProcessorEditor::initialiseCodeEditors() {
|
|||
|
||||
void OscirenderAudioProcessorEditor::paint(juce::Graphics& g) {
|
||||
g.fillAll(getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId));
|
||||
|
||||
auto ds = juce::DropShadow(juce::Colours::black, 5, juce::Point<int>(0, 0));
|
||||
|
||||
// if (!usingNativeMenuBar) {
|
||||
// // add drop shadow to the menu bar
|
||||
// ds.drawForRectangle(g, menuBar.getBounds());
|
||||
// }
|
||||
|
||||
//for (int i = 0; i < codeEditors.size(); i++) {
|
||||
// if (codeEditors[i]->isVisible()) {
|
||||
// ds.drawForRectangle(g, codeEditors[i]->getBounds());
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//if (lua.isVisible()) {
|
||||
// ds.drawForRectangle(g, lua.getBounds());
|
||||
//}
|
||||
|
||||
// if (console.isVisible()) {
|
||||
// ds.drawForRectangle(g, console.getBounds());
|
||||
// }
|
||||
}
|
||||
|
||||
void OscirenderAudioProcessorEditor::resized() {
|
||||
|
|
|
@ -10,21 +10,6 @@
|
|||
#include "components/ErrorCodeEditorComponent.h"
|
||||
#include "components/LuaConsole.h"
|
||||
|
||||
class ProxyLayoutAnimationComponent : public juce::Component {
|
||||
public:
|
||||
ProxyLayoutAnimationComponent(juce::StretchableLayoutManager& layout, int index) : layout(layout), index(index) {}
|
||||
|
||||
void resized() override {
|
||||
layout.setItemPosition(index, getBounds().getWidth());
|
||||
getParentComponent()->resized();
|
||||
DBG(getBounds().getWidth());
|
||||
}
|
||||
|
||||
private:
|
||||
juce::StretchableLayoutManager& layout;
|
||||
int index;
|
||||
};
|
||||
|
||||
class OscirenderAudioProcessorEditor : public juce::AudioProcessorEditor, private juce::CodeDocument::Listener, public juce::AsyncUpdater, public juce::ChangeListener {
|
||||
public:
|
||||
OscirenderAudioProcessorEditor(OscirenderAudioProcessor&);
|
||||
|
@ -86,7 +71,6 @@ public:
|
|||
juce::MenuBarComponent menuBar;
|
||||
|
||||
juce::StretchableLayoutManager layout;
|
||||
ProxyLayoutAnimationComponent layoutAnimation{layout, 1};
|
||||
juce::StretchableLayoutResizerBar resizerBar{&layout, 1, true};
|
||||
|
||||
juce::StretchableLayoutManager luaLayout;
|
||||
|
|
|
@ -32,6 +32,7 @@ void SettingsComponent::resized() {
|
|||
|
||||
juce::Component* midiComponents[] = { &dummy, &midiResizerBar, &midi };
|
||||
midiLayout.layOutComponents(midiComponents, 3, area.getX(), area.getY(), area.getWidth(), area.getHeight(), true, true);
|
||||
midi.setBounds(midi.getBounds());
|
||||
|
||||
juce::Component* columns[] = { &dummy2, &mainResizerBar, &dummy };
|
||||
mainLayout.layOutComponents(columns, 3, dummy.getX(), dummy.getY(), dummy.getWidth(), dummy.getHeight(), false, true);
|
||||
|
@ -94,16 +95,3 @@ void SettingsComponent::mouseDown(const juce::MouseEvent& event) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsComponent::paint(juce::Graphics& g) {
|
||||
// add drop shadow to each component
|
||||
//auto dc = juce::DropShadow(juce::Colours::black, 5, juce::Point<int>(0, 0));
|
||||
//dc.drawForRectangle(g, main.getBounds());
|
||||
//dc.drawForRectangle(g, effects.getBounds());
|
||||
//dc.drawForRectangle(g, midi.getBounds());
|
||||
//dc.drawForRectangle(g, perspective.getBounds());
|
||||
|
||||
//if (txt.isVisible()) {
|
||||
// dc.drawForRectangle(g, txt.getBounds());
|
||||
//}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ public:
|
|||
void update();
|
||||
void mouseMove(const juce::MouseEvent& event) override;
|
||||
void mouseDown(const juce::MouseEvent& event) override;
|
||||
void paint(juce::Graphics& g) override;
|
||||
|
||||
private:
|
||||
OscirenderAudioProcessor& audioProcessor;
|
||||
|
|
|
@ -72,7 +72,6 @@ void EffectsListComponent::paintOverChildren(juce::Graphics& g) {
|
|||
auto bounds = list.getBounds();
|
||||
bounds.removeFromBottom(2);
|
||||
g.fillRect(bounds);
|
||||
list.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "VisualiserComponent.h"
|
||||
#include "../LookAndFeel.h"
|
||||
|
||||
VisualiserComponent::VisualiserComponent(int numChannels, OscirenderAudioProcessor& p) : numChannels(numChannels), backgroundColour(juce::Colours::black), waveformColour(juce::Colour(0xff00ff00)), audioProcessor(p), juce::Thread("VisualiserComponent") {
|
||||
setOpaque(true);
|
||||
resetBuffer();
|
||||
startTimerHz(60);
|
||||
startThread();
|
||||
|
@ -46,8 +46,8 @@ void VisualiserComponent::setColours(juce::Colour bk, juce::Colour fg) {
|
|||
}
|
||||
|
||||
void VisualiserComponent::paint(juce::Graphics& g) {
|
||||
g.fillAll(backgroundColour);
|
||||
g.drawRect(getLocalBounds(), 1);
|
||||
g.setColour(backgroundColour);
|
||||
g.fillRoundedRectangle(getLocalBounds().toFloat(), OscirenderLookAndFeel::RECT_RADIUS);
|
||||
|
||||
auto r = getLocalBounds().toFloat();
|
||||
auto minDim = juce::jmin(r.getWidth(), r.getHeight());
|
||||
|
@ -63,7 +63,7 @@ void VisualiserComponent::paint(juce::Graphics& g) {
|
|||
if (!active) {
|
||||
// add translucent layer
|
||||
g.setColour(juce::Colours::black.withAlpha(0.5f));
|
||||
g.fillRect(getLocalBounds());
|
||||
g.fillRoundedRectangle(getLocalBounds().toFloat(), OscirenderLookAndFeel::RECT_RADIUS);
|
||||
|
||||
// add text
|
||||
g.setColour(juce::Colours::white);
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
companyEmail="james@ball.sh" defines="NOMINMAX=1">
|
||||
<MAINGROUP id="j5Ge2T" name="osci-render">
|
||||
<GROUP id="{5ABCED88-0059-A7AF-9596-DBF91DDB0292}" name="Resources">
|
||||
<GROUP id="{8B7C0BA0-BE39-1611-4D80-F5E19B9AD847}" name="fonts">
|
||||
<FILE id="CWpZX4" name="font.ttf" compile="0" resource="1" file="Resources/fonts/font.ttf"/>
|
||||
</GROUP>
|
||||
<GROUP id="{C2609827-4F4A-1ADA-8BA1-A40C1D92649C}" name="lua">
|
||||
<FILE id="xANsA8" name="demo.lua" compile="0" resource="1" file="Resources/lua/demo.lua"/>
|
||||
</GROUP>
|
||||
|
|
Ładowanie…
Reference in New Issue