MCPcopy Create free account
hub / github.com/ZL-Audio/ZLEqualizer / fillRoundedShadowRectangle

Method fillRoundedShadowRectangle

source/gui/interface_definitons.cpp:22–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20 }
21
22 juce::Rectangle<float> UIBase::fillRoundedShadowRectangle(juce::Graphics& g,
23 juce::Rectangle<float> box_bounds,
24 float corner_size,
25 const FillRoundedShadowRectangleArgs& margs) const {
26 auto args = margs;
27 if (!args.change_main)
28 args.main_colour = getBackgroundColour().withAlpha(args.main_colour.getAlpha());
29 if (!args.change_dark)
30 args.dark_shadow_color = getDarkShadowColour();
31 if (!args.change_bright)
32 args.bright_shadow_color = getBrightShadowColour();
33
34 juce::Path path;
35 const auto radius = juce::jmax(juce::roundToInt(corner_size * args.blur_radius * 1.5f), 1);
36 if (args.fit) {
37 box_bounds = box_bounds.withSizeKeepingCentre(
38 box_bounds.getWidth() - static_cast<float>(radius) - 1.42f * corner_size,
39 box_bounds.getHeight() - static_cast<float>(radius) - 1.42f * corner_size);
40 }
41 path.addRoundedRectangle(box_bounds.getX(), box_bounds.getY(),
42 box_bounds.getWidth(), box_bounds.getHeight(),
43 corner_size, corner_size,
44 args.curve_top_left, args.curve_top_right,
45 args.curve_bottom_left, args.curve_bottom_right);
46 auto offset = static_cast<int>(corner_size * args.blur_radius);
47 juce::Path mask(path);
48 mask.setUsingNonZeroWinding(false);
49 mask.addRectangle(box_bounds.withSizeKeepingCentre(box_bounds.getWidth() + corner_size * 3,
50 box_bounds.getHeight() + corner_size * 3));
51 g.saveState();
52 g.reduceClipRegion(mask);
53 if (args.draw_bright) {
54 juce::DropShadow bright_shadow(args.bright_shadow_color, radius,
55 {-offset, -offset});
56 bright_shadow.drawForPath(g, path);
57 }
58 if (args.draw_dark) {
59 juce::DropShadow dark_shadow(args.dark_shadow_color, radius,
60 {offset, offset});
61 dark_shadow.drawForPath(g, path);
62 }
63 g.restoreState();
64 if (args.draw_main) {
65 g.setColour(args.main_colour);
66 g.fillPath(path);
67 }
68 return box_bounds;
69 }
70
71 juce::Rectangle<float> UIBase::fillRoundedInnerShadowRectangle(juce::Graphics& g,
72 juce::Rectangle<float> box_bounds,

Callers 1

paintMethod · 0.80

Calls 5

getWidthMethod · 0.80
getHeightMethod · 0.80
getXMethod · 0.45
getYMethod · 0.45
setColourMethod · 0.45

Tested by

no test coverage detected