1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:57:44 +00:00

WindowServer: Implement simple window shadows

This implements simple window shadows around most windows, including
tooltips. Because this method uses a bitmap for the shadow bits,
it is limited to rectangular window frames. For non-rectangular
window frames we'll need to implement a more sophisticated algorithm.
This commit is contained in:
Tom 2021-02-08 17:27:51 -07:00 committed by Andreas Kling
parent 72fdab7bfb
commit 0ce4b9d7db
14 changed files with 234 additions and 70 deletions

View file

@ -47,6 +47,7 @@ public:
virtual IntRect frame_rect_for_window(WindowType, const IntRect& window_rect, const Palette&) const override;
virtual Vector<IntRect> layout_buttons(WindowType, const IntRect& window_rect, const Palette&, size_t buttons) const override;
virtual bool is_simple_rect_frame() const override { return true; }
private:
struct FrameColors {

View file

@ -735,13 +735,13 @@ void Painter::blit_with_alpha(const IntPoint& position, const Gfx::Bitmap& sourc
}
}
void Painter::blit(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& a_src_rect, float opacity)
void Painter::blit(const IntPoint& position, const Gfx::Bitmap& source, const IntRect& a_src_rect, float opacity, bool apply_alpha)
{
ASSERT(scale() >= source.scale() && "painter doesn't support downsampling scale factors");
if (opacity < 1.0f)
return blit_with_opacity(position, source, a_src_rect, opacity);
if (source.has_alpha_channel())
if (source.has_alpha_channel() && apply_alpha)
return blit_with_alpha(position, source, a_src_rect);
auto safe_src_rect = a_src_rect.intersected(source.rect());

View file

@ -70,7 +70,7 @@ public:
void draw_line(const IntPoint&, const IntPoint&, Color, int thickness = 1, LineStyle style = LineStyle::Solid);
void draw_quadratic_bezier_curve(const IntPoint& control_point, const IntPoint&, const IntPoint&, Color, int thickness = 1, LineStyle style = LineStyle::Solid);
void draw_elliptical_arc(const IntPoint& p1, const IntPoint& p2, const IntPoint& center, const FloatPoint& radii, float x_axis_rotation, float theta_1, float theta_delta, Color, int thickness = 1, LineStyle style = LineStyle::Solid);
void blit(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect, float opacity = 1.0f);
void blit(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect, float opacity = 1.0f, bool apply_alpha = true);
void blit_dimmed(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect);
void blit_brightened(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect);
void blit_filtered(const IntPoint&, const Gfx::Bitmap&, const IntRect& src_rect, Function<Color(Color)>);

View file

@ -140,6 +140,7 @@ public:
int window_title_button_height() const { return metric(MetricRole::TitleButtonHeight); }
String title_button_icons_path() const { return path(PathRole::TitleButtonIcons); }
String window_shadow_path() const { return path(PathRole::WindowShadow); }
Color color(ColorRole role) const { return m_impl->color(role); }
int metric(MetricRole role) const { return m_impl->metric(role); }

View file

@ -119,6 +119,7 @@ Core::AnonymousBuffer load_system_theme(const String& path)
} while (0)
DO_PATH(TitleButtonIcons);
DO_PATH(WindowShadow);
return buffer;
}

View file

@ -144,6 +144,7 @@ enum class MetricRole {
enum class PathRole {
NoRole,
TitleButtonIcons,
WindowShadow,
__Count,
};

View file

@ -61,6 +61,7 @@ public:
virtual IntRect frame_rect_for_window(WindowType, const IntRect& window_rect, const Palette&) const = 0;
virtual Vector<IntRect> layout_buttons(WindowType, const IntRect& window_rect, const Palette&, size_t buttons) const = 0;
virtual bool is_simple_rect_frame() const = 0;
protected:
WindowTheme() { }