kopia lustrzana https://github.com/jameshball/osci-render
Make code editor collapsible
rodzic
9a3e707257
commit
4bc4629474
|
@ -11,7 +11,7 @@
|
|||
|
||||
//==============================================================================
|
||||
OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor (OscirenderAudioProcessor& p)
|
||||
: AudioProcessorEditor(&p), audioProcessor(p), effects(p), main(p)
|
||||
: AudioProcessorEditor(&p), audioProcessor(p), effects(p), main(p), collapseButton("Collapse", juce::Colours::white, juce::Colours::white, juce::Colours::white)
|
||||
{
|
||||
// Make sure that before the constructor has finished, you've set the
|
||||
// editor's size to whatever you need it to be.
|
||||
|
@ -38,6 +38,25 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor (OscirenderAudioP
|
|||
a = io.read("*number") -- read a number
|
||||
print(fact(a))
|
||||
)LUA");
|
||||
|
||||
addAndMakeVisible(collapseButton);
|
||||
collapseButton.onClick = [this] {
|
||||
if (codeEditor->isVisible()) {
|
||||
codeEditor->setVisible(false);
|
||||
juce::Path path;
|
||||
path.addTriangle(0.0f, 0.5f, 1.0f, 1.0f, 1.0f, 0.0f);
|
||||
collapseButton.setShape(path, false, true, true);
|
||||
} else {
|
||||
codeEditor->setVisible(true);
|
||||
juce::Path path;
|
||||
path.addTriangle(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.5f);
|
||||
collapseButton.setShape(path, false, true, true);
|
||||
}
|
||||
resized();
|
||||
};
|
||||
juce::Path path;
|
||||
path.addTriangle(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.5f);
|
||||
collapseButton.setShape(path, false, true, true);
|
||||
}
|
||||
|
||||
OscirenderAudioProcessorEditor::~OscirenderAudioProcessorEditor() {}
|
||||
|
@ -45,17 +64,25 @@ OscirenderAudioProcessorEditor::~OscirenderAudioProcessorEditor() {}
|
|||
//==============================================================================
|
||||
void OscirenderAudioProcessorEditor::paint (juce::Graphics& g)
|
||||
{
|
||||
// (Our component is opaque, so we must completely fill the background with a solid colour)
|
||||
g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
|
||||
g.fillAll(getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId));
|
||||
|
||||
g.setColour (juce::Colours::white);
|
||||
g.setFont (15.0f);
|
||||
g.setColour(juce::Colours::white);
|
||||
g.setFont(15.0f);
|
||||
}
|
||||
|
||||
void OscirenderAudioProcessorEditor::resized() {
|
||||
effects.setBounds(getWidth() / 2, 0, getWidth() / 2, getHeight());
|
||||
main.setBounds(0, 0, getWidth() / 2, getHeight() / 2);
|
||||
auto area = getLocalBounds();
|
||||
auto sections = 2;
|
||||
if (codeEditor != nullptr) {
|
||||
codeEditor->setBounds(0, getHeight() / 2, getWidth() / 2, getHeight() / 2);
|
||||
if (codeEditor->isVisible()) {
|
||||
sections++;
|
||||
codeEditor->setBounds(area.removeFromRight(getWidth() / sections));
|
||||
} else {
|
||||
codeEditor->setBounds(0, 0, 0, 0);
|
||||
}
|
||||
collapseButton.setBounds(area.removeFromRight(20));
|
||||
}
|
||||
effects.setBounds(area.removeFromRight(getWidth() / sections));
|
||||
main.setBounds(area.removeFromTop(getHeight() / 2));
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ private:
|
|||
juce::CodeDocument codeDocument;
|
||||
juce::LuaTokeniser luaTokeniser;
|
||||
std::unique_ptr<juce::CodeEditorComponent> codeEditor;
|
||||
juce::ShapeButton collapseButton;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OscirenderAudioProcessorEditor)
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue