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);
|
||||
auto baseColour = label.findColour(juce::Label::backgroundColourId);
|
||||
if (label.isEditable()) {
|
||||
label.setMouseCursor(juce::MouseCursor::IBeamCursor);
|
||||
juce::MessageManager::callAsync(
|
||||
[&label] () {
|
||||
label.setMouseCursor(juce::MouseCursor::IBeamCursor);
|
||||
}
|
||||
);
|
||||
baseColour = LookAndFeelHelpers::createBaseColour(baseColour, false, label.isMouseOver(true), false, label.isEnabled());
|
||||
}
|
||||
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) {
|
||||
juce::Rectangle<int> boxBounds{0, 0, width, height};
|
||||
box.setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
||||
juce::MessageManager::callAsync(
|
||||
[&box] () {
|
||||
box.setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
||||
}
|
||||
);
|
||||
|
||||
g.setColour(box.findColour(juce::ComboBox::backgroundColourId));
|
||||
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) {
|
||||
button.setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
||||
juce::MessageManager::callAsync(
|
||||
[&button] () {
|
||||
button.setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
||||
}
|
||||
);
|
||||
|
||||
auto bounds = button.getLocalBounds().toFloat().reduced(0.5f, 0.5f);
|
||||
|
||||
|
|
|
@ -20,6 +20,16 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioPr
|
|||
}
|
||||
#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);
|
||||
console.setConsoleOpen(false);
|
||||
|
||||
|
@ -149,6 +159,9 @@ void OscirenderAudioProcessorEditor::resized() {
|
|||
if (!usingNativeMenuBar) {
|
||||
menuBar.setBounds(area.removeFromTop(25));
|
||||
}
|
||||
|
||||
toolbar.setBounds(area.removeFromTop(50));
|
||||
toolbar.setEditingActive(true);
|
||||
|
||||
area.removeFromTop(2);
|
||||
area.removeFromLeft(3);
|
||||
|
|
|
@ -10,6 +10,86 @@
|
|||
#include "components/ErrorCodeEditorComponent.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 {
|
||||
public:
|
||||
OscirenderAudioProcessorEditor(OscirenderAudioProcessor&);
|
||||
|
@ -57,6 +137,9 @@ public:
|
|||
|
||||
LuaConsole console;
|
||||
|
||||
DemoToolbarItemFactory factory;
|
||||
juce::Toolbar toolbar;
|
||||
|
||||
std::vector<std::shared_ptr<juce::CodeDocument>> codeDocuments;
|
||||
std::vector<std::shared_ptr<OscirenderCodeEditorComponent>> codeEditors;
|
||||
juce::CodeEditorComponent::ColourScheme colourScheme;
|
||||
|
|
Ładowanie…
Reference in New Issue