Example #1
1
void Oscilloscope::paint(Graphics& g) {
  static const DropShadow shadow(Colour(0xbb000000), 5, Point<int>(0, 0));
  g.drawImageWithin(background_,
                    0, 0, getWidth(), getHeight(), RectanglePlacement());

  shadow.drawForPath(g, wave_path_);

  g.setColour(Colour(0xff565656));
  g.fillPath(wave_path_);
  g.setColour(Colour(0xffaaaaaa));
  g.strokePath(wave_path_, PathStrokeType(1.0f, PathStrokeType::beveled, PathStrokeType::rounded));
}
Example #2
0
void XYPad::paint(Graphics& g) {
  static const PathStrokeType stroke(1.5f, PathStrokeType::beveled, PathStrokeType::rounded);
  static const DropShadow shadow(Colour(0xbb000000), 5, Point<int>(0, 0));

  g.drawImage(background_,
              0, 0, getWidth(), getHeight(),
              0, 0, background_.getWidth(), background_.getHeight());

  float x = x_slider_->getValue() * getWidth();
  float y = (1.0f - y_slider_->getValue()) * getHeight();

  Path target;
  target.addEllipse(x - 6.0f, y - 6.0f, 12.0f, 12.0f);
  shadow.drawForPath(g, target);

  g.setColour(Colour(0xff565656));
  g.fillPath(target);

  if (active_)
    g.setColour(Colour(0xff03a9f4));
  else
    g.setColour(Colour(0xff777777));
  g.strokePath(target, stroke);
  g.fillEllipse(x - 1.0f, y - 1.0f, 2.0f, 2.0f);

  if (mouse_down_) {
    g.setColour(Colour(0x11ffffff));
    g.fillEllipse(x - 20.0, y - 20.0, 40.0, 40.0);
  }
}
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)
{
    if (style == Slider::LinearVertical)
    {
        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));
        
        const float thumbWidth = jmin (slider.getWidth() - 2 * spaceBetweenThumbAndComponentBorder,
                                       maxThumbWidthVertical);
        const float thumbHeight = thumbWidth * heightToWidthRatioVertical;
        
        const float xCenter = x + width * 0.5f;
        // Originally it was yCenter = sliderPos. But that way the thumb (and especially the center line) did
        // not always look the same because of aliasing. With this additional rounding it is ensured that the
        // vertical position of the thumb "snaps" to the closest pixel and therefore looks always the same.
        const float yCenter = (int)(sliderPos) + 0.5f;
        const float xThumb = xCenter - 0.5f * thumbWidth;
        const float yThumb = yCenter - 0.5f * thumbHeight;
        
        // The shape of the thumb
        Path p;
        p.addRoundedRectangle(xThumb, yThumb, thumbWidth, thumbHeight, 5.0f);
        
        // Drop shadow
        const DropShadow ds (Colours::black, 4, Point<int> (0, 0));
        ds.drawForPath (g, p);
        
        // Outline
        const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f;
        g.setColour (Colours::black);
        //g.setColour (knobColour.darker());
        g.strokePath (p, PathStrokeType (outlineThickness));
        
        // Fill
        ColourGradient gradient (knobColour.darker(), xThumb, yThumb,
                                 knobColour.darker(), xThumb, yThumb + thumbHeight, false);
        gradient.addColour (0.5, knobColour.brighter());
        g.setGradientFill(gradient);
        g.fillPath (p);
