diff --git a/Source/Processors/Editors/ParameterEditor.cpp b/Source/Processors/Editors/ParameterEditor.cpp index 1173c1318b9872660e725449c747fe466f23f4a2..7c72d36355cded30999045220ced7af5ced62648 100644 --- a/Source/Processors/Editors/ParameterEditor.cpp +++ b/Source/Processors/Editors/ParameterEditor.cpp @@ -30,9 +30,16 @@ ParameterEditor::ParameterEditor(Parameter& p, Font labelFont) { std::cout << "Boolean parameter. Creating checkbox." << std::endl; // create checkbox - //ParameterCheckbox* pc = new ParameterCheckbox(p.getName()); - //addAndMakeVisible(pc); - //pc->setBounds(0,0,getWidth(), getHeight()); + ParameterCheckbox* pc = new ParameterCheckbox((bool) p.getDefaultValue()); + addAndMakeVisible(pc); + pc->setBounds(0,0,12, 12); + + Label* label = new Label(p.getName(), p.getName()); + labelFont.setHeight(10); + label->setColour(Label::textColourId, Colours::darkgrey); + label->setFont(labelFont); + label->setBounds(10, 1, 100, 10); + addAndMakeVisible(label); } else if (p.isContinuous()) { @@ -86,46 +93,6 @@ ParameterEditor::~ParameterEditor() deleteAllChildren(); } -void ParameterEditor::paint(Graphics& g) -{ - - // Path p; - // PathStrokeType pst = PathStrokeType(2.0f); - - // float radius = 10.0f; - - // p.startNewSubPath(0, radius); - // p.addArc(0, 0, radius*2, radius*2, 1.5*double_Pi, 2.0*double_Pi ); - - // p.lineTo(getWidth() - radius, 0);//getHeight()); - // p.addArc(getWidth()-radius*2, 0, radius*2, radius*2, 0, 0.5*double_Pi); - - // p.lineTo(getWidth(), getHeight()-radius); - // p.addArc(getWidth()-radius*2, getHeight()-radius*2, radius*2, radius*2, 0.5*double_Pi, double_Pi); - - // p.lineTo(radius, getHeight()); - // p.addArc(0, getHeight()-radius*2, radius*2, radius*2, double_Pi, 1.5*double_Pi); - // p.closeSubPath(); - // //p.lineTo(0, radius); - - // g.setColour(Colours::grey); - // //g.strokePath(p, pst); - // g.fillPath(p); - // //g.setColour(Colours::grey) - // ColourGradient grad = ColourGradient(Colour(220,220,220),0.0,0.0, - // Colour(170,170,170),0.0, getHeight(), - // false); - // //grad.addColour(0.5f, Colour(50,50,50)); - // g.setGradientFill(grad); - - // AffineTransform a = AffineTransform::scale(0.98f, 0.94f, float(getWidth())/2.0f, - // float(getHeight())/2.0f); - // //a.scaled(0.7, 0.7); - // g.fillPath(p, a); - - - -} /// ============= PARAMETER BUTTON ================== @@ -229,3 +196,51 @@ void ParameterButton::resized() } } + +// ==== PARAMETER CHECKBOX ======================= + + +ParameterCheckbox::ParameterCheckbox(bool defaultState) : Button("name") +{ + setToggleState(defaultState, false); + setClickingTogglesState(true); + + selectedGrad = ColourGradient(Colour(240,179,12),0.0,0.0, + Colour(207,160,33),0.0, 20.0f, + true); + selectedOverGrad = ColourGradient(Colour(209,162,33),0.0, 5.0f, + Colour(190,150,25),0.0, 0.0f, + true); + neutralGrad = ColourGradient(Colour(220,220,220),0.0,0.0, + Colour(170,170,170),0.0, 20.0f, + true); + neutralOverGrad = ColourGradient(Colour(180,180,180),0.0,5.0f, + Colour(150,150,150),0.0, 0.0, + true); +} + +void ParameterCheckbox::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown) +{ + + g.setColour(Colours::grey); + g.fillRoundedRectangle(0, 0, getWidth(), getHeight(), 2.0f); + + if (getToggleState()) + { + if (isMouseOver) + g.setGradientFill(selectedOverGrad); + else + g.setGradientFill(selectedGrad); + } else { + if (isMouseOver) + g.setGradientFill(neutralOverGrad); + else + g.setGradientFill(neutralGrad); + } + + AffineTransform a = AffineTransform::scale(0.98f, 0.94f, float(getWidth())/2.0f, + float(getHeight())/2.0f); + + g.fillRoundedRectangle(1, 1, getWidth()-2, getHeight()-2, 2.0f); + +} \ No newline at end of file diff --git a/Source/Processors/Editors/ParameterEditor.h b/Source/Processors/Editors/ParameterEditor.h index 7dbf4f9318db0ab8a118cb3f80ef1949be0b02f1..d364ccee836422fb78b94dc4c42a4f2dd4453fce 100644 --- a/Source/Processors/Editors/ParameterEditor.h +++ b/Source/Processors/Editors/ParameterEditor.h @@ -48,8 +48,6 @@ public: private: - void paint(Graphics& g); - Array<Component*> componentArray; enum { @@ -93,4 +91,20 @@ private: }; +class ParameterCheckbox : public Button + +{ +public: + ParameterCheckbox(bool defaultState); + ~ParameterCheckbox() {} + +private: + void paintButton(Graphics& g, bool isMouseOver, bool isButtonDown); + + ColourGradient selectedGrad; + ColourGradient selectedOverGrad; + ColourGradient neutralGrad; + ColourGradient neutralOverGrad; +}; + #endif // __PARAMETEREDITOR_H_44537DA9__ diff --git a/Source/Processors/SignalGenerator.cpp b/Source/Processors/SignalGenerator.cpp index 76234e65c99cb8f6888cf309964947fde72ac624..5fcb29f6ecd5e8f614a65d838cd6d89cfb7c9e6b 100644 --- a/Source/Processors/SignalGenerator.cpp +++ b/Source/Processors/SignalGenerator.cpp @@ -43,7 +43,7 @@ SignalGenerator::SignalGenerator() a.add(2); a.add(3); - Parameter p = Parameter("Paramter name",a,0); + Parameter p = Parameter("Parameter name",true);//a,0); parameters.add(p);