Skip to content

Commit

Permalink
#5 - Make corners of button tooltip transparent
Browse files Browse the repository at this point in the history
  • Loading branch information
cornzz committed Jun 29, 2020
1 parent 1ebb38a commit 9208f3b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
1 change: 0 additions & 1 deletion Source/Level1Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Level1Editor::Level1Editor(Ckpa_compressorAudioProcessor& p) : processor(p)
int editorHeight = 2 * editorMargin;
for (int i = 0; i < parameters.size() - 1; ++i) {
if (const AudioProcessorParameterWithID* parameter = dynamic_cast<AudioProcessorParameterWithID*> (parameters[i])) {

if (processor.parameters.parameterTypes[i] == "Slider") {
Slider* aSlider;
sliders.add(aSlider = new Slider());
Expand Down
1 change: 0 additions & 1 deletion Source/Level1Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Level1Editor : public Component
sliderTextEntryBoxWidth = 100,
sliderTextEntryBoxHeight = 25,
sliderHeight = 25,
buttonHeight = 25,
levelMeterHeight = 20,
labelWidth = 100
};
Expand Down
6 changes: 3 additions & 3 deletions Source/Level3Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class Level3Editor : public Component,
bool init = true;
bool dragging = false;

float circleDiameter = 0;
int numAtoms = 74;

OwnedArray<Slider> sliders;
typedef AudioProcessorValueTreeState::SliderAttachment SliderAttachment;
OwnedArray<SliderAttachment> sliderAttachments;
Expand All @@ -116,9 +119,6 @@ class Level3Editor : public Component,
OwnedArray<Atom> atoms;
std::vector<int> visibleAtoms, invisibleAtoms;

float circleDiameter = 0;
int numAtoms = 74;

//==============================================================================

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Level3Editor)
Expand Down
40 changes: 23 additions & 17 deletions Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ Ckpa_compressorAudioProcessorEditor::Ckpa_compressorAudioProcessorEditor(Ckpa_co
processor(p),
tabs(p, new Level1Editor(p), new Level2Editor(p), new Level3Editor(p))
{
setSize(editorWidth, 383);
addAndMakeVisible(tabs);

//======================================
Colour backgroundColour = findColour(ResizableWindow::backgroundColourId);
Colour sliderThumbColour = findColour(Slider::thumbColourId);
tooltipWindow->setOpaque(false);
tooltipWindow->setColour(TooltipWindow::backgroundColourId, Colours::transparentWhite);

const Array<AudioProcessorParameter*> parameters = processor.getParameters();
//Power Button
ShapeButton* powerButton;
buttons.add(powerButton = new ShapeButton("powerButton",
findColour(Slider::thumbColourId),
findColour(Slider::thumbColourId).brighter(0.1),
findColour(Slider::thumbColourId).darker(0.15)));
sliderThumbColour,
sliderThumbColour.brighter(0.1),
sliderThumbColour.darker(0.15)));
// On and off colour sets are switched around, since this used to be the "bypass button"
powerButton->setOnColours(findColour(ResizableWindow::backgroundColourId),
findColour(ResizableWindow::backgroundColourId).brighter(0.1),
findColour(Slider::thumbColourId).darker(0.2));
powerButton->setOnColours(backgroundColour,
backgroundColour.brighter(0.1),
sliderThumbColour.darker(0.2));
powerButton->shouldUseOnColours(true);
powerButton->setTooltip("Bypass");
Path pbPath;
Expand All @@ -57,24 +57,25 @@ Ckpa_compressorAudioProcessorEditor::Ckpa_compressorAudioProcessorEditor(Ckpa_co
buttonAttachments.add(powerButtonAttachment = new ButtonAttachment(processor.parameters.valueTreeState, buttonParameter->paramID, *powerButton));
addAndMakeVisible(powerButton);
powerButton->setClickingTogglesState(true);
Rectangle<int> rPower = getLocalBounds();
powerButton->setBounds(rPower.removeFromBottom(39).removeFromRight(39)); // TODO: Should be done in resized()

//Reset Button
ShapeButton* resetButton;
buttons.add(resetButton = new ShapeButton("resetButton",
getLookAndFeel().findColour(Slider::thumbColourId),
getLookAndFeel().findColour(Slider::thumbColourId).brighter(0.1),
getLookAndFeel().findColour(Slider::thumbColourId).darker(0.15)));
sliderThumbColour,
sliderThumbColour.brighter(0.1),
sliderThumbColour.darker(0.15)));
resetButton->setTooltip("Reset");
Path rbPath;
rbPath.restoreFromString(resetButtonPath);
resetButton->setShape(rbPath, true, true, true);

resetButton->onClick = [this] { resetParameters(); };
addAndMakeVisible(resetButton);
Rectangle<int> rReset = getLocalBounds();
resetButton->setBounds(rReset.removeFromBottom(39).withTrimmedRight(39).removeFromRight(39)); // TODO: Should be done in resized()

//======================================

addAndMakeVisible(tabs, 0);
setSize(editorWidth, 383);
}

Ckpa_compressorAudioProcessorEditor::~Ckpa_compressorAudioProcessorEditor()
Expand All @@ -90,6 +91,11 @@ void Ckpa_compressorAudioProcessorEditor::resized()
{
Rectangle<int> r = getLocalBounds();
tabs.setBounds(r);

r = r.removeFromBottom(39);
for (ShapeButton* sb : buttons) {
sb->setBounds(r.removeFromRight(39));
}
}

void Ckpa_compressorAudioProcessorEditor::resetParameters()
Expand Down
3 changes: 2 additions & 1 deletion Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ class Ckpa_compressorAudioProcessorEditor : public AudioProcessorEditor
// This reference is provided as a quick way for your editor to
// access the processor object that created it.
Ckpa_compressorAudioProcessor& processor;
SharedResourcePointer<TooltipWindow> tooltipWindow;

enum {
editorWidth = 500,
editorMargin = 10,
editorPadding = 10,
};

SharedResourcePointer<TooltipWindow> tooltipWindow;

void resetParameters();

OwnedArray<ShapeButton> buttons;
Expand Down
2 changes: 1 addition & 1 deletion Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
==============================================================================
*/

#include "PluginProcessor.h"
#include "PluginEditor.h"
#include "PluginParameters.h"

//==============================================================================

Expand Down

0 comments on commit 9208f3b

Please sign in to comment.