//        g.setColour (knobColour);
//        g.fillPath (p);
        
        // Middle line
        g.setColour(Colours::black);
        g.drawLine(xThumb, yCenter, xThumb + thumbWidth, yCenter);
    }
    else
    {
        // Just call the base class for the demo
        LookAndFeel_V3::drawLinearSliderThumb (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider);
    }
}
Example #4
0
void SynthSlider::drawRotaryShadow(Graphics &g) {
  static const DropShadow shadow(Colour(0xbb000000), 3, Point<int>(0, 0));
  static const float shadow_angle = mopo::PI / 1.3f;

  g.saveState();
  g.setOrigin(getX(), getY());

  float full_radius = std::min(getWidth() / 2.0f, getHeight() / 2.0f);
  Path shadow_path;
  shadow_path.addCentredArc(full_radius, full_radius,
                            0.87f * full_radius, 0.85f * full_radius,
                            0, -shadow_angle, shadow_angle, true);
  shadow.drawForPath(g, shadow_path);
  g.restoreState();
}
Example #5
0
void FilterResponse::paint(Graphics& g) {
  static const PathStrokeType stroke(1.5f, PathStrokeType::beveled, PathStrokeType::rounded);
  static const DropShadow shadow(Colour(0xbb000000), 5, Point<int>(0, 0));

  g.drawImage(background_,
              0, 0, getWidth(), getHeight(),
              0, 0, background_.getWidth(), background_.getHeight());

  shadow.drawForPath(g, filter_response_path_);

  g.setColour(Colour(0xff565656));
  g.fillPath(filter_response_path_);

  g.setColour(Colour(0xff03a9f4));
  g.strokePath(filter_response_path_, stroke);
}
Example #6
0
    void drawRoundThumb (Graphics& g, const float x, const float y,
                         const float diameter, const Colour& colour, float outlineThickness)
    {
        const Rectangle<float> a (x, y, diameter, diameter);
        const float halfThickness = outlineThickness * 0.5f;

        Path p;
        p.addEllipse (x + halfThickness, y + halfThickness, diameter - outlineThickness, diameter - outlineThickness);

        const DropShadow ds (Colours::black, 1, Point<int> (0, 0));
        ds.drawForPath (g, p);

        g.setColour (colour);
        g.fillPath (p);

        g.setColour (colour.brighter());
        g.strokePath (p, PathStrokeType (outlineThickness));
    }
Example #7
0
void WaveViewer::paintBackground(Graphics& g) {
  static const DropShadow shadow(Colour(0xbb000000), 5, Point<int>(0, 0));

  g.fillAll(Colour(0xff424242));

  g.setColour(Colour(0xff4a4a4a));
  for (int x = 0; x < getWidth(); x += GRID_CELL_WIDTH)
    g.drawLine(x, 0, x, getHeight());
  for (int y = 0; y < getHeight(); y += GRID_CELL_WIDTH)
    g.drawLine(0, y, getWidth(), y);

  shadow.drawForPath(g, wave_path_);

  g.setColour(Colour(0xff565656));
  g.fillPath(wave_path_);
  g.setColour(Colour(0xff03a9f4));
  g.strokePath(wave_path_, PathStrokeType(1.5f, PathStrokeType::beveled, PathStrokeType::rounded));
}
void DefaultLookAndFeel::drawToggleButton(Graphics& g, ToggleButton& button,
                                          bool isMouseOverButton, bool isButtonDown) {
  static const DropShadow shadow(Colour(0x88000000), 1.0f, Point<int>(0, 0));
  static float stroke_percent = 0.1;
  static float padding = 3.0f;
  static float hover_padding = 1.0f;

  float full_radius = std::min(button.getWidth(), button.getHeight()) / 2.0;
  float stroke_width = 2.0f * full_radius * stroke_percent;
  PathStrokeType stroke_type(stroke_width, PathStrokeType::beveled, PathStrokeType::rounded);
  float outer_radius = full_radius - stroke_width - padding;
  Path outer;
  outer.addCentredArc(full_radius, full_radius, outer_radius, outer_radius,
                      mopo::PI, -POWER_ARC_ANGLE, POWER_ARC_ANGLE, true);

  Path shadow_path;
  stroke_type.createStrokedPath(shadow_path, outer);
  shadow.drawForPath(g, shadow_path);
  Rectangle<int> bar_shadow_rect(full_radius - 1.0f, padding, 2.0f, full_radius - padding);
  shadow.drawForRectangle(g, bar_shadow_rect);

  if (button.getToggleState())
    g.setColour(Colours::white);
  else
    g.setColour(Colours::grey);

  g.strokePath(outer, stroke_type);
  g.fillRoundedRectangle(full_radius - 1.0f, padding, 2.0f, full_radius - padding, 1.0f);

  if (isButtonDown) {
    g.setColour(Colour(0x11000000));
    g.fillEllipse(hover_padding, hover_padding,
                  button.getWidth() - 2 * hover_padding, button.getHeight() - 2 * hover_padding);
  }
  else if (isMouseOverButton) {
    g.setColour(Colour(0x11ffffff));
    g.fillEllipse(hover_padding, hover_padding,
                  button.getWidth() - 2 * hover_padding, button.getHeight() - 2 * hover_padding);  }
}