Skip to content

Commit

Permalink
appIndicators: Update progress bar colors to be more modern
Browse files Browse the repository at this point in the history
As commented in ubuntu/yaru#4016, the
progress bar, with its 3D gradient track, doesn't fit very well
in the current Gnome/Yaru theme.

This patch changes this, moving the track to a planar look, and
also allows to set the colors in the CSS.
  • Loading branch information
sergio-costas authored and 3v1n0 committed Mar 21, 2024
1 parent bc7af63 commit f509ece
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
4 changes: 4 additions & 0 deletions _stylesheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ $dock_style_modes: [null, shrink, extended, extended-shrink];

#dashtodockContainer.dashtodock .progress-bar {
/* Customization of the progress bar style, e.g.:
// base colors (the "background")
-progress-bar-base-background: rgba(0.25, 0.25, 0.25, 0,75);
-progress-bar-base-border: rgba(0.75, 0.75, 0.75, 0,25);
// progress bar colors
-progress-bar-background: rgba(0.8, 0.8, 0.8, 1);
-progress-bar-border: rgba(0.9, 0.9, 0.9, 1);
*/
Expand Down
29 changes: 14 additions & 15 deletions appIconIndicators.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,24 +859,26 @@ class UnityIndicator extends IndicatorBase {

cr.setLineWidth(lineWidth);

// Draw the outer stroke
let stroke = new Cairo.LinearGradient(0, y, 0, y + height);
let fill = null;
stroke.addColorStopRGBA(0.5, 0.5, 0.5, 0.5, 0.1);
stroke.addColorStopRGBA(0.9, 0.8, 0.8, 0.8, 0.4);
Utils.drawRoundedLine(cr, x + lineWidth / 2.0,
y + lineWidth / 2.0, width, height, true, true, stroke, fill);

// Draw the background
x += lineWidth;
y += lineWidth;
width -= 2.0 * lineWidth;
height -= 2.0 * lineWidth;

stroke = Cairo.SolidPattern.createRGBA(0.20, 0.20, 0.20, 0.9);
fill = new Cairo.LinearGradient(0, y, 0, y + height);
fill.addColorStopRGBA(0.4, 0.25, 0.25, 0.25, 1.0);
fill.addColorStopRGBA(0.9, 0.35, 0.35, 0.35, 1.0);
let hasColor, bg, bd, fg;
const node = this._progressOverlayArea.get_theme_node();

[hasColor, bg] = node.lookup_color('-progress-bar-base-background', false);
if (!hasColor)
bg = new Clutter.Color({red: 64, green: 64, blue: 64, alpha: 192});

[hasColor, fg] = node.lookup_color('-progress-bar-base-border', false);
if (!hasColor)
fg = new Clutter.Color({red: 192, green: 192, blue: 192, alpha: 64});

let fill = Cairo.SolidPattern.createRGBA(bg.red / 255, bg.green / 255, bg.blue / 255, bg.alpha / 255);
let stroke = Cairo.SolidPattern.createRGBA(
fg.red / 255, fg.green / 255, fg.blue / 255, fg.alpha / 255);
Utils.drawRoundedLine(cr, x + lineWidth / 2.0,
y + lineWidth / 2.0, width, height, true, true, stroke, fill);

Expand All @@ -888,9 +890,6 @@ class UnityIndicator extends IndicatorBase {

const finishedWidth = Math.ceil(this._progress * width);

let hasColor, bg, bd;
const node = this._progressOverlayArea.get_theme_node();

[hasColor, bg] = node.lookup_color('-progress-bar-background', false);
if (!hasColor)
bg = new Clutter.Color({red: 204, green: 204, blue: 204, alpha: 255});
Expand Down

0 comments on commit f509ece

Please sign in to comment.