1- /*
2- ==============================================================================
3-
4- Knob.cpp
5- Created: 24 Nov 2024 5:30:19pm
6- Author: Martin
7-
8- ==============================================================================
9- */
10-
111#include " MyLookAndFeel.h"
122
13- Knob::Knob () :juce::Slider(juce::Slider::SliderStyle::RotaryVerticalDrag, TextBoxBelow ) {
3+ Knob::Knob () :juce::Slider(juce::Slider::SliderStyle::RotaryVerticalDrag, NoTextBox ) {
144 this ->setLookAndFeel (&this ->lookAndFeel );
155 this ->setPopupDisplayEnabled (true , false , nullptr );
166}
@@ -19,10 +9,8 @@ void Knob::paint(juce::Graphics& g) {
199 this ->lookAndFeel .drawRotarySlider (g, this ->getLocalBounds ().getX (), this ->getLocalBounds ().getY (), this ->getLocalBounds ().getWidth (), this ->getLocalBounds ().getHeight (), this ->getNormalisableRange ().convertTo0to1 (this ->getValue ()), 0 .0f , 360 .0f , *this );
2010}
2111
22- juce::String Knob::getTextFromValue (double value)
23- {
24- // return juce::String((this->getNormalisableRange().convertTo0to1(value)) * 10.0f, 1);
25- return juce::String (this ->getValue ());
12+ juce::String Knob::getTextFromValue (double value){
13+ return juce::String ((this ->getNormalisableRange ().convertTo0to1 (value)) * 10 .0f , 1 );
2614}
2715
2816Knob::~Knob () {
@@ -89,7 +77,6 @@ void MyLookAndFeel::drawLinearSlider(juce::Graphics& g, int x, int y, int width,
8977 g.setColour (slider.findColour (juce::Slider::trackColourId));
9078 g.strokePath (valueTrack, { trackWidth, juce::PathStrokeType::curved, juce::PathStrokeType::rounded });
9179
92- // g.setColour(slider.findColour(juce::Slider::thumbColourId));
9380 juce::ColourGradient thumbGradient (slider.findColour (juce::Slider::thumbColourId).contrasting (), maxPoint - juce::Point<float >(thumbWidth / 2 , 0 ), slider.findColour (juce::Slider::thumbColourId), maxPoint - juce::Point<float >(0 .7f * thumbWidth / 2 , 0 ), true );
9481 g.setGradientFill (thumbGradient);
9582 g.fillEllipse (juce::Rectangle<float >(static_cast <float > (thumbWidth), static_cast <float > (thumbWidth)).withCentre (maxPoint));
@@ -116,12 +103,10 @@ Switch::Switch(std::atomic<float>* position, const void* imageOffData, int image
116103
117104void Switch::changeState () {
118105 if (!this ->getToggleState ()) {
119- // this->powerButton.setToggleState(false, juce::NotificationType::dontSendNotification);
120106 this ->setImages (false , true , true , juce::ImageCache::getFromMemory (imageOffData, imageOffSize), 1 .0f , juce::Colours::transparentWhite, juce::Image (), 1 .0f , juce::Colours::transparentWhite, juce::Image (), 1 .0f , juce::Colours::transparentWhite);
121107 this ->repaint ();
122108 }
123109 else {
124- // this->powerButton.setToggleState(true, juce::NotificationType::dontSendNotification);
125110 this ->setImages (false , true , true , juce::ImageCache::getFromMemory (imageOnData, imageOnSize), 1 .0f , juce::Colours::transparentWhite, juce::Image (), 1 .0f , juce::Colours::transparentWhite, juce::Image (), 1 .0f , juce::Colours::transparentWhite);
126111 this ->repaint ();
127112 }
0 commit comments