overviewControls: Move translation-x to SlideLayout

Not because ClutterActor is bad or wrong, but because I always get
confused on the difference, and having them both in SlideLayout
makes the code a bit easier to read and understand.
This commit is contained in:
Jasper St. Pierre 2013-09-18 19:59:02 -04:00
parent f5a9dbb348
commit 88393f0f65

View File

@ -36,6 +36,7 @@ const SlideLayout = new Lang.Class({
_init: function(params) { _init: function(params) {
this._slideX = 1; this._slideX = 1;
this._translationX = 0;
this._direction = SlideDirection.LEFT; this._direction = SlideDirection.LEFT;
this.parent(params); this.parent(params);
@ -66,7 +67,7 @@ const SlideLayout = new Lang.Class({
let alignX = (realDirection == SlideDirection.LEFT) ? (availWidth - natWidth) : 0; let alignX = (realDirection == SlideDirection.LEFT) ? (availWidth - natWidth) : 0;
let actorBox = new Clutter.ActorBox(); let actorBox = new Clutter.ActorBox();
actorBox.x1 = box.x1 + alignX; actorBox.x1 = box.x1 + alignX + this._translationX;
actorBox.x2 = actorBox.x1 + availWidth; actorBox.x2 = actorBox.x1 + availWidth;
actorBox.y1 = box.y1; actorBox.y1 = box.y1;
actorBox.y2 = actorBox.y1 + availHeight; actorBox.y2 = actorBox.y1 + availHeight;
@ -90,7 +91,16 @@ const SlideLayout = new Lang.Class({
get slideDirection() { get slideDirection() {
return this._direction; return this._direction;
} },
set translationX(value) {
this._translationX = value;
this.layout_changed();
},
get translationX() {
return this._translationX;
},
}); });
const SlidingControl = new Lang.Class({ const SlidingControl = new Lang.Class({
@ -158,20 +168,19 @@ const SlidingControl = new Lang.Class({
translationEnd = translation; translationEnd = translation;
} }
if (this.actor.translation_x == translationEnd) if (this.layout.translationX == translationEnd)
return; return;
this.actor.translation_x = translationStart; this.layout.translationX = translationStart;
Tweener.addTween(this.actor, { translation_x: translationEnd, Tweener.addTween(this.layout, { translationX: translationEnd,
time: SIDE_CONTROLS_ANIMATION_TIME, time: SIDE_CONTROLS_ANIMATION_TIME,
transition: 'easeOutQuad' transition: 'easeOutQuad' });
});
}, },
_onOverviewShowing: function() { _onOverviewShowing: function() {
this._visible = true; this._visible = true;
this.layout.slideX = this._getSlide(); this.layout.slideX = this._getSlide();
this.actor.translation_x = this._getTranslation(); this.layout.translationX = this._getTranslation();
this.slideIn(); this.slideIn();
}, },
@ -189,7 +198,7 @@ const SlidingControl = new Lang.Class({
_onDragBegin: function() { _onDragBegin: function() {
this._inDrag = true; this._inDrag = true;
this.actor.translation_x = 0; this.layout.translationX = 0;
this._updateSlide(); this._updateSlide();
}, },