Bug 574702 - Give the panel a gradient background and shadow
The panel looks nicer when it is drawn as a semi-transparent gradient above the background color. shell-global.[ch]: Add a function that creates vertical gradient actors. panel.js: Change the look of the panel and put the tray in a framed box. overlay.js: Extend the overlay background to behind the panel.
This commit is contained in:
parent
1fcaafdb58
commit
2b9b600710
@ -585,9 +585,9 @@ Overlay.prototype = {
|
|||||||
let background = new Clutter.Rectangle({ color: OVERLAY_BACKGROUND_COLOR,
|
let background = new Clutter.Rectangle({ color: OVERLAY_BACKGROUND_COLOR,
|
||||||
reactive: true,
|
reactive: true,
|
||||||
x: 0,
|
x: 0,
|
||||||
y: Panel.PANEL_HEIGHT,
|
y: 0,
|
||||||
width: global.screen_width,
|
width: global.screen_width,
|
||||||
height: global.screen_width - Panel.PANEL_HEIGHT });
|
height: global.screen_width });
|
||||||
this._group.add_actor(background);
|
this._group.add_actor(background);
|
||||||
|
|
||||||
this._group.hide();
|
this._group.hide();
|
||||||
|
132
js/ui/panel.js
132
js/ui/panel.js
@ -10,15 +10,36 @@ const Button = imports.ui.button;
|
|||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
|
|
||||||
const PANEL_HEIGHT = 32;
|
const PANEL_HEIGHT = 32;
|
||||||
const TRAY_HEIGHT = 24;
|
const TRAY_HEIGHT = 28;
|
||||||
const PANEL_BACKGROUND_COLOR = new Clutter.Color();
|
const SHADOW_HEIGHT = 6;
|
||||||
PANEL_BACKGROUND_COLOR.from_pixel(0xeeddccff);
|
|
||||||
|
// The panel has a transparent white background with a gradient.
|
||||||
|
const PANEL_TOP_COLOR = new Clutter.Color();
|
||||||
|
PANEL_TOP_COLOR.from_pixel(0xffffff99);
|
||||||
|
const PANEL_MIDDLE_COLOR = new Clutter.Color();
|
||||||
|
PANEL_MIDDLE_COLOR.from_pixel(0xffffff88);
|
||||||
|
const PANEL_BOTTOM_COLOR = new Clutter.Color();
|
||||||
|
PANEL_BOTTOM_COLOR.from_pixel(0xffffffaa);
|
||||||
|
|
||||||
|
const SHADOW_COLOR = new Clutter.Color();
|
||||||
|
SHADOW_COLOR.from_pixel(0x00000033);
|
||||||
|
const TRANSPARENT_COLOR = new Clutter.Color();
|
||||||
|
TRANSPARENT_COLOR.from_pixel(0x00000000);
|
||||||
|
|
||||||
|
// Darken (pressed) buttons; lightening has no effect on white backgrounds.
|
||||||
const PANEL_BUTTON_COLOR = new Clutter.Color();
|
const PANEL_BUTTON_COLOR = new Clutter.Color();
|
||||||
PANEL_BUTTON_COLOR.from_pixel(0xccbbaa66);
|
PANEL_BUTTON_COLOR.from_pixel(0x00000015);
|
||||||
const PANEL_BORDER_COLOR = new Clutter.Color();
|
|
||||||
PANEL_BORDER_COLOR.from_pixel(0x000000ff);
|
|
||||||
const PRESSED_BUTTON_BACKGROUND_COLOR = new Clutter.Color();
|
const PRESSED_BUTTON_BACKGROUND_COLOR = new Clutter.Color();
|
||||||
PRESSED_BUTTON_BACKGROUND_COLOR.from_pixel(0xccbbaaff);
|
PRESSED_BUTTON_BACKGROUND_COLOR.from_pixel(0x00000030);
|
||||||
|
|
||||||
|
const TRAY_BACKGROUND_COLOR = new Clutter.Color();
|
||||||
|
TRAY_BACKGROUND_COLOR.from_pixel(0xefefefff);
|
||||||
|
const TRAY_BORDER_COLOR = new Clutter.Color();
|
||||||
|
TRAY_BORDER_COLOR.from_pixel(0x00000033);
|
||||||
|
const TRAY_CORNER_RADIUS = 5;
|
||||||
|
const TRAY_BORDER_WIDTH = 1;
|
||||||
|
const TRAY_PADDING = 2;
|
||||||
|
const TRAY_SPACING = 2;
|
||||||
|
|
||||||
function Panel() {
|
function Panel() {
|
||||||
this._init();
|
this._init();
|
||||||
@ -29,19 +50,41 @@ Panel.prototype = {
|
|||||||
let me = this;
|
let me = this;
|
||||||
let global = Shell.Global.get();
|
let global = Shell.Global.get();
|
||||||
|
|
||||||
this._box = new Big.Box({ background_color: PANEL_BACKGROUND_COLOR,
|
// Put the background under the panel within a group.
|
||||||
|
this._group = new Clutter.Group();
|
||||||
|
|
||||||
|
// Create backBox, which contains two boxes, backUpper and backLower,
|
||||||
|
// for the background gradients and one for the shadow. The shadow at
|
||||||
|
// the bottom has a fixed height (packing flag NONE), and the rest of
|
||||||
|
// the height above is divided evenly between backUpper and backLower
|
||||||
|
// (with packing flag EXPAND).
|
||||||
|
let backBox = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
height: PANEL_HEIGHT + 1,
|
width: global.screen_width,
|
||||||
|
height: PANEL_HEIGHT + SHADOW_HEIGHT });
|
||||||
|
let backUpper = global.create_vertical_gradient(PANEL_TOP_COLOR,
|
||||||
|
PANEL_MIDDLE_COLOR);
|
||||||
|
let backLower = global.create_vertical_gradient(PANEL_MIDDLE_COLOR,
|
||||||
|
PANEL_BOTTOM_COLOR);
|
||||||
|
let shadow = global.create_vertical_gradient(SHADOW_COLOR,
|
||||||
|
TRANSPARENT_COLOR);
|
||||||
|
shadow.set_height(SHADOW_HEIGHT);
|
||||||
|
backBox.append(backUpper, Big.BoxPackFlags.EXPAND);
|
||||||
|
backBox.append(backLower, Big.BoxPackFlags.EXPAND);
|
||||||
|
backBox.append(shadow, Big.BoxPackFlags.NONE);
|
||||||
|
this._group.add_actor(backBox);
|
||||||
|
|
||||||
|
let box = new Big.Box({ x: 0,
|
||||||
|
y: 0,
|
||||||
|
height: PANEL_HEIGHT,
|
||||||
width: global.screen_width,
|
width: global.screen_width,
|
||||||
orientation: Big.BoxOrientation.HORIZONTAL,
|
orientation: Big.BoxOrientation.HORIZONTAL,
|
||||||
spacing: 4,
|
spacing: 4 });
|
||||||
border_bottom: 1,
|
|
||||||
border_color: PANEL_BORDER_COLOR });
|
|
||||||
|
|
||||||
this.button = new Button.Button("Activities", PANEL_BUTTON_COLOR, PRESSED_BUTTON_BACKGROUND_COLOR, true, null, PANEL_HEIGHT);
|
this.button = new Button.Button("Activities", PANEL_BUTTON_COLOR, PRESSED_BUTTON_BACKGROUND_COLOR, true, null, PANEL_HEIGHT);
|
||||||
|
|
||||||
this._box.append(this.button.button, Big.BoxPackFlags.NONE);
|
box.append(this.button.button, Big.BoxPackFlags.NONE);
|
||||||
|
|
||||||
let statusbox = new Big.Box();
|
let statusbox = new Big.Box();
|
||||||
this._statusmenu = new Shell.StatusMenu();
|
this._statusmenu = new Shell.StatusMenu();
|
||||||
@ -52,7 +95,7 @@ Panel.prototype = {
|
|||||||
me._statusmenu.toggle(e);
|
me._statusmenu.toggle(e);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
this._box.append(statusbutton.button, Big.BoxPackFlags.END);
|
box.append(statusbutton.button, Big.BoxPackFlags.END);
|
||||||
// We get a deactivated event when the popup disappears
|
// We get a deactivated event when the popup disappears
|
||||||
this._statusmenu.connect('deactivated', function (sm) {
|
this._statusmenu.connect('deactivated', function (sm) {
|
||||||
statusbutton.release();
|
statusbutton.release();
|
||||||
@ -63,22 +106,42 @@ Panel.prototype = {
|
|||||||
let pad = (PANEL_HEIGHT - this._clock.height) / 2;
|
let pad = (PANEL_HEIGHT - this._clock.height) / 2;
|
||||||
let clockbox = new Big.Box({ padding_top: pad,
|
let clockbox = new Big.Box({ padding_top: pad,
|
||||||
padding_bottom: pad,
|
padding_bottom: pad,
|
||||||
|
padding_left: 4,
|
||||||
padding_right: 4 });
|
padding_right: 4 });
|
||||||
clockbox.append(this._clock, Big.BoxPackFlags.NONE);
|
clockbox.append(this._clock, Big.BoxPackFlags.NONE);
|
||||||
this._box.append(clockbox, Big.BoxPackFlags.END);
|
box.append(clockbox, Big.BoxPackFlags.END);
|
||||||
|
|
||||||
this._traymanager = new Shell.TrayManager({ bg_color: PANEL_BACKGROUND_COLOR });
|
// The tray icons live in trayBox within trayContainer.
|
||||||
|
// With Gtk 2.16, we can also use a transparent background for this.
|
||||||
|
// The trayBox is hidden when there are no tray icons.
|
||||||
|
let trayContainer = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
|
||||||
|
y_align: Big.BoxAlignment.CENTER });
|
||||||
|
box.append(trayContainer, Big.BoxPackFlags.END);
|
||||||
|
let trayBox = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
|
||||||
|
height: TRAY_HEIGHT,
|
||||||
|
background_color: TRAY_BACKGROUND_COLOR,
|
||||||
|
corner_radius: TRAY_CORNER_RADIUS,
|
||||||
|
border: TRAY_BORDER_WIDTH,
|
||||||
|
border_color: TRAY_BORDER_COLOR,
|
||||||
|
padding: TRAY_PADDING,
|
||||||
|
spacing: TRAY_SPACING });
|
||||||
|
trayBox.hide();
|
||||||
|
trayContainer.append(trayBox, Big.BoxPackFlags.NONE);
|
||||||
|
|
||||||
|
this._traymanager = new Shell.TrayManager({ bg_color: TRAY_BACKGROUND_COLOR });
|
||||||
this._traymanager.connect('tray-icon-added',
|
this._traymanager.connect('tray-icon-added',
|
||||||
function(o, icon) {
|
function(o, icon) {
|
||||||
let pad = (PANEL_HEIGHT - icon.height) / 2;
|
trayBox.append(icon, Big.BoxPackFlags.NONE);
|
||||||
icon._panel_box = new Big.Box({ padding_top: pad,
|
|
||||||
padding_bottom: pad });
|
// Make sure the trayBox is shown.
|
||||||
icon._panel_box.append(icon, Big.BoxPackFlags.NONE);
|
trayBox.show();
|
||||||
me._box.append(icon._panel_box, Big.BoxPackFlags.END);
|
|
||||||
});
|
});
|
||||||
this._traymanager.connect('tray-icon-removed',
|
this._traymanager.connect('tray-icon-removed',
|
||||||
function(o, icon) {
|
function(o, icon) {
|
||||||
me._box.remove_actor(icon._panel_box);
|
trayBox.remove_actor(icon);
|
||||||
|
|
||||||
|
if (trayBox.get_children().length == 0)
|
||||||
|
trayBox.hide();
|
||||||
});
|
});
|
||||||
this._traymanager.manage_stage(global.stage);
|
this._traymanager.manage_stage(global.stage);
|
||||||
|
|
||||||
@ -102,7 +165,10 @@ Panel.prototype = {
|
|||||||
me._setStruts();
|
me._setStruts();
|
||||||
});
|
});
|
||||||
|
|
||||||
global.stage.add_actor(this._box);
|
this._group.add_actor(box);
|
||||||
|
|
||||||
|
global.stage.add_actor(this._group);
|
||||||
|
|
||||||
global.screen.connect('restacked',
|
global.screen.connect('restacked',
|
||||||
function() {
|
function() {
|
||||||
me._restacked();
|
me._restacked();
|
||||||
@ -116,9 +182,9 @@ Panel.prototype = {
|
|||||||
set_stage_input_area: function() {
|
set_stage_input_area: function() {
|
||||||
let global = Shell.Global.get();
|
let global = Shell.Global.get();
|
||||||
|
|
||||||
if (this._box.visible) {
|
if (this._group.visible) {
|
||||||
global.set_stage_input_area(this._box.x, this._box.y,
|
global.set_stage_input_area(this._group.x, this._group.y,
|
||||||
this._box.width, this._box.height);
|
this._group.width, PANEL_HEIGHT);
|
||||||
} else
|
} else
|
||||||
global.set_stage_input_area(0, 0, 0, 0);
|
global.set_stage_input_area(0, 0, 0, 0);
|
||||||
},
|
},
|
||||||
@ -161,20 +227,20 @@ Panel.prototype = {
|
|||||||
// treats it currently...
|
// treats it currently...
|
||||||
//
|
//
|
||||||
// @windows is sorted bottom to top.
|
// @windows is sorted bottom to top.
|
||||||
this._box.show();
|
this._group.show();
|
||||||
for (i = windows.length - 1; i > -1; i--) {
|
for (i = windows.length - 1; i > -1; i--) {
|
||||||
let layer = windows[i].get_meta_window().get_layer();
|
let layer = windows[i].get_meta_window().get_layer();
|
||||||
|
|
||||||
if (layer == Meta.StackLayer.OVERRIDE_REDIRECT) {
|
if (layer == Meta.StackLayer.OVERRIDE_REDIRECT) {
|
||||||
if (windows[i].x <= this._box.x &&
|
if (windows[i].x <= this._group.x &&
|
||||||
windows[i].x + windows[i].width >= this._box.x + this._box.width &&
|
windows[i].x + windows[i].width >= this._group.x + this._group.width &&
|
||||||
windows[i].y <= this._box.y &&
|
windows[i].y <= this._group.y &&
|
||||||
windows[i].y + windows[i].height >= this._box.y + this._box.height) {
|
windows[i].y + windows[i].height >= this._group.y + PANEL_HEIGHT) {
|
||||||
this._box.hide();
|
this._group.hide();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (layer == Meta.StackLayer.FULLSCREEN) {
|
} else if (layer == Meta.StackLayer.FULLSCREEN) {
|
||||||
this._box.hide();
|
this._group.hide();
|
||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
@ -662,3 +662,50 @@ grab_notify (GtkWidget *widget, gboolean was_grabbed, gpointer user_data)
|
|||||||
global->input_width, global->input_height);
|
global->input_width, global->input_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* shell_global_create_vertical_gradient:
|
||||||
|
* @top: the color at the top
|
||||||
|
* @bottom: the color at the bottom
|
||||||
|
*
|
||||||
|
* Creates a vertical gradient actor.
|
||||||
|
*
|
||||||
|
* Return value: (transfer none): a #ClutterCairoTexture actor with the
|
||||||
|
* gradient. The texture actor is floating, hence (transfer none).
|
||||||
|
*/
|
||||||
|
ClutterCairoTexture *
|
||||||
|
shell_global_create_vertical_gradient (ClutterColor *top,
|
||||||
|
ClutterColor *bottom)
|
||||||
|
{
|
||||||
|
ClutterCairoTexture *texture;
|
||||||
|
cairo_t *cr;
|
||||||
|
cairo_pattern_t *pattern;
|
||||||
|
|
||||||
|
/* Draw the gradient on an 8x8 pixel texture. Because the gradient is drawn
|
||||||
|
* from the uppermost to the lowermost row, after stretching 1/16 of the
|
||||||
|
* texture height has the top color and 1/16 has the bottom color. The 8
|
||||||
|
* pixel width is chosen for reasons related to graphics hardware internals.
|
||||||
|
*/
|
||||||
|
texture = CLUTTER_CAIRO_TEXTURE (clutter_cairo_texture_new (8, 8));
|
||||||
|
cr = clutter_cairo_texture_create (texture);
|
||||||
|
|
||||||
|
pattern = cairo_pattern_create_linear (0, 0, 0, 8);
|
||||||
|
cairo_pattern_add_color_stop_rgba (pattern, 0,
|
||||||
|
top->red / 255.,
|
||||||
|
top->green / 255.,
|
||||||
|
top->blue / 255.,
|
||||||
|
top->alpha / 255.);
|
||||||
|
cairo_pattern_add_color_stop_rgba (pattern, 1,
|
||||||
|
bottom->red / 255.,
|
||||||
|
bottom->green / 255.,
|
||||||
|
bottom->blue / 255.,
|
||||||
|
bottom->alpha / 255.);
|
||||||
|
|
||||||
|
cairo_set_source (cr, pattern);
|
||||||
|
cairo_paint (cr);
|
||||||
|
|
||||||
|
cairo_pattern_destroy (pattern);
|
||||||
|
cairo_destroy (cr);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
@ -64,6 +64,9 @@ void shell_global_ungrab_keyboard (ShellGlobal *global);
|
|||||||
|
|
||||||
void shell_global_reexec_self (ShellGlobal *global);
|
void shell_global_reexec_self (ShellGlobal *global);
|
||||||
|
|
||||||
|
ClutterCairoTexture *shell_global_create_vertical_gradient (ClutterColor *top,
|
||||||
|
ClutterColor *bottom);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __SHELL_GLOBAL_H__ */
|
#endif /* __SHELL_GLOBAL_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user