void drawLinearSliderThumb (Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle style, Slider& slider) override { const float sliderRadius = (float) getSliderThumbRadius (slider); bool isDownOrDragging = slider.isEnabled() && (slider.isMouseOverOrDragging() || slider.isMouseButtonDown()); Colour knobColour (slider.findColour (Slider::rotarySliderFillColourId).withMultipliedSaturation ((slider.hasKeyboardFocus (false) || isDownOrDragging) ? 1.3f : 0.9f) .withMultipliedAlpha (slider.isEnabled() ? 1.0f : 0.7f)); g.setColour (knobColour); if (style == Slider::LinearHorizontal || style == Slider::LinearVertical) { float kx, ky; if (style == Slider::LinearVertical) { kx = x + width * 0.5f; ky = sliderPos; g.fillRect (Rectangle<float> (kx - sliderRadius, ky - 2.5f, sliderRadius * 2.0f, 5.0f)); } else { kx = sliderPos; ky = y + height * 0.5f; g.fillRect (Rectangle<float> (kx - 2.5f, ky - sliderRadius, 5.0f, sliderRadius * 2.0f)); } } else { // Just call the base class for the demo LookAndFeel_V2::drawLinearSliderThumb (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider); } }
void drawLinearSliderBackground (Graphics& g, int x, int y, int width, int height, float /*sliderPos*/, float /*minSliderPos*/, float /*maxSliderPos*/, const Slider::SliderStyle /*style*/, Slider& slider) override { const float sliderRadius = getSliderThumbRadius (slider) - 5.0f; Path on, off; if (slider.isHorizontal()) { const float iy = y + height * 0.5f - sliderRadius * 0.5f; Rectangle<float> r (x - sliderRadius * 0.5f, iy, width + sliderRadius, sliderRadius); const float onW = r.getWidth() * ((float) slider.valueToProportionOfLength (slider.getValue())); on.addRectangle (r.removeFromLeft (onW)); off.addRectangle (r); } else { const float ix = x + width * 0.5f - sliderRadius * 0.5f; Rectangle<float> r (ix, y - sliderRadius * 0.5f, sliderRadius, height + sliderRadius); const float onH = r.getHeight() * ((float) slider.valueToProportionOfLength (slider.getValue())); on.addRectangle (r.removeFromBottom (onH)); off.addRectangle (r); } g.setColour (slider.findColour (Slider::rotarySliderFillColourId)); g.fillPath (on); g.setColour (slider.findColour (Slider::trackColourId)); g.fillPath (off); }
void preenfmLookAndFeel::drawLinearSliderThumb (Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle style, Slider& slider) { if (!slider.isEnabled()) { return; } const float sliderRadius = (float) (getSliderThumbRadius (slider) - 2); Colour knobColour (createBaseColourPFM2 (slider.findColour (Slider::thumbColourId), slider.hasKeyboardFocus (false) && slider.isEnabled(), slider.isMouseOverOrDragging() && slider.isEnabled(), slider.isMouseButtonDown() && slider.isEnabled())); const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f; if (style == Slider::LinearHorizontal || style == Slider::LinearVertical) { float kx, ky; if (style == Slider::LinearVertical) { kx = x + width * 0.5f; ky = sliderPos; } else { kx = sliderPos; ky = y + height * 0.5f; } // drawGlassSphere (g, // kx - sliderRadius, // ky - sliderRadius, // sliderRadius * 2.0f, // knobColour, outlineThickness); if (slider.isEnabled()) { g.setColour(knobColour); g.fillRect( kx - sliderRadius + 3, ky - sliderRadius, sliderRadius*2 - 6, sliderRadius*2); g.setColour(Colours::grey); } else { g.setColour (Colour (0x80808080)); } g.drawRect( kx - sliderRadius + 3, ky - sliderRadius, sliderRadius*2 - 6, sliderRadius*2); } else { LookAndFeel_V2::drawLinearSliderThumb (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider); } }
void CustomLookAndFeel::drawLinearSliderBackground(Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle /*style*/, Slider& slider) { const float sliderRadius = (float)(getSliderThumbRadius(slider) - 2); Path indent; // Path backgroundPath; if (slider.isHorizontal()) { const float iy = y + height * 0.5f - sliderRadius * 0.5f; const float ih = sliderRadius; indent.addRoundedRectangle(x - sliderRadius * 0.5f, iy, width + sliderRadius, ih, 5.0f); // backgroundPath.addRoundedRectangle (x - sliderRadius * 0.5f, iy, // (width + sliderRadius)*minSliderPos, ih, // 5.0f); // g.setColour(Colours::orange); // g.fillPath (backgroundPath); } else { const float ix = x + width * 0.5f - sliderRadius * 0.5f; const float iw = sliderRadius; indent.addRoundedRectangle(ix, y - sliderRadius * 0.5f, iw, height + sliderRadius, 5.0f); // backgroundPath.addRoundedRectangle (ix, y - sliderRadius * 0.5f, // iw, (height + sliderRadius)*sliderPos, // 5.0f); // g.setColour(Colours::orange); // g.fillPath (backgroundPath); //g.fillPath (indent); } g.setColour(Colours::darkgrey); g.strokePath(indent, PathStrokeType(0.5f)); }
void pMixLookAndFeel::drawLinearSliderBackground (Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle, Slider& slider) { const float sliderRadius = (float) (getSliderThumbRadius (slider) - 3); const Colour trackColour (slider.findColour (Slider::trackColourId)); //const Colour trackColour = Colours::darkgrey; const Colour gradCol1 (trackColour.overlaidWith (Colour (slider.isEnabled() ? 0x13000000 : 0x09000000))); const Colour gradCol2 (trackColour.overlaidWith (Colour (0x06000000))); //Path indent; if (slider.isHorizontal()) { g.setColour (trackColour); const float iy = y + height * 0.5f - sliderRadius * 0.5f; g.fillRect((float)x, iy, (float)width, (float)4); // // // //g.setGradientFill (ColourGradient (gradCol1, 0.0f, iy, // // gradCol2, 0.0f, iy + sliderRadius, false)); // // indent.addRoundedRectangle (x - sliderRadius * 0.5f, iy, width + sliderRadius, sliderRadius, 5.0f); } // else // { // const float ix = x + width * 0.5f - sliderRadius * 0.5f; // // // //g.setGradientFill (ColourGradient (gradCol1, ix, 0.0f, // // gradCol2, ix + sliderRadius, 0.0f, false)); // // indent.addRoundedRectangle (ix, y - sliderRadius * 0.5f, sliderRadius, height + sliderRadius, 5.0f); // } //g.fillPath (indent); //g.setColour (trackColour.contrasting (0.5f)); //g.strokePath (indent, PathStrokeType (0.5f)); }
void MuteLookAndFeel::drawLinearSliderThumb(Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle style, Slider& slider) { const float sliderRadius = (float)(getSliderThumbRadius(slider) - 2); bool isDownOrDragging = slider.isEnabled() && (slider.isMouseOverOrDragging() || slider.isMouseButtonDown()); Colour knobColour(slider.findColour(Slider::thumbColourId).withMultipliedSaturation((slider.hasKeyboardFocus(false) || isDownOrDragging) ? 1.3f : 0.9f) .withMultipliedAlpha(slider.isEnabled() ? 1.0f : 0.7f)); if (style == Slider::LinearHorizontal || style == Slider::LinearVertical) { float kx, ky; if (style == Slider::LinearVertical) { kx = x + width * 0.5f; ky = sliderPos; } else { kx = sliderPos; ky = y + height * 0.5f; } const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f; drawRoundThumb(g, kx - sliderRadius, ky - sliderRadius, sliderRadius * 2.0f, knobColour, outlineThickness); } else { // Just call the base class for the demo LookAndFeel_V2::drawLinearSliderThumb(g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider); } }
void pMixLookAndFeel::drawLinearSliderThumb (Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle style, Slider& slider) { const float sliderRadius = (float) (getSliderThumbRadius (slider) - 2); PMixParamSlider * pmixslider = dynamic_cast<PMixParamSlider*>(&slider); Colour knobColour; if (pmixslider) { knobColour = (LookAndFeelHelpers::createBaseColour (pmixslider->getSliderColour(), slider.hasKeyboardFocus (false) && slider.isEnabled(), slider.isMouseOverOrDragging() && slider.isEnabled(), slider.isMouseButtonDown() && slider.isEnabled())); } else { knobColour = (LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId), slider.hasKeyboardFocus (false) && slider.isEnabled(), slider.isMouseOverOrDragging() && slider.isEnabled(), slider.isMouseButtonDown() && slider.isEnabled())); } //const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f; if (style == Slider::LinearHorizontal || style == Slider::LinearVertical) { float kx, ky; if (style == Slider::LinearVertical) { kx = x + width * 0.5f; ky = sliderPos; } else { kx = sliderPos; ky = y + height * 0.5f; } Path p; p.addEllipse (kx - sliderRadius, ky - sliderRadius, sliderRadius * 2.0f, sliderRadius * 2.0f); g.setColour(knobColour); g.fillPath (p); g.setColour(Colours::darkgrey); g.drawEllipse(kx - sliderRadius, ky - sliderRadius, sliderRadius * 2.0f, sliderRadius * 2.0f, 1.f); // drawGlassSphere (g, // kx - sliderRadius, // ky - sliderRadius, // sliderRadius * 2.0f, // knobColour, outlineThickness); } // else // { // if (style == Slider::ThreeValueVertical) // { // drawGlassSphere (g, x + width * 0.5f - sliderRadius, // sliderPos - sliderRadius, // sliderRadius * 2.0f, // knobColour, outlineThickness); // } // else if (style == Slider::ThreeValueHorizontal) // { // drawGlassSphere (g,sliderPos - sliderRadius, // y + height * 0.5f - sliderRadius, // sliderRadius * 2.0f, // knobColour, outlineThickness); // } // // if (style == Slider::TwoValueVertical || style == Slider::ThreeValueVertical) // { // const float sr = jmin (sliderRadius, width * 0.4f); // // drawGlassPointer (g, jmax (0.0f, x + width * 0.5f - sliderRadius * 2.0f), // minSliderPos - sliderRadius, // sliderRadius * 2.0f, knobColour, outlineThickness, 1); // // drawGlassPointer (g, jmin (x + width - sliderRadius * 2.0f, x + width * 0.5f), maxSliderPos - sr, // sliderRadius * 2.0f, knobColour, outlineThickness, 3); // } // else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal) // { // const float sr = jmin (sliderRadius, height * 0.4f); // // drawGlassPointer (g, minSliderPos - sr, // jmax (0.0f, y + height * 0.5f - sliderRadius * 2.0f), // sliderRadius * 2.0f, knobColour, outlineThickness, 2); // // drawGlassPointer (g, maxSliderPos - sliderRadius, // jmin (y + height - sliderRadius * 2.0f, y + height * 0.5f), // sliderRadius * 2.0f, knobColour, outlineThickness, 4); // } // } }
void CustomLookAndFeel::drawLinearSliderThumb(Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle style, Slider& slider) { const float sliderRadius = (float)(getSliderThumbRadius(slider) - 2); Colour knobColour(Colours::darkgrey); //LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId), // slider.hasKeyboardFocus (false) && slider.isEnabled(), // slider.isMouseOverOrDragging() && slider.isEnabled(), // slider.isMouseButtonDown() && slider.isEnabled())); const float outlineThickness = slider.isEnabled() ? 2.0f : 0.5f; if (style == Slider::LinearHorizontal || style == Slider::LinearVertical) { float kx, ky; if (style == Slider::LinearVertical) { kx = x + width * 0.5f; ky = sliderPos; } else { kx = sliderPos; ky = y + height * 0.5f; } drawSliderKnob(g, kx - sliderRadius, ky - sliderRadius, sliderRadius * 2.0f, knobColour, outlineThickness); } else { if (style == Slider::ThreeValueVertical) { drawSliderKnob(g, x + width * 0.5f - sliderRadius, sliderPos - sliderRadius, sliderRadius * 2.0f, knobColour, outlineThickness); } else if (style == Slider::ThreeValueHorizontal) { drawSliderKnob(g,sliderPos - sliderRadius, y + height * 0.5f - sliderRadius, sliderRadius * 2.0f, knobColour, outlineThickness); } if (style == Slider::TwoValueVertical || style == Slider::ThreeValueVertical) { const float sr = jmin(sliderRadius, width * 0.4f); drawGlassPointer(g, jmax(0.0f, x + width * 0.5f - sliderRadius * 2.0f), minSliderPos - sliderRadius, sliderRadius * 2.0f, knobColour, outlineThickness, 1); drawGlassPointer(g, jmin(x + width - sliderRadius * 2.0f, x + width * 0.5f), maxSliderPos - sr, sliderRadius * 2.0f, knobColour, outlineThickness, 3); } else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal) { const float sr = jmin(sliderRadius, height * 0.4f); drawGlassPointer(g, minSliderPos - sr, jmax(0.0f, y + height * 0.5f - sliderRadius * 2.0f), sliderRadius * 2.0f, knobColour, outlineThickness, 2); drawGlassPointer(g, maxSliderPos - sliderRadius, jmin(y + height - sliderRadius * 2.0f, y + height * 0.5f), sliderRadius * 2.0f, knobColour, outlineThickness, 4); } } }
Slider::SliderLayout NTLookAndFeel::getSliderLayout(juce::Slider &slider){ // 1. compute the actually visible textBox size from the slider textBox size and some additional constraints int minXSpace = 0; int minYSpace = 0; Slider::TextEntryBoxPosition textBoxPos = slider.getTextBoxPosition(); if (textBoxPos == Slider::TextBoxLeft || textBoxPos == Slider::TextBoxRight) minXSpace = 30; else minYSpace = 15; Rectangle<int> localBounds = slider.getLocalBounds(); const int textBoxWidth = jmax (0, jmin (slider.getTextBoxWidth(), localBounds.getWidth() - minXSpace)); const int textBoxHeight = jmax (0, jmin (slider.getTextBoxHeight(), localBounds.getHeight() - minYSpace)); Slider::SliderLayout layout; // 2. set the textBox bounds if (textBoxPos != Slider::NoTextBox) { if (slider.isBar()) { layout.textBoxBounds = localBounds; } else { layout.textBoxBounds.setWidth (textBoxWidth); layout.textBoxBounds.setHeight (textBoxHeight); if (textBoxPos == Slider::TextBoxLeft) layout.textBoxBounds.setX (0); else if (textBoxPos == Slider::TextBoxRight) layout.textBoxBounds.setX (localBounds.getWidth() - textBoxWidth); else /* above or below -> centre horizontally */ layout.textBoxBounds.setX ((localBounds.getWidth() - textBoxWidth) / 2); if (textBoxPos == Slider::TextBoxAbove) layout.textBoxBounds.setY (0); else if (textBoxPos == Slider::TextBoxBelow) layout.textBoxBounds.setY (localBounds.getHeight() - textBoxHeight); else /* left or right -> centre vertically */ layout.textBoxBounds.setY ((localBounds.getHeight() - textBoxHeight) / 2); } } // 3. set the slider bounds layout.sliderBounds = localBounds; if (slider.isBar()) { layout.sliderBounds.reduce (1, 1); // bar border } else { if (textBoxPos == Slider::TextBoxLeft) layout.sliderBounds.removeFromLeft (textBoxWidth + 10); else if (textBoxPos == Slider::TextBoxRight) layout.sliderBounds.removeFromRight (textBoxWidth); else if (textBoxPos == Slider::TextBoxAbove) layout.sliderBounds.removeFromTop (textBoxHeight); else if (textBoxPos == Slider::TextBoxBelow) layout.sliderBounds.removeFromBottom (textBoxHeight); const int thumbIndent = getSliderThumbRadius (slider); if (slider.isHorizontal()) layout.sliderBounds.reduce (thumbIndent, 0); else if (slider.isVertical()) layout.sliderBounds.reduce (0, thumbIndent); } return layout; }
void TCATLookAndFeel::drawLinearSlider (Graphics& g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle style, Slider& slider) { g.fillAll (slider.findColour (Slider::backgroundColourId)); const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled(); if (style == Slider::LinearBar) { Colour baseColour (createBaseColour (slider.findColour (Slider::thumbColourId) .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f), false, isMouseOver, isMouseOver || slider.isMouseButtonDown())); drawShinyButtonShape (g, (float) x, (float) y, sliderPos - (float) x, (float) height, 0.0f, baseColour, slider.isEnabled() ? 0.9f : 0.3f, true, true, true, true); } else { const float sliderRadius = (float) getSliderThumbRadius (slider); const Colour trackColour (slider.findColour (Slider::trackColourId)); const Colour gradCol1 (trackColour.overlaidWith (Colours::black.withAlpha (slider.isEnabled() ? 0.25f : 0.13f))); const Colour gradCol2 (trackColour.overlaidWith (Colours::black.withAlpha (0.08f))); Path indent; if (slider.isHorizontal()) { const float iy = y + height * 0.5f - sliderRadius * 0.5f; const float ih = sliderRadius; ColourGradient cg (gradCol1, 0.0f, iy, gradCol2, 0.0f, iy + ih, false); g.setGradientFill(cg); indent.addRoundedRectangle (x - sliderRadius * 0.5f, iy, width + sliderRadius, ih, 5.0f); g.fillPath (indent); } else { const float ix = x + width * 0.5f - sliderRadius * 0.5f; const float iw = sliderRadius; ColourGradient cg (gradCol1, ix, 0.0f, gradCol2, ix + iw, 0.0f, false); g.setGradientFill(cg); indent.addRoundedRectangle (ix, y - sliderRadius * 0.5f, iw, height + sliderRadius, 5.0f); g.fillPath (indent); } g.setColour (Colours::black.withAlpha (0.3f)); g.strokePath (indent, PathStrokeType (0.5f)); Colour knobColour (createBaseColour (slider.findColour (Slider::thumbColourId), slider.hasKeyboardFocus (false) && slider.isEnabled(), isMouseOver, slider.isMouseButtonDown() && slider.isEnabled())); const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f; if (style == Slider::LinearHorizontal || style == Slider::LinearVertical) { float kx, ky; if (style == Slider::LinearVertical) { kx = x + width * 0.5f; ky = sliderPos; } else { kx = sliderPos; ky = y + height * 0.5f; } drawGlassSphere (g, kx - sliderRadius, ky - sliderRadius, sliderRadius * 2.0f, knobColour, outlineThickness); } else { if (style == Slider::ThreeValueVertical) { drawGlassSphere (g, x + width * 0.5f - sliderRadius, sliderPos - sliderRadius, sliderRadius * 2.0f, knobColour, outlineThickness); } else if (style == Slider::ThreeValueHorizontal) { drawGlassSphere (g,sliderPos - sliderRadius, y + height * 0.5f - sliderRadius, sliderRadius * 2.0f, knobColour, outlineThickness); } if (style == Slider::TwoValueVertical || style == Slider::ThreeValueVertical) { const float sr = jmin (sliderRadius, width * 0.4f); drawGlassPointer (g, jmax (0.0f, x + width * 0.5f - sliderRadius * 2.0f), minSliderPos - sliderRadius, sliderRadius * 2.0f, knobColour, outlineThickness, 1); drawGlassPointer (g, jmin (x + width - sliderRadius * 2.0f, x + width * 0.5f), maxSliderPos - sr, sliderRadius * 2.0f, knobColour, outlineThickness, 3); } else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal) { const float sr = jmin (sliderRadius, height * 0.4f); drawGlassPointer (g, minSliderPos - sr, jmax (0.0f, y + height * 0.5f - sliderRadius * 2.0f), sliderRadius * 2.0f, knobColour, outlineThickness, 2); drawGlassPointer (g, maxSliderPos - sliderRadius, jmin (y + height - sliderRadius * 2.0f, y + height * 0.5f), sliderRadius * 2.0f, knobColour, outlineThickness, 4); } } } }