WindowSwitcher: draw our own borders (#1918)

This commit is contained in:
Danielle Foré 2024-05-27 15:29:45 -07:00 committed by GitHub
parent 906b83abb5
commit bb8da6c79f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 50 additions and 20 deletions

View File

@ -18,17 +18,6 @@
* Authored by: Tom Beckmann
*/
.gala-notification {
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
background-color: rgb(2434, 2434, 2434);
border: 1px solid rgba(0, 0, 0, 0.3);
border-radius: 4px;
}
.gala-notification .title, .gala-notification .label {
color: #333;
}
.decoration {
border-radius: 4px 4px 0 0;
box-shadow:
@ -55,9 +44,8 @@
}
.window-switcher.decoration {
border-radius: 6px;
border-radius: 9px;
box-shadow:
0 0 0 1px alpha(#000, 0.2),
0 8px 10px 1px alpha(#000, 0.14),
0 3px 14px 2px alpha(#000, 0.12),
0 5px 5px -3px alpha(#000, 0.4);

View File

@ -13,6 +13,10 @@ namespace Gala.Drawing {
public class Color : GLib.Object {
public const Gdk.RGBA LIGHT_BACKGROUND = { (250f / 255f), (250f / 255f), (250f / 255f), 1};
public const Gdk.RGBA DARK_BACKGROUND = { (51 / 255f), (51 / 255f), (51 / 255f), 1};
public const Gdk.RGBA LIGHT_BORDER = { 0, 0, 0, 0.2};
public const Gdk.RGBA DARK_BORDER = { 0, 0, 0, 0.75};
public const Gdk.RGBA LIGHT_HIGHLIGHT = { 255, 255, 255, 1};
public const Gdk.RGBA DARK_HIGHLIGHT = { 255, 255, 255, 0.05};
public const Gdk.RGBA TOOLTIP_BACKGROUND = { 0, 0, 0, 1};
public const Gdk.RGBA TOOLTIP_TEXT_COLOR = { 1, 1, 1, 1};

View File

@ -142,12 +142,20 @@ public class Gala.WindowSwitcher : CanvasActor {
}
protected override void draw (Cairo.Context ctx, int width, int height) {
var background_color = Drawing.Color.LIGHT_BACKGROUND;
var border_color = Drawing.Color.LIGHT_BORDER;
var caption_color = "#2e2e31";
var highlight_color = Drawing.Color.LIGHT_HIGHLIGHT;
if (style_manager.prefers_color_scheme == Drawing.StyleManager.ColorScheme.DARK) {
background_color = Drawing.Color.DARK_BACKGROUND;
border_color = Drawing.Color.DARK_BORDER;
caption_color = "#fafafa";
highlight_color = Drawing.Color.DARK_HIGHLIGHT;
}
var stroke_width = scaling_factor;
caption.color = Clutter.Color.from_string (caption_color);
ctx.save ();
@ -156,20 +164,50 @@ public class Gala.WindowSwitcher : CanvasActor {
ctx.clip ();
ctx.reset_clip ();
var background_color = Drawing.Color.LIGHT_BACKGROUND;
if (style_manager.prefers_color_scheme == Drawing.StyleManager.ColorScheme.DARK) {
background_color = Drawing.Color.DARK_BACKGROUND;
}
ctx.set_operator (Cairo.Operator.SOURCE);
// Offset by 0.5 so cairo draws a stroke on real pixels
Drawing.Utilities.cairo_rounded_rectangle (
ctx, 0.5, 0.5,
width - stroke_width,
height - stroke_width,
InternalUtils.scale_to_int (9, scaling_factor)
);
ctx.set_source_rgba (
background_color.red,
background_color.green,
background_color.blue,
background_color.alpha
);
Drawing.Utilities.cairo_rounded_rectangle (ctx, 0, 0, width, height, InternalUtils.scale_to_int (6, scaling_factor));
ctx.fill ();
ctx.fill_preserve ();
ctx.set_line_width (stroke_width);
ctx.set_source_rgba (
border_color.red,
border_color.green,
border_color.blue,
border_color.alpha
);
ctx.stroke ();
ctx.restore ();
// Offset by 0.5 so cairo draws a stroke on real pixels
Drawing.Utilities.cairo_rounded_rectangle (
ctx, stroke_width + 0.5, stroke_width + 0.5,
width - stroke_width * 2 - 1,
height - stroke_width * 2 - 1,
InternalUtils.scale_to_int (8, scaling_factor)
);
ctx.set_line_width (stroke_width);
ctx.set_source_rgba (
highlight_color.red,
highlight_color.green,
highlight_color.blue,
highlight_color.alpha
);
ctx.stroke ();
ctx.restore ();
}