| 69 | } |
| 70 | |
| 71 | juce::Rectangle<float> UIBase::fillRoundedInnerShadowRectangle(juce::Graphics& g, |
| 72 | juce::Rectangle<float> box_bounds, |
| 73 | float corner_size, |
| 74 | const FillRoundedShadowRectangleArgs& margs) const { |
| 75 | auto args = margs; |
| 76 | if (!args.change_main) |
| 77 | args.main_colour = getBackgroundColour(); |
| 78 | if (!args.change_dark) |
| 79 | args.dark_shadow_color = getDarkShadowColour(); |
| 80 | if (!args.change_bright) |
| 81 | args.bright_shadow_color = getBrightShadowColour(); |
| 82 | |
| 83 | juce::Path mask; |
| 84 | mask.addRoundedRectangle(box_bounds.getX(), box_bounds.getY(), |
| 85 | box_bounds.getWidth(), box_bounds.getHeight(), |
| 86 | corner_size, corner_size, |
| 87 | args.curve_top_left, args.curve_top_right, |
| 88 | args.curve_bottom_left, args.curve_bottom_right); |
| 89 | g.saveState(); |
| 90 | g.reduceClipRegion(mask); |
| 91 | if (args.draw_main) { |
| 92 | g.fillAll(args.main_colour); |
| 93 | } |
| 94 | auto offset = static_cast<int>(corner_size * args.blur_radius); |
| 95 | auto radius = juce::jmax(juce::roundToInt(corner_size * args.blur_radius * 1.5f), 1); |
| 96 | if (!args.flip) { |
| 97 | juce::DropShadow dark_shadow(args.dark_shadow_color.withMultipliedAlpha(0.75f), radius, |
| 98 | {-offset, -offset}); |
| 99 | dark_shadow.drawForPath(g, mask); |
| 100 | juce::DropShadow bright_shadow(args.bright_shadow_color, radius, |
| 101 | {offset, offset}); |
| 102 | bright_shadow.drawForPath(g, mask); |
| 103 | } else { |
| 104 | juce::DropShadow bright_shadow(args.dark_shadow_color, radius, |
| 105 | {offset, offset}); |
| 106 | bright_shadow.drawForPath(g, mask); |
| 107 | juce::DropShadow dark_shadow(args.bright_shadow_color.withMultipliedAlpha(0.75f), radius, |
| 108 | {-offset, -offset}); |
| 109 | dark_shadow.drawForPath(g, mask); |
| 110 | } |
| 111 | box_bounds = box_bounds.withSizeKeepingCentre( |
| 112 | box_bounds.getWidth() - 0.75f * static_cast<float>(radius), |
| 113 | box_bounds.getHeight() - 0.75f * static_cast<float>(radius)); |
| 114 | juce::Path path; |
| 115 | path.addRoundedRectangle(box_bounds.getX(), box_bounds.getY(), |
| 116 | box_bounds.getWidth(), box_bounds.getHeight(), |
| 117 | corner_size, corner_size, |
| 118 | args.curve_top_left, args.curve_top_right, |
| 119 | args.curve_bottom_left, args.curve_bottom_right); |
| 120 | |
| 121 | juce::DropShadow back_shadow(args.main_colour, radius, |
| 122 | {0, 0}); |
| 123 | back_shadow.drawForPath(g, path); |
| 124 | g.restoreState(); |
| 125 | return box_bounds; |
| 126 | } |
| 127 | |
| 128 | juce::Rectangle<float> UIBase::getShadowEllipseArea(juce::Rectangle<float> box_bounds, float corner_size, |