Use BigBox rather than TidyGrid to organize the panel. #568712
svn path=/trunk/; revision=168
This commit is contained in:
parent
3a84625888
commit
a80c18bc4e
@ -4,7 +4,7 @@ const Clutter = imports.gi.Clutter;
|
|||||||
const Mainloop = imports.mainloop;
|
const Mainloop = imports.mainloop;
|
||||||
const Meta = imports.gi.Meta;
|
const Meta = imports.gi.Meta;
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const Tidy = imports.gi.Tidy;
|
const Big = imports.gi.Big;
|
||||||
|
|
||||||
const Button = imports.ui.button;
|
const Button = imports.ui.button;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
@ -13,6 +13,8 @@ const PANEL_HEIGHT = 32;
|
|||||||
const TRAY_HEIGHT = 24;
|
const TRAY_HEIGHT = 24;
|
||||||
const PANEL_BACKGROUND_COLOR = new Clutter.Color();
|
const PANEL_BACKGROUND_COLOR = new Clutter.Color();
|
||||||
PANEL_BACKGROUND_COLOR.from_pixel(0xeeddccff);
|
PANEL_BACKGROUND_COLOR.from_pixel(0xeeddccff);
|
||||||
|
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(0xccbbaaff);
|
||||||
|
|
||||||
@ -22,53 +24,44 @@ function Panel() {
|
|||||||
|
|
||||||
Panel.prototype = {
|
Panel.prototype = {
|
||||||
_init : function() {
|
_init : function() {
|
||||||
|
let me = this;
|
||||||
let global = Shell.Global.get();
|
let global = Shell.Global.get();
|
||||||
|
|
||||||
this._group = new Clutter.Group();
|
this._box = new Big.Box({ background_color: PANEL_BACKGROUND_COLOR,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
height: PANEL_HEIGHT + 1,
|
||||||
|
width: global.screen_width,
|
||||||
|
orientation: Big.BoxOrientation.HORIZONTAL,
|
||||||
|
spacing: 4,
|
||||||
|
border_bottom: 1,
|
||||||
|
border_color: PANEL_BORDER_COLOR });
|
||||||
|
|
||||||
let background = new Clutter.Rectangle({ color: PANEL_BACKGROUND_COLOR,
|
this.button = new Button.Button("Activities", PANEL_BACKGROUND_COLOR, PRESSED_BUTTON_BACKGROUND_COLOR, true, null, PANEL_HEIGHT);
|
||||||
reactive: true,
|
|
||||||
width: global.screen_width+2,
|
|
||||||
height: PANEL_HEIGHT+1,
|
|
||||||
border_width: 1});
|
|
||||||
background.set_position(-1, -1);
|
|
||||||
this._group.add_actor(background);
|
|
||||||
|
|
||||||
this.button = new Button.Button("Activities", PANEL_BACKGROUND_COLOR, PRESSED_BUTTON_BACKGROUND_COLOR, true, null, PANEL_HEIGHT-1);
|
this._box.append(this.button.button, Big.BoxPackFlags.NONE);
|
||||||
|
|
||||||
this._group.add_actor(this.button.button);
|
|
||||||
|
|
||||||
this._grid = new Tidy.Grid({ height: TRAY_HEIGHT,
|
|
||||||
valign: 0.5,
|
|
||||||
end_align: true,
|
|
||||||
column_gap: 2 })
|
|
||||||
this._group.add_actor(this._grid);
|
|
||||||
|
|
||||||
this._clock = new Clutter.Label({ font_name: "Sans Bold 16px",
|
this._clock = new Clutter.Label({ font_name: "Sans Bold 16px",
|
||||||
text: "" });
|
text: "" });
|
||||||
this._grid.add_actor(this._clock);
|
let pad = (PANEL_HEIGHT - this._clock.height) / 2;
|
||||||
|
let clockbox = new Big.Box({ padding_top: pad,
|
||||||
// Setting the anchor point at top right (north east) makes that portion of the
|
padding_bottom: pad,
|
||||||
// grid positioned at the position specified below.
|
padding_right: 4 });
|
||||||
this._grid.set_anchor_point_from_gravity(Clutter.Gravity.NORTH_EAST);
|
clockbox.append(this._clock, Big.BoxPackFlags.NONE);
|
||||||
this._grid.set_position(global.screen_width - 2, (PANEL_HEIGHT - TRAY_HEIGHT) / 2);
|
this._box.append(clockbox, Big.BoxPackFlags.END);
|
||||||
|
|
||||||
this._traymanager = new Shell.TrayManager({ bg_color: PANEL_BACKGROUND_COLOR });
|
this._traymanager = new Shell.TrayManager({ bg_color: PANEL_BACKGROUND_COLOR });
|
||||||
let me = this;
|
|
||||||
// the anchor point needs to be updated each time the height/width of the content might have changed, because
|
|
||||||
// it doesn't get updated on its own
|
|
||||||
this._traymanager.connect('tray-icon-added',
|
this._traymanager.connect('tray-icon-added',
|
||||||
function(o, icon) {
|
function(o, icon) {
|
||||||
me._grid.add_actor(icon);
|
let pad = (PANEL_HEIGHT - icon.height) / 2;
|
||||||
/* bump the clock back to the end */
|
icon._panel_box = new Big.Box({ padding_top: pad,
|
||||||
me._grid.remove_actor(me._clock);
|
padding_bottom: pad });
|
||||||
me._grid.add_actor(me._clock);
|
icon._panel_box.append(icon, Big.BoxPackFlags.NONE);
|
||||||
me._grid.move_anchor_point_from_gravity(Clutter.Gravity.NORTH_EAST);
|
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._grid.remove_actor(icon);
|
me._box.remove_actor(icon._panel_box);
|
||||||
me._grid.move_anchor_point_from_gravity(Clutter.Gravity.NORTH_EAST);
|
|
||||||
});
|
});
|
||||||
this._traymanager.manage_stage(global.stage);
|
this._traymanager.manage_stage(global.stage);
|
||||||
|
|
||||||
@ -92,7 +85,7 @@ Panel.prototype = {
|
|||||||
me._setStruts();
|
me._setStruts();
|
||||||
});
|
});
|
||||||
|
|
||||||
global.stage.add_actor(this._group);
|
global.stage.add_actor(this._box);
|
||||||
|
|
||||||
// Start the clock
|
// Start the clock
|
||||||
this._updateClock();
|
this._updateClock();
|
||||||
|
Loading…
Reference in New Issue
Block a user