kopia lustrzana https://github.com/jameshball/osci-render
Initial testing with tabs
rodzic
0615a46c5d
commit
0462daac2b
|
@ -94,7 +94,11 @@ void OscirenderLookAndFeel::drawLabel(juce::Graphics& g, juce::Label& label) {
|
||||||
label.setRepaintsOnMouseActivity(true);
|
label.setRepaintsOnMouseActivity(true);
|
||||||
auto baseColour = label.findColour(juce::Label::backgroundColourId);
|
auto baseColour = label.findColour(juce::Label::backgroundColourId);
|
||||||
if (label.isEditable()) {
|
if (label.isEditable()) {
|
||||||
|
juce::MessageManager::callAsync(
|
||||||
|
[&label] () {
|
||||||
label.setMouseCursor(juce::MouseCursor::IBeamCursor);
|
label.setMouseCursor(juce::MouseCursor::IBeamCursor);
|
||||||
|
}
|
||||||
|
);
|
||||||
baseColour = LookAndFeelHelpers::createBaseColour(baseColour, false, label.isMouseOver(true), false, label.isEnabled());
|
baseColour = LookAndFeelHelpers::createBaseColour(baseColour, false, label.isMouseOver(true), false, label.isEnabled());
|
||||||
}
|
}
|
||||||
g.setColour(baseColour);
|
g.setColour(baseColour);
|
||||||
|
@ -168,7 +172,11 @@ void OscirenderLookAndFeel::drawTextEditorOutline(juce::Graphics& g, int width,
|
||||||
|
|
||||||
void OscirenderLookAndFeel::drawComboBox(juce::Graphics& g, int width, int height, bool, int, int, int, int, juce::ComboBox& box) {
|
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};
|
juce::Rectangle<int> boxBounds{0, 0, width, height};
|
||||||
|
juce::MessageManager::callAsync(
|
||||||
|
[&box] () {
|
||||||
box.setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
box.setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
g.setColour(box.findColour(juce::ComboBox::backgroundColourId));
|
g.setColour(box.findColour(juce::ComboBox::backgroundColourId));
|
||||||
g.fillRoundedRectangle(boxBounds.toFloat(), RECT_RADIUS);
|
g.fillRoundedRectangle(boxBounds.toFloat(), RECT_RADIUS);
|
||||||
|
@ -280,7 +288,11 @@ void OscirenderLookAndFeel::drawLinearSlider(juce::Graphics& g, int x, int y, in
|
||||||
}
|
}
|
||||||
|
|
||||||
void OscirenderLookAndFeel::drawButtonBackground(juce::Graphics& g, juce::Button& button, const juce::Colour& backgroundColour, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) {
|
void OscirenderLookAndFeel::drawButtonBackground(juce::Graphics& g, juce::Button& button, const juce::Colour& backgroundColour, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) {
|
||||||
|
juce::MessageManager::callAsync(
|
||||||
|
[&button] () {
|
||||||
button.setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
button.setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
auto bounds = button.getLocalBounds().toFloat().reduced(0.5f, 0.5f);
|
auto bounds = button.getLocalBounds().toFloat().reduced(0.5f, 0.5f);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,16 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioPr
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
addAndMakeVisible(&toolbar);
|
||||||
|
toolbar.addDefaultItems(factory);
|
||||||
|
auto children = toolbar.getChildren();
|
||||||
|
for (auto child : children) {
|
||||||
|
auto item = dynamic_cast<juce::ToolbarItemComponent*>(child);
|
||||||
|
if (item != nullptr) {
|
||||||
|
toolbar.addMouseListener(item, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addAndMakeVisible(console);
|
addAndMakeVisible(console);
|
||||||
console.setConsoleOpen(false);
|
console.setConsoleOpen(false);
|
||||||
|
|
||||||
|
@ -150,6 +160,9 @@ void OscirenderAudioProcessorEditor::resized() {
|
||||||
menuBar.setBounds(area.removeFromTop(25));
|
menuBar.setBounds(area.removeFromTop(25));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toolbar.setBounds(area.removeFromTop(50));
|
||||||
|
toolbar.setEditingActive(true);
|
||||||
|
|
||||||
area.removeFromTop(2);
|
area.removeFromTop(2);
|
||||||
area.removeFromLeft(3);
|
area.removeFromLeft(3);
|
||||||
auto volumeArea = area.removeFromLeft(30);
|
auto volumeArea = area.removeFromLeft(30);
|
||||||
|
|
|
@ -10,6 +10,86 @@
|
||||||
#include "components/ErrorCodeEditorComponent.h"
|
#include "components/ErrorCodeEditorComponent.h"
|
||||||
#include "components/LuaConsole.h"
|
#include "components/LuaConsole.h"
|
||||||
|
|
||||||
|
|
||||||
|
class DemoToolbarItemFactory : public juce::ToolbarItemFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DemoToolbarItemFactory() {}
|
||||||
|
|
||||||
|
void getAllToolbarItemIds (juce::Array<int>& ids) {
|
||||||
|
for (int i = 1; i < 128; ++i) {
|
||||||
|
ids.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void getDefaultItemSet (juce::Array<int>& ids) {
|
||||||
|
for (int i = 1; i < 10; ++i) {
|
||||||
|
ids.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
juce::ToolbarItemComponent* createItem (int itemId) {
|
||||||
|
return new TabComponent(itemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
juce::StringArray iconNames;
|
||||||
|
|
||||||
|
class TabComponent : public juce::ToolbarItemComponent {
|
||||||
|
public:
|
||||||
|
TabComponent(const int id) : juce::ToolbarItemComponent (id, "Custom Toolbar Item", false), label("demo toolbar combo box"), id(id) {
|
||||||
|
addAndMakeVisible(&label);
|
||||||
|
|
||||||
|
label.setText("tab " + juce::String(id), juce::dontSendNotification);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
~TabComponent() override {
|
||||||
|
if (toolbar != nullptr) {
|
||||||
|
toolbar->removeMouseListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getToolbarItemSizes(int /*toolbarDepth*/, bool isToolbarVertical, int& preferredSize, int& minSize, int& maxSize) {
|
||||||
|
if (isToolbarVertical) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
preferredSize = 250;
|
||||||
|
minSize = 80;
|
||||||
|
maxSize = 300;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void paintButtonArea(juce::Graphics&, int, int, bool, bool) {}
|
||||||
|
|
||||||
|
void contentAreaChanged(const juce::Rectangle<int>& contentArea) {
|
||||||
|
label.setSize(contentArea.getWidth() - 2, juce::jmin(contentArea.getHeight() - 2, 22));
|
||||||
|
label.setCentrePosition(contentArea.getCentreX(), contentArea.getCentreY());
|
||||||
|
}
|
||||||
|
|
||||||
|
void mouseDown(const juce::MouseEvent& e) {
|
||||||
|
auto temp = getToolbar();
|
||||||
|
if (temp != nullptr) {
|
||||||
|
toolbar = temp;
|
||||||
|
}
|
||||||
|
if (getScreenBounds().contains(e.getScreenPosition())) {
|
||||||
|
label.setText("clicked!", juce::dontSendNotification);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mouseUp(const juce::MouseEvent& e) {
|
||||||
|
label.setText("tab " + juce::String(id), juce::dontSendNotification);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
juce::Label label;
|
||||||
|
juce::Toolbar* toolbar;
|
||||||
|
int id;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class OscirenderAudioProcessorEditor : public juce::AudioProcessorEditor, private juce::CodeDocument::Listener, public juce::AsyncUpdater, public juce::ChangeListener {
|
class OscirenderAudioProcessorEditor : public juce::AudioProcessorEditor, private juce::CodeDocument::Listener, public juce::AsyncUpdater, public juce::ChangeListener {
|
||||||
public:
|
public:
|
||||||
OscirenderAudioProcessorEditor(OscirenderAudioProcessor&);
|
OscirenderAudioProcessorEditor(OscirenderAudioProcessor&);
|
||||||
|
@ -57,6 +137,9 @@ public:
|
||||||
|
|
||||||
LuaConsole console;
|
LuaConsole console;
|
||||||
|
|
||||||
|
DemoToolbarItemFactory factory;
|
||||||
|
juce::Toolbar toolbar;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<juce::CodeDocument>> codeDocuments;
|
std::vector<std::shared_ptr<juce::CodeDocument>> codeDocuments;
|
||||||
std::vector<std::shared_ptr<OscirenderCodeEditorComponent>> codeEditors;
|
std::vector<std::shared_ptr<OscirenderCodeEditorComponent>> codeEditors;
|
||||||
juce::CodeEditorComponent::ColourScheme colourScheme;
|
juce::CodeEditorComponent::ColourScheme colourScheme;
|
||||||
|
|
Ładowanie…
Reference in New Issue