panelMenu: Don't fade appMenuButton icon and put it on the side
Design request, don't fade the icon of the appMenuButton and put it on the side instead of overlaping with the text.
This commit is contained in:
@ -189,11 +189,8 @@ const AppMenuButton = new Lang.Class({
|
|||||||
this.actor.bind_property("reactive", this.actor, "can-focus", 0);
|
this.actor.bind_property("reactive", this.actor, "can-focus", 0);
|
||||||
this.actor.reactive = false;
|
this.actor.reactive = false;
|
||||||
|
|
||||||
this._container = new Shell.GenericContainer();
|
this._container = St.BoxLayout({ style_class: 'panel-status-menu-box' });
|
||||||
bin.set_child(this._container);
|
bin.set_child(this._container);
|
||||||
this._container.connect('get-preferred-width', Lang.bind(this, this._getContentPreferredWidth));
|
|
||||||
this._container.connect('get-preferred-height', Lang.bind(this, this._getContentPreferredHeight));
|
|
||||||
this._container.connect('allocate', Lang.bind(this, this._contentAllocate));
|
|
||||||
|
|
||||||
let textureCache = St.TextureCache.get_default();
|
let textureCache = St.TextureCache.get_default();
|
||||||
textureCache.connect('icon-theme-changed',
|
textureCache.connect('icon-theme-changed',
|
||||||
@ -206,14 +203,11 @@ const AppMenuButton = new Lang.Class({
|
|||||||
Lang.bind(this, this._updateIconBoxClip));
|
Lang.bind(this, this._updateIconBoxClip));
|
||||||
this._container.add_actor(this._iconBox);
|
this._container.add_actor(this._iconBox);
|
||||||
|
|
||||||
this._hbox = new St.BoxLayout({ style_class: 'panel-status-menu-box' });
|
|
||||||
this._container.add_actor(this._hbox);
|
|
||||||
|
|
||||||
this._label = new TextShadower();
|
this._label = new TextShadower();
|
||||||
this._label.actor.y_align = Clutter.ActorAlign.CENTER;
|
this._label.actor.y_align = Clutter.ActorAlign.CENTER;
|
||||||
this._hbox.add_actor(this._label.actor);
|
this._container.add_actor(this._label.actor);
|
||||||
this._arrow = PopupMenu.arrowIcon(St.Side.BOTTOM);
|
this._arrow = PopupMenu.arrowIcon(St.Side.BOTTOM);
|
||||||
this._hbox.add_actor(this._arrow);
|
this._container.add_actor(this._arrow);
|
||||||
|
|
||||||
this._iconBottomClip = 0;
|
this._iconBottomClip = 0;
|
||||||
|
|
||||||
@ -277,7 +271,7 @@ const AppMenuButton = new Lang.Class({
|
|||||||
return;
|
return;
|
||||||
this._spinnerIcon = icon;
|
this._spinnerIcon = icon;
|
||||||
this._spinner = new Animation.AnimatedIcon(this._spinnerIcon, PANEL_ICON_SIZE);
|
this._spinner = new Animation.AnimatedIcon(this._spinnerIcon, PANEL_ICON_SIZE);
|
||||||
this._hbox.add_actor(this._spinner.actor);
|
this._container.add_actor(this._spinner.actor);
|
||||||
this._spinner.actor.hide();
|
this._spinner.actor.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -291,7 +285,7 @@ const AppMenuButton = new Lang.Class({
|
|||||||
if (!this._targetApp)
|
if (!this._targetApp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let icon = this._targetApp.get_faded_icon(2 * PANEL_ICON_SIZE, this._iconBox.text_direction);
|
let icon = this._targetApp.create_icon_texture(2 * PANEL_ICON_SIZE);
|
||||||
this._iconBox.set_child(icon);
|
this._iconBox.set_child(icon);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -344,64 +338,6 @@ const AppMenuButton = new Lang.Class({
|
|||||||
this._spinner.actor.show();
|
this._spinner.actor.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
_getContentPreferredWidth: function(actor, forHeight, alloc) {
|
|
||||||
let [minSize, naturalSize] = this._iconBox.get_preferred_width(forHeight);
|
|
||||||
alloc.min_size = minSize;
|
|
||||||
alloc.natural_size = naturalSize;
|
|
||||||
[minSize, naturalSize] = this._hbox.get_preferred_width(forHeight);
|
|
||||||
alloc.min_size = alloc.min_size + Math.max(0, minSize - Math.floor(alloc.min_size / 2));
|
|
||||||
alloc.natural_size = alloc.natural_size + Math.max(0, naturalSize - Math.floor(alloc.natural_size / 2));
|
|
||||||
},
|
|
||||||
|
|
||||||
_getContentPreferredHeight: function(actor, forWidth, alloc) {
|
|
||||||
let [minSize, naturalSize] = this._iconBox.get_preferred_height(forWidth);
|
|
||||||
alloc.min_size = minSize;
|
|
||||||
alloc.natural_size = naturalSize;
|
|
||||||
[minSize, naturalSize] = this._hbox.get_preferred_height(forWidth);
|
|
||||||
if (minSize > alloc.min_size)
|
|
||||||
alloc.min_size = minSize;
|
|
||||||
if (naturalSize > alloc.natural_size)
|
|
||||||
alloc.natural_size = naturalSize;
|
|
||||||
},
|
|
||||||
|
|
||||||
_contentAllocate: function(actor, box, flags) {
|
|
||||||
let allocWidth = box.x2 - box.x1;
|
|
||||||
let allocHeight = box.y2 - box.y1;
|
|
||||||
let childBox = new Clutter.ActorBox();
|
|
||||||
|
|
||||||
let [minWidth, minHeight, naturalWidth, naturalHeight] = this._iconBox.get_preferred_size();
|
|
||||||
|
|
||||||
let direction = this.actor.get_text_direction();
|
|
||||||
|
|
||||||
let yPadding = Math.floor(Math.max(0, allocHeight - naturalHeight) / 2);
|
|
||||||
childBox.y1 = yPadding;
|
|
||||||
childBox.y2 = childBox.y1 + Math.min(naturalHeight, allocHeight);
|
|
||||||
if (direction == Clutter.TextDirection.LTR) {
|
|
||||||
childBox.x1 = 0;
|
|
||||||
childBox.x2 = childBox.x1 + Math.min(naturalWidth, allocWidth);
|
|
||||||
} else {
|
|
||||||
childBox.x1 = Math.max(0, allocWidth - naturalWidth);
|
|
||||||
childBox.x2 = allocWidth;
|
|
||||||
}
|
|
||||||
this._iconBox.allocate(childBox, flags);
|
|
||||||
|
|
||||||
let iconWidth = childBox.x2 - childBox.x1;
|
|
||||||
|
|
||||||
[minWidth, naturalWidth] = this._hbox.get_preferred_width(-1);
|
|
||||||
|
|
||||||
childBox.y1 = 0;
|
|
||||||
childBox.y2 = allocHeight;
|
|
||||||
|
|
||||||
if (direction == Clutter.TextDirection.LTR) {
|
|
||||||
childBox.x1 = Math.floor(iconWidth / 2);
|
|
||||||
childBox.x2 = Math.min(childBox.x1 + naturalWidth, allocWidth);
|
|
||||||
} else {
|
|
||||||
childBox.x2 = allocWidth - Math.floor(iconWidth / 2);
|
|
||||||
childBox.x1 = Math.max(0, childBox.x2 - naturalWidth);
|
|
||||||
}
|
|
||||||
this._hbox.allocate(childBox, flags);
|
|
||||||
},
|
|
||||||
|
|
||||||
_onAppStateChanged: function(appSys, app) {
|
_onAppStateChanged: function(appSys, app) {
|
||||||
let state = app.state;
|
let state = app.state;
|
||||||
if (state != Shell.AppState.STARTING) {
|
if (state != Shell.AppState.STARTING) {
|
||||||
|
Reference in New Issue
Block a user