layout: Use background gradient when top bar is transparent

Make sure the legibility of top bar elements doesn't depend on the
wallpaper by adding a light gradient at the top when the top bar
is transparent, similar to what Android does.

https://bugzilla.gnome.org/show_bug.cgi?id=783913
This commit is contained in:
Alessandro Bono 2017-08-19 17:17:40 +02:00 committed by Florian Müllner
parent e45e8a2a14
commit d0d0350a8c
2 changed files with 38 additions and 6 deletions

View File

@ -729,7 +729,9 @@ StScrollBar {
/* TOP BAR */ /* TOP BAR */
#panel { #panel {
background-color: rgba(0, 0, 0, 0.35); background-gradient-start: rgba(0,0,0,0.3);
background-gradient-end: rgba(0,0,0,0);
background-gradient-direction: vertical;
/* transition from solid to transparent */ /* transition from solid to transparent */
transition-duration: 500ms; transition-duration: 500ms;
font-weight: bold; font-weight: bold;
@ -748,7 +750,7 @@ StScrollBar {
.panel-corner { .panel-corner {
-panel-corner-radius: $panel-corner-radius; -panel-corner-radius: $panel-corner-radius;
-panel-corner-background-color: rgba(0, 0, 0, 0.35); -panel-corner-background-color: rgba(0, 0, 0, 0);
-panel-corner-border-width: 2px; -panel-corner-border-width: 2px;
-panel-corner-border-color: transparent; -panel-corner-border-color: transparent;
@ -768,7 +770,7 @@ StScrollBar {
-minimum-hpadding: 6px; -minimum-hpadding: 6px;
font-weight: bold; font-weight: bold;
color: #eee; color: #eee;
text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.9); text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.8);
transition-duration: 100ms; transition-duration: 100ms;
.app-menu-icon { .app-menu-icon {
@ -781,17 +783,17 @@ StScrollBar {
.system-status-icon, .system-status-icon,
.app-menu-icon > StIcon, .app-menu-icon > StIcon,
.popup-menu-arrow { .popup-menu-arrow {
icon-shadow: 0px 1px 2px rgba(0, 0, 0, 0.9); icon-shadow: 0px 1px 2px rgba(0, 0, 0, 0.8);
} }
&:hover { &:hover {
color: lighten($fg_color, 10%); color: lighten($fg_color, 10%);
text-shadow: 0px 1px 6px rgba(0, 0, 0, 1); text-shadow: 0px 1px 3px rgba(0, 0, 0, 1);
.system-status-icon, .system-status-icon,
.app-menu-icon > StIcon, .app-menu-icon > StIcon,
.popup-menu-arrow { .popup-menu-arrow {
icon-shadow: 0px 1px 6px rgba(0, 0, 0, 1); icon-shadow: 0px 1px 3px rgba(0, 0, 0, 1);
} }
} }
@ -830,6 +832,9 @@ StScrollBar {
&.solid { &.solid {
background-color: black; background-color: black;
background-gradient-start: none;
background-gradient-end: none;
background-gradient-direction: none;
/* transition from transparent to solid */ /* transition from transparent to solid */
transition-duration: 300ms; transition-duration: 300ms;

View File

@ -21,6 +21,8 @@ const Tweener = imports.ui.tweener;
var STARTUP_ANIMATION_TIME = 0.5; var STARTUP_ANIMATION_TIME = 0.5;
var KEYBOARD_ANIMATION_TIME = 0.15; var KEYBOARD_ANIMATION_TIME = 0.15;
var BACKGROUND_FADE_ANIMATION_TIME = 1.0; var BACKGROUND_FADE_ANIMATION_TIME = 1.0;
var GRADIENT_FADE_IN_ANIMATION_TIME = 1.0;
var GRADIENT_FADE_OUT_ANIMATION_TIME = 0.3;
var HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels var HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels
var HOT_CORNER_PRESSURE_TIMEOUT = 1000; // ms var HOT_CORNER_PRESSURE_TIMEOUT = 1000; // ms
@ -301,8 +303,10 @@ var LayoutManager = new Lang.Class({
// This is called by Main after everything else is constructed // This is called by Main after everything else is constructed
init() { init() {
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this)); Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
Main.panel.connect('solid-style-changed', this._updatePrimaryBackground.bind(this));
this._loadBackground(); this._loadBackground();
this._updatePrimaryBackground();
}, },
showOverview() { showOverview() {
@ -324,6 +328,29 @@ var LayoutManager = new Lang.Class({
this._queueUpdateRegions(); this._queueUpdateRegions();
}, },
_updatePrimaryBackground() {
let metaBackgroundActor = this._bgManagers[this.primaryIndex].backgroundActor;
metaBackgroundActor.gradient = true;
metaBackgroundActor.gradient_height = 3 * Main.panel.actor.get_height();
if (Main.panel.solidStyle) {
Tweener.addTween(metaBackgroundActor,
{ gradient_max_darkness: 0,
time: GRADIENT_FADE_OUT_ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete: function() {
metaBackgroundActor.gradient = false;
}
});
} else {
Tweener.removeTweens(metaBackgroundActor);
Tweener.addTween(metaBackgroundActor,
{ gradient_max_darkness: 0.4,
time: GRADIENT_FADE_IN_ANIMATION_TIME,
transition: 'easeOutQuad'
});
}
},
_updateMonitors() { _updateMonitors() {
let display = global.display; let display = global.display;