panelMenu: add a gap between the panel and its menus

The specs call for a 2 pixel gap between the panel and its menus,
though we need to specify this as 4 pixels, since it's relative to the
bottom of the icon/title, not the bottom of the panel (up until now,
the point of the menu arrow was actually overlapping the menu's
highlight underline).

Also, move the gap specification into the CSS, since it makes more
sense there.

https://bugzilla.gnome.org/show_bug.cgi?id=655627
This commit is contained in:
Dan Winship 2011-07-30 13:24:24 -04:00
parent e01baf2a25
commit 2403fd0680
5 changed files with 16 additions and 10 deletions

View File

@ -321,6 +321,10 @@ StTooltip StLabel {
icon-shadow: black 0px 2px 2px; icon-shadow: black 0px 2px 2px;
} }
.panel-menu {
-boxpointer-gap: 4px
}
/* The rounded panel corners we draw don't /* The rounded panel corners we draw don't
* support transitions, so disable transitions * support transitions, so disable transitions
* for the buttons at the left/right edges * for the buttons at the left/right edges

View File

@ -609,7 +609,7 @@ AppIconMenu.prototype = {
if (St.Widget.get_default_direction() == St.TextDirection.RTL) if (St.Widget.get_default_direction() == St.TextDirection.RTL)
side = St.Side.RIGHT; side = St.Side.RIGHT;
PopupMenu.PopupMenu.prototype._init.call(this, source.actor, 0.5, side, 0); PopupMenu.PopupMenu.prototype._init.call(this, source.actor, 0.5, side);
// We want to keep the item hovered while the menu is up // We want to keep the item hovered while the menu is up
this.blockSourceEvents = true; this.blockSourceEvents = true;

View File

@ -180,7 +180,7 @@ BoxPointer.prototype = {
this.bin.allocate(childBox, flags); this.bin.allocate(childBox, flags);
if (this._sourceActor && this._sourceActor.mapped) if (this._sourceActor && this._sourceActor.mapped)
this._reposition(this._sourceActor, this._gap, this._alignment); this._reposition(this._sourceActor, this._alignment);
}, },
_drawBorder: function(area) { _drawBorder: function(area) {
@ -306,19 +306,18 @@ BoxPointer.prototype = {
cr.stroke(); cr.stroke();
}, },
setPosition: function(sourceActor, gap, alignment) { setPosition: function(sourceActor, alignment) {
// We need to show it now to force an allocation, // We need to show it now to force an allocation,
// so that we can query the correct size. // so that we can query the correct size.
this.actor.show(); this.actor.show();
this._sourceActor = sourceActor; this._sourceActor = sourceActor;
this._gap = gap;
this._alignment = alignment; this._alignment = alignment;
this._reposition(sourceActor, gap, alignment); this._reposition(sourceActor, alignment);
}, },
_reposition: function(sourceActor, gap, alignment) { _reposition: function(sourceActor, alignment) {
// Position correctly relative to the sourceActor // Position correctly relative to the sourceActor
let sourceNode = sourceActor.get_theme_node(); let sourceNode = sourceActor.get_theme_node();
let sourceContentBox = sourceNode.get_content_box(sourceActor.get_allocation_box()); let sourceContentBox = sourceNode.get_content_box(sourceActor.get_allocation_box());
@ -338,6 +337,9 @@ BoxPointer.prototype = {
let margin = (4 * borderRadius + borderWidth + arrowBase); let margin = (4 * borderRadius + borderWidth + arrowBase);
let halfMargin = margin / 2; let halfMargin = margin / 2;
let themeNode = this.actor.get_theme_node();
let gap = themeNode.get_length('-boxpointer-gap');
let resX, resY; let resX, resY;
switch (this._arrowSide) { switch (this._arrowSide) {

View File

@ -23,7 +23,8 @@ Button.prototype = {
this.actor._delegate = this; this.actor._delegate = this;
this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress)); this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress)); this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress));
this.menu = new PopupMenu.PopupMenu(this.actor, menuAlignment, St.Side.TOP, 0); this.menu = new PopupMenu.PopupMenu(this.actor, menuAlignment, St.Side.TOP);
this.menu.actor.add_style_class_name('panel-menu');
this.menu.connect('open-state-changed', Lang.bind(this, this._onOpenStateChanged)); this.menu.connect('open-state-changed', Lang.bind(this, this._onOpenStateChanged));
this.menu.actor.connect('key-press-event', Lang.bind(this, this._onMenuKeyPress)); this.menu.actor.connect('key-press-event', Lang.bind(this, this._onMenuKeyPress));
Main.chrome.addActor(this.menu.actor, { affectsStruts: false }); Main.chrome.addActor(this.menu.actor, { affectsStruts: false });

View File

@ -985,12 +985,11 @@ function PopupMenu() {
PopupMenu.prototype = { PopupMenu.prototype = {
__proto__: PopupMenuBase.prototype, __proto__: PopupMenuBase.prototype,
_init: function(sourceActor, alignment, arrowSide, gap) { _init: function(sourceActor, alignment, arrowSide) {
PopupMenuBase.prototype._init.call (this, sourceActor, 'popup-menu-content'); PopupMenuBase.prototype._init.call (this, sourceActor, 'popup-menu-content');
this._alignment = alignment; this._alignment = alignment;
this._arrowSide = arrowSide; this._arrowSide = arrowSide;
this._gap = gap;
this._boxPointer = new BoxPointer.BoxPointer(arrowSide, this._boxPointer = new BoxPointer.BoxPointer(arrowSide,
{ x_fill: true, { x_fill: true,
@ -1048,7 +1047,7 @@ PopupMenu.prototype = {
this.isOpen = true; this.isOpen = true;
this._boxPointer.setPosition(this.sourceActor, this._gap, this._alignment); this._boxPointer.setPosition(this.sourceActor, this._alignment);
this._boxPointer.show(animate); this._boxPointer.show(animate);
this.emit('open-state-changed', true); this.emit('open-state-changed', true);