2013-02-14 19:41:38 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2013-05-29 01:10:58 +00:00
|
|
|
const GObject = imports.gi.GObject;
|
2013-02-14 19:41:38 +00:00
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const Lang = imports.lang;
|
2013-01-24 11:14:19 +00:00
|
|
|
const Meta = imports.gi.Meta;
|
2013-02-14 19:41:38 +00:00
|
|
|
const St = imports.gi.St;
|
2013-02-17 18:51:51 +00:00
|
|
|
const Shell = imports.gi.Shell;
|
2013-02-14 19:41:38 +00:00
|
|
|
|
2013-02-25 23:05:45 +00:00
|
|
|
const Dash = imports.ui.dash;
|
2013-02-14 19:41:38 +00:00
|
|
|
const Main = imports.ui.main;
|
2013-02-19 03:35:04 +00:00
|
|
|
const Params = imports.misc.params;
|
2012-12-11 22:26:09 +00:00
|
|
|
const Tweener = imports.ui.tweener;
|
2013-02-15 23:25:36 +00:00
|
|
|
const ViewSelector = imports.ui.viewSelector;
|
2013-02-25 23:05:45 +00:00
|
|
|
const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
|
2013-02-14 19:41:38 +00:00
|
|
|
|
2017-07-18 17:47:27 +00:00
|
|
|
var SIDE_CONTROLS_ANIMATION_TIME = 0.16;
|
2013-02-14 19:41:38 +00:00
|
|
|
|
2013-02-16 01:43:01 +00:00
|
|
|
function getRtlSlideDirection(direction, actor) {
|
|
|
|
let rtl = (actor.text_direction == Clutter.TextDirection.RTL);
|
|
|
|
if (rtl)
|
|
|
|
direction = (direction == SlideDirection.LEFT) ?
|
|
|
|
SlideDirection.RIGHT : SlideDirection.LEFT;
|
|
|
|
|
|
|
|
return direction;
|
|
|
|
};
|
|
|
|
|
2017-07-18 17:47:27 +00:00
|
|
|
var SlideDirection = {
|
2013-02-14 19:41:38 +00:00
|
|
|
LEFT: 0,
|
|
|
|
RIGHT: 1
|
|
|
|
};
|
|
|
|
|
2017-07-18 17:41:25 +00:00
|
|
|
var SlideLayout = new Lang.Class({
|
2013-02-14 19:41:38 +00:00
|
|
|
Name: 'SlideLayout',
|
|
|
|
Extends: Clutter.FixedLayout,
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_init(params) {
|
2013-02-14 19:41:38 +00:00
|
|
|
this._slideX = 1;
|
2014-08-31 00:18:51 +00:00
|
|
|
this._translationX = undefined;
|
2013-02-14 19:41:38 +00:00
|
|
|
this._direction = SlideDirection.LEFT;
|
|
|
|
|
|
|
|
this.parent(params);
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
vfunc_get_preferred_width(container, forHeight) {
|
2013-02-14 19:41:38 +00:00
|
|
|
let child = container.get_first_child();
|
|
|
|
|
|
|
|
let [minWidth, natWidth] = child.get_preferred_width(forHeight);
|
|
|
|
|
|
|
|
minWidth *= this._slideX;
|
|
|
|
natWidth *= this._slideX;
|
|
|
|
|
|
|
|
return [minWidth, natWidth];
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
vfunc_allocate(container, box, flags) {
|
2013-02-14 19:41:38 +00:00
|
|
|
let child = container.get_first_child();
|
|
|
|
|
|
|
|
let availWidth = Math.round(box.x2 - box.x1);
|
|
|
|
let availHeight = Math.round(box.y2 - box.y1);
|
2013-10-12 02:36:49 +00:00
|
|
|
let [, natWidth] = child.get_preferred_width(availHeight);
|
2013-02-14 19:41:38 +00:00
|
|
|
|
2013-09-18 23:48:22 +00:00
|
|
|
// Align the actor inside the clipped box, as the actor's alignment
|
|
|
|
// flags only determine what to do if the allocated box is bigger
|
|
|
|
// than the actor's box.
|
2013-02-16 01:43:01 +00:00
|
|
|
let realDirection = getRtlSlideDirection(this._direction, child);
|
2014-10-10 08:58:42 +00:00
|
|
|
let alignX = (realDirection == SlideDirection.LEFT) ? (availWidth - natWidth)
|
|
|
|
: (availWidth - natWidth * this._slideX);
|
2013-02-14 19:41:38 +00:00
|
|
|
|
2013-09-18 23:42:41 +00:00
|
|
|
let actorBox = new Clutter.ActorBox();
|
2013-09-18 23:59:02 +00:00
|
|
|
actorBox.x1 = box.x1 + alignX + this._translationX;
|
2013-11-03 00:06:29 +00:00
|
|
|
actorBox.x2 = actorBox.x1 + (child.x_expand ? availWidth : natWidth);
|
2013-10-21 21:51:50 +00:00
|
|
|
actorBox.y1 = box.y1;
|
2013-10-12 02:36:49 +00:00
|
|
|
actorBox.y2 = actorBox.y1 + availHeight;
|
2013-02-14 19:41:38 +00:00
|
|
|
|
|
|
|
child.allocate(actorBox, flags);
|
|
|
|
},
|
|
|
|
|
|
|
|
set slideX(value) {
|
|
|
|
this._slideX = value;
|
|
|
|
this.layout_changed();
|
|
|
|
},
|
|
|
|
|
|
|
|
get slideX() {
|
|
|
|
return this._slideX;
|
|
|
|
},
|
|
|
|
|
|
|
|
set slideDirection(direction) {
|
|
|
|
this._direction = direction;
|
|
|
|
this.layout_changed();
|
|
|
|
},
|
|
|
|
|
|
|
|
get slideDirection() {
|
|
|
|
return this._direction;
|
2013-09-18 23:59:02 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
set translationX(value) {
|
|
|
|
this._translationX = value;
|
|
|
|
this.layout_changed();
|
|
|
|
},
|
|
|
|
|
|
|
|
get translationX() {
|
|
|
|
return this._translationX;
|
|
|
|
},
|
2013-02-14 19:41:38 +00:00
|
|
|
});
|
|
|
|
|
2017-07-18 17:41:25 +00:00
|
|
|
var SlidingControl = new Lang.Class({
|
2013-02-14 19:41:38 +00:00
|
|
|
Name: 'SlidingControl',
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_init(params) {
|
2013-02-19 03:35:04 +00:00
|
|
|
params = Params.parse(params, { slideDirection: SlideDirection.LEFT });
|
|
|
|
|
2013-09-18 23:06:56 +00:00
|
|
|
this._visible = true;
|
|
|
|
this._inDrag = false;
|
2013-02-14 19:41:38 +00:00
|
|
|
|
|
|
|
this.layout = new SlideLayout();
|
2013-02-19 03:35:04 +00:00
|
|
|
this.layout.slideDirection = params.slideDirection;
|
2013-02-14 19:41:38 +00:00
|
|
|
this.actor = new St.Widget({ layout_manager: this.layout,
|
2013-02-21 15:44:32 +00:00
|
|
|
style_class: 'overview-controls',
|
2013-02-14 19:41:38 +00:00
|
|
|
clip_to_allocation: true });
|
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
Main.overview.connect('hiding', this._onOverviewHiding.bind(this));
|
2013-02-14 19:41:38 +00:00
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
Main.overview.connect('item-drag-begin', this._onDragBegin.bind(this));
|
|
|
|
Main.overview.connect('item-drag-end', this._onDragEnd.bind(this));
|
|
|
|
Main.overview.connect('item-drag-cancelled', this._onDragEnd.bind(this));
|
2013-02-19 03:34:27 +00:00
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
Main.overview.connect('window-drag-begin', this._onWindowDragBegin.bind(this));
|
|
|
|
Main.overview.connect('window-drag-cancelled', this._onWindowDragEnd.bind(this));
|
|
|
|
Main.overview.connect('window-drag-end', this._onWindowDragEnd.bind(this));
|
2013-02-14 19:41:38 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getSlide() {
|
2013-02-14 19:41:38 +00:00
|
|
|
throw new Error('getSlide() must be overridden');
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateSlide() {
|
2013-09-18 23:22:54 +00:00
|
|
|
Tweener.addTween(this.layout, { slideX: this._getSlide(),
|
2013-02-14 19:41:38 +00:00
|
|
|
time: SIDE_CONTROLS_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad' });
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getVisibleWidth() {
|
2013-02-16 01:50:26 +00:00
|
|
|
let child = this.actor.get_first_child();
|
|
|
|
let [, , natWidth, ] = child.get_preferred_size();
|
|
|
|
return natWidth;
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getTranslation() {
|
2013-02-16 01:50:26 +00:00
|
|
|
let child = this.actor.get_first_child();
|
|
|
|
let direction = getRtlSlideDirection(this.layout.slideDirection, child);
|
|
|
|
let visibleWidth = this.getVisibleWidth();
|
|
|
|
|
|
|
|
if (direction == SlideDirection.LEFT)
|
2013-02-18 06:24:40 +00:00
|
|
|
return - visibleWidth;
|
2013-02-16 01:50:26 +00:00
|
|
|
else
|
2013-02-18 06:24:40 +00:00
|
|
|
return visibleWidth;
|
2013-02-16 01:50:26 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateTranslation() {
|
2013-02-16 01:50:26 +00:00
|
|
|
let translationStart = 0;
|
|
|
|
let translationEnd = 0;
|
|
|
|
let translation = this._getTranslation();
|
|
|
|
|
2014-08-31 00:20:43 +00:00
|
|
|
let shouldShow = (this._getSlide() > 0);
|
|
|
|
if (shouldShow) {
|
2013-02-16 01:50:26 +00:00
|
|
|
translationStart = translation;
|
|
|
|
} else {
|
|
|
|
translationEnd = translation;
|
|
|
|
}
|
|
|
|
|
2013-09-18 23:59:02 +00:00
|
|
|
if (this.layout.translationX == translationEnd)
|
2013-02-18 19:17:29 +00:00
|
|
|
return;
|
|
|
|
|
2013-09-18 23:59:02 +00:00
|
|
|
this.layout.translationX = translationStart;
|
|
|
|
Tweener.addTween(this.layout, { translationX: translationEnd,
|
|
|
|
time: SIDE_CONTROLS_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad' });
|
2013-02-16 01:50:26 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onOverviewHiding() {
|
2014-08-31 01:30:48 +00:00
|
|
|
// We need to explicitly slideOut since showing pages
|
|
|
|
// doesn't imply sliding out, instead, hiding the overview does.
|
2013-09-18 23:13:35 +00:00
|
|
|
this.slideOut();
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onWindowDragBegin() {
|
2013-02-19 03:34:27 +00:00
|
|
|
this._onDragBegin();
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onWindowDragEnd() {
|
2013-02-19 03:34:27 +00:00
|
|
|
this._onDragEnd();
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onDragBegin() {
|
2013-09-18 23:06:56 +00:00
|
|
|
this._inDrag = true;
|
2014-08-31 00:20:43 +00:00
|
|
|
this._updateTranslation();
|
2013-09-18 23:22:54 +00:00
|
|
|
this._updateSlide();
|
2013-02-14 19:41:38 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onDragEnd() {
|
2013-09-18 23:06:56 +00:00
|
|
|
this._inDrag = false;
|
2013-09-18 23:22:54 +00:00
|
|
|
this._updateSlide();
|
2013-02-14 19:41:38 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
fadeIn() {
|
2013-02-19 03:34:27 +00:00
|
|
|
Tweener.addTween(this.actor, { opacity: 255,
|
|
|
|
time: SIDE_CONTROLS_ANIMATION_TIME / 2,
|
|
|
|
transition: 'easeInQuad'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
fadeHalf() {
|
2013-02-19 03:34:27 +00:00
|
|
|
Tweener.addTween(this.actor, { opacity: 128,
|
|
|
|
time: SIDE_CONTROLS_ANIMATION_TIME / 2,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
slideIn() {
|
2013-09-18 23:06:56 +00:00
|
|
|
this._visible = true;
|
2013-09-26 20:20:06 +00:00
|
|
|
// we will update slideX and the translation from pageEmpty
|
2013-02-14 19:41:38 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
slideOut() {
|
2013-09-18 23:06:56 +00:00
|
|
|
this._visible = false;
|
2013-02-18 06:25:54 +00:00
|
|
|
this._updateTranslation();
|
2013-09-26 20:20:06 +00:00
|
|
|
// we will update slideX from pageEmpty
|
2013-02-16 01:50:26 +00:00
|
|
|
},
|
2013-09-26 20:20:06 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
pageEmpty() {
|
2013-09-26 20:20:06 +00:00
|
|
|
// When pageEmpty is received, there's no visible view in the
|
|
|
|
// selector; this means we can now safely set the full slide for
|
|
|
|
// the next page, since slideIn or slideOut might have been called,
|
|
|
|
// changing the visiblity
|
2013-09-18 23:22:54 +00:00
|
|
|
this.layout.slideX = this._getSlide();
|
2013-09-26 20:20:06 +00:00
|
|
|
this._updateTranslation();
|
|
|
|
}
|
2013-02-14 19:41:38 +00:00
|
|
|
});
|
2012-12-11 22:26:09 +00:00
|
|
|
|
2017-07-18 17:41:25 +00:00
|
|
|
var ThumbnailsSlider = new Lang.Class({
|
2012-12-11 22:26:09 +00:00
|
|
|
Name: 'ThumbnailsSlider',
|
|
|
|
Extends: SlidingControl,
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_init(thumbnailsBox) {
|
2013-02-19 03:35:04 +00:00
|
|
|
this.parent({ slideDirection: SlideDirection.RIGHT });
|
2012-12-11 22:26:09 +00:00
|
|
|
|
|
|
|
this._thumbnailsBox = thumbnailsBox;
|
|
|
|
|
|
|
|
this.actor.request_mode = Clutter.RequestMode.WIDTH_FOR_HEIGHT;
|
|
|
|
this.actor.reactive = true;
|
|
|
|
this.actor.track_hover = true;
|
|
|
|
this.actor.add_actor(this._thumbnailsBox.actor);
|
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
Main.layoutManager.connect('monitors-changed', this._updateSlide.bind(this));
|
|
|
|
this.actor.connect('notify::hover', this._updateSlide.bind(this));
|
2013-05-29 01:10:58 +00:00
|
|
|
this._thumbnailsBox.actor.bind_property('visible', this.actor, 'visible', GObject.BindingFlags.SYNC_CREATE);
|
2012-12-11 22:26:09 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getAlwaysZoomOut() {
|
2017-06-01 13:38:41 +00:00
|
|
|
// Always show the pager on hover or during a drag
|
|
|
|
let alwaysZoomOut = this.actor.hover || this._inDrag;
|
2012-12-11 22:26:09 +00:00
|
|
|
|
|
|
|
if (!alwaysZoomOut) {
|
|
|
|
let monitors = Main.layoutManager.monitors;
|
|
|
|
let primary = Main.layoutManager.primaryMonitor;
|
|
|
|
|
|
|
|
/* Look for any monitor to the right of the primary, if there is
|
|
|
|
* one, we always keep zoom out, otherwise its hard to reach
|
|
|
|
* the thumbnail area without passing into the next monitor. */
|
|
|
|
for (let i = 0; i < monitors.length; i++) {
|
|
|
|
if (monitors[i].x >= primary.x + primary.width) {
|
|
|
|
alwaysZoomOut = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-16 01:50:26 +00:00
|
|
|
return alwaysZoomOut;
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getNonExpandedWidth() {
|
2013-04-20 16:29:58 +00:00
|
|
|
let child = this.actor.get_first_child();
|
|
|
|
return child.get_theme_node().get_length('visible-width');
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getSlide() {
|
2013-09-18 23:06:56 +00:00
|
|
|
if (!this._visible)
|
2013-02-16 01:50:26 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
let alwaysZoomOut = this._getAlwaysZoomOut();
|
2012-12-11 22:26:09 +00:00
|
|
|
if (alwaysZoomOut)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
let child = this.actor.get_first_child();
|
|
|
|
let preferredHeight = child.get_preferred_height(-1)[1];
|
|
|
|
let expandedWidth = child.get_preferred_width(preferredHeight)[1];
|
|
|
|
|
2013-04-20 16:29:58 +00:00
|
|
|
return this.getNonExpandedWidth() / expandedWidth;
|
2013-02-16 01:50:26 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getVisibleWidth() {
|
2013-02-16 01:50:26 +00:00
|
|
|
let alwaysZoomOut = this._getAlwaysZoomOut();
|
|
|
|
if (alwaysZoomOut)
|
|
|
|
return this.parent();
|
2013-04-20 16:29:58 +00:00
|
|
|
else
|
|
|
|
return this.getNonExpandedWidth();
|
2012-12-11 22:26:09 +00:00
|
|
|
}
|
|
|
|
});
|
2013-01-24 04:11:23 +00:00
|
|
|
|
2017-07-18 17:41:25 +00:00
|
|
|
var DashSlider = new Lang.Class({
|
2013-01-24 04:11:23 +00:00
|
|
|
Name: 'DashSlider',
|
|
|
|
Extends: SlidingControl,
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_init(dash) {
|
2013-02-19 03:35:04 +00:00
|
|
|
this.parent({ slideDirection: SlideDirection.LEFT });
|
2013-01-24 04:11:23 +00:00
|
|
|
|
2013-02-15 23:26:24 +00:00
|
|
|
this._dash = dash;
|
2013-01-24 04:11:23 +00:00
|
|
|
|
2013-10-30 22:32:26 +00:00
|
|
|
// SlideLayout reads the actor's expand flags to decide
|
|
|
|
// whether to allocate the natural size to its child, or the whole
|
|
|
|
// available allocation
|
|
|
|
this._dash.actor.x_expand = true;
|
|
|
|
|
2013-09-18 23:40:38 +00:00
|
|
|
this.actor.x_expand = true;
|
2013-02-25 23:05:45 +00:00
|
|
|
this.actor.x_align = Clutter.ActorAlign.START;
|
|
|
|
this.actor.y_expand = true;
|
|
|
|
|
2013-02-15 23:26:24 +00:00
|
|
|
this.actor.add_actor(this._dash.actor);
|
2013-01-24 04:11:23 +00:00
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
this._dash.connect('icon-size-changed', this._updateSlide.bind(this));
|
2013-01-24 04:11:23 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_getSlide() {
|
2013-09-18 23:06:56 +00:00
|
|
|
if (this._visible || this._inDrag)
|
2013-01-24 04:11:23 +00:00
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
2013-02-19 03:34:27 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onWindowDragBegin() {
|
2013-02-19 03:34:27 +00:00
|
|
|
this.fadeHalf();
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onWindowDragEnd() {
|
2013-02-19 03:34:27 +00:00
|
|
|
this.fadeIn();
|
2013-01-24 04:11:23 +00:00
|
|
|
}
|
|
|
|
});
|
2013-02-15 23:25:36 +00:00
|
|
|
|
2017-07-18 17:41:25 +00:00
|
|
|
var DashSpacer = new Lang.Class({
|
2013-02-21 17:48:09 +00:00
|
|
|
Name: 'DashSpacer',
|
|
|
|
Extends: St.Widget,
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_init(params) {
|
2013-02-21 17:48:09 +00:00
|
|
|
this.parent(params);
|
|
|
|
|
|
|
|
this._bindConstraint = null;
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
setDashActor(dashActor) {
|
2013-02-21 17:48:09 +00:00
|
|
|
if (this._bindConstraint) {
|
|
|
|
this.remove_constraint(this._bindConstraint);
|
|
|
|
this._bindConstraint = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dashActor) {
|
|
|
|
this._bindConstraint = new Clutter.BindConstraint({ source: dashActor,
|
|
|
|
coordinate: Clutter.BindCoordinate.SIZE });
|
|
|
|
this.add_constraint(this._bindConstraint);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
vfunc_get_preferred_width(forHeight) {
|
2013-02-21 17:48:09 +00:00
|
|
|
let box = this.get_allocation_box();
|
|
|
|
let minWidth = this.parent(forHeight)[0];
|
|
|
|
let natWidth = box.x2 - box.x1;
|
|
|
|
return [minWidth, natWidth];
|
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
vfunc_get_preferred_height(forWidth) {
|
2013-02-21 17:48:09 +00:00
|
|
|
let box = this.get_allocation_box();
|
|
|
|
let minHeight = this.parent(forWidth)[0];
|
|
|
|
let natHeight = box.y2 - box.y1;
|
|
|
|
return [minHeight, natHeight];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-07-18 17:41:25 +00:00
|
|
|
var ControlsLayout = new Lang.Class({
|
2013-09-13 07:34:13 +00:00
|
|
|
Name: 'ControlsLayout',
|
|
|
|
Extends: Clutter.BinLayout,
|
|
|
|
Signals: { 'allocation-changed': { flags: GObject.SignalFlags.RUN_LAST } },
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
vfunc_allocate(container, box, flags) {
|
2013-09-13 07:34:13 +00:00
|
|
|
this.parent(container, box, flags);
|
|
|
|
this.emit('allocation-changed');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-07-18 17:41:25 +00:00
|
|
|
var ControlsManager = new Lang.Class({
|
2013-02-15 23:25:36 +00:00
|
|
|
Name: 'ControlsManager',
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_init(searchEntry) {
|
2013-02-25 23:05:45 +00:00
|
|
|
this.dash = new Dash.Dash();
|
|
|
|
this._dashSlider = new DashSlider(this.dash);
|
|
|
|
this._dashSpacer = new DashSpacer();
|
|
|
|
this._dashSpacer.setDashActor(this._dashSlider.actor);
|
|
|
|
|
|
|
|
this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox();
|
|
|
|
this._thumbnailsSlider = new ThumbnailsSlider(this._thumbnailsBox);
|
2013-02-15 23:25:36 +00:00
|
|
|
|
2013-02-25 23:05:45 +00:00
|
|
|
this.viewSelector = new ViewSelector.ViewSelector(searchEntry,
|
|
|
|
this.dash.showAppsButton);
|
2017-12-02 00:27:35 +00:00
|
|
|
this.viewSelector.connect('page-changed', this._setVisibility.bind(this));
|
|
|
|
this.viewSelector.connect('page-empty', this._onPageEmpty.bind(this));
|
2013-02-15 23:25:36 +00:00
|
|
|
|
2013-09-13 07:34:13 +00:00
|
|
|
let layout = new ControlsLayout();
|
|
|
|
this.actor = new St.Widget({ layout_manager: layout,
|
2013-02-25 23:05:45 +00:00
|
|
|
x_expand: true, y_expand: true,
|
|
|
|
clip_to_allocation: true });
|
|
|
|
this._group = new St.BoxLayout({ name: 'overview-group',
|
|
|
|
x_expand: true, y_expand: true });
|
|
|
|
this.actor.add_actor(this._group);
|
|
|
|
|
|
|
|
this.actor.add_actor(this._dashSlider.actor);
|
|
|
|
|
|
|
|
this._group.add_actor(this._dashSpacer);
|
|
|
|
this._group.add(this.viewSelector.actor, { x_fill: true,
|
|
|
|
expand: true });
|
|
|
|
this._group.add_actor(this._thumbnailsSlider.actor);
|
2013-02-18 04:45:24 +00:00
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
layout.connect('allocation-changed', this._updateWorkspacesGeometry.bind(this));
|
2013-02-25 23:11:59 +00:00
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
Main.overview.connect('showing', this._updateSpacerVisibility.bind(this));
|
2017-10-31 00:38:18 +00:00
|
|
|
Main.overview.connect('item-drag-begin', () => {
|
|
|
|
let activePage = this.viewSelector.getActivePage();
|
|
|
|
if (activePage != ViewSelector.ViewPage.WINDOWS)
|
|
|
|
this.viewSelector.fadeHalf();
|
|
|
|
});
|
|
|
|
Main.overview.connect('item-drag-end', () => {
|
|
|
|
this.viewSelector.fadeIn();
|
|
|
|
});
|
|
|
|
Main.overview.connect('item-drag-cancelled', () => {
|
|
|
|
this.viewSelector.fadeIn();
|
|
|
|
});
|
2013-02-15 23:25:36 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateWorkspacesGeometry() {
|
2013-02-25 23:11:59 +00:00
|
|
|
let [x, y] = this.actor.get_transformed_position();
|
|
|
|
let [width, height] = this.actor.get_transformed_size();
|
|
|
|
let geometry = { x: x, y: y, width: width, height: height };
|
|
|
|
|
|
|
|
let spacing = this.actor.get_theme_node().get_length('spacing');
|
|
|
|
let dashWidth = this._dashSlider.getVisibleWidth() + spacing;
|
|
|
|
let thumbnailsWidth = this._thumbnailsSlider.getNonExpandedWidth() + spacing;
|
|
|
|
|
|
|
|
geometry.width -= dashWidth;
|
|
|
|
geometry.width -= thumbnailsWidth;
|
|
|
|
|
|
|
|
if (this.actor.get_text_direction() == Clutter.TextDirection.LTR)
|
|
|
|
geometry.x += dashWidth;
|
|
|
|
else
|
|
|
|
geometry.x += thumbnailsWidth;
|
|
|
|
|
2013-02-25 23:25:27 +00:00
|
|
|
this.viewSelector.setWorkspacesFullGeometry(geometry);
|
2013-02-25 23:11:59 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_setVisibility() {
|
2013-02-15 23:25:36 +00:00
|
|
|
// Ignore the case when we're leaving the overview, since
|
|
|
|
// actors will be made visible again when entering the overview
|
|
|
|
// next time, and animating them while doing so is just
|
|
|
|
// unnecessary noise
|
2013-02-16 17:45:10 +00:00
|
|
|
if (!Main.overview.visible ||
|
|
|
|
(Main.overview.animationInProgress && !Main.overview.visibleTarget))
|
2013-02-15 23:25:36 +00:00
|
|
|
return;
|
|
|
|
|
2013-02-25 23:05:45 +00:00
|
|
|
let activePage = this.viewSelector.getActivePage();
|
2013-02-15 23:25:36 +00:00
|
|
|
let dashVisible = (activePage == ViewSelector.ViewPage.WINDOWS ||
|
|
|
|
activePage == ViewSelector.ViewPage.APPS);
|
2013-09-26 20:20:06 +00:00
|
|
|
let thumbnailsVisible = (activePage == ViewSelector.ViewPage.WINDOWS);
|
|
|
|
|
|
|
|
if (dashVisible)
|
|
|
|
this._dashSlider.slideIn();
|
|
|
|
else
|
2013-02-15 23:25:36 +00:00
|
|
|
this._dashSlider.slideOut();
|
|
|
|
|
2013-09-26 20:20:06 +00:00
|
|
|
if (thumbnailsVisible)
|
|
|
|
this._thumbnailsSlider.slideIn();
|
|
|
|
else
|
2013-02-15 23:25:36 +00:00
|
|
|
this._thumbnailsSlider.slideOut();
|
2013-02-16 01:50:26 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateSpacerVisibility() {
|
2013-02-21 17:48:09 +00:00
|
|
|
if (Main.overview.animationInProgress && !Main.overview.visibleTarget)
|
|
|
|
return;
|
|
|
|
|
2013-02-25 23:05:45 +00:00
|
|
|
let activePage = this.viewSelector.getActivePage();
|
|
|
|
this._dashSpacer.visible = (activePage == ViewSelector.ViewPage.WINDOWS);
|
2013-02-21 17:48:09 +00:00
|
|
|
},
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onPageEmpty() {
|
2013-09-26 20:20:06 +00:00
|
|
|
this._dashSlider.pageEmpty();
|
|
|
|
this._thumbnailsSlider.pageEmpty();
|
2013-02-21 17:48:09 +00:00
|
|
|
|
|
|
|
this._updateSpacerVisibility();
|
2013-02-15 23:25:36 +00:00
|
|
|
}
|
|
|
|
});
|