overviewControls: split out an util function

Will be used later

https://bugzilla.gnome.org/show_bug.cgi?id=693924
This commit is contained in:
Cosimo Cecchi 2013-02-15 20:43:01 -05:00
parent 8ce3531de8
commit 7ed4bd67b8

View File

@ -10,6 +10,15 @@ const ViewSelector = imports.ui.viewSelector;
const SIDE_CONTROLS_ANIMATION_TIME = 0.2; const SIDE_CONTROLS_ANIMATION_TIME = 0.2;
function getRtlSlideDirection(direction, actor) {
let rtl = (actor.text_direction == Clutter.TextDirection.RTL);
if (rtl)
direction = (direction == SlideDirection.LEFT) ?
SlideDirection.RIGHT : SlideDirection.LEFT;
return direction;
};
const SlideDirection = { const SlideDirection = {
LEFT: 0, LEFT: 0,
RIGHT: 1 RIGHT: 1
@ -26,17 +35,6 @@ const SlideLayout = new Lang.Class({
this.parent(params); this.parent(params);
}, },
_getRealSlideDirection: function(child) {
let direction = this._direction;
let rtl = (child.text_direction == Clutter.TextDirection.RTL);
if (rtl)
direction = (direction == SlideDirection.LEFT) ?
SlideDirection.RIGHT : SlideDirection.LEFT;
return direction;
},
vfunc_get_preferred_width: function(container, forHeight) { vfunc_get_preferred_width: function(container, forHeight) {
let child = container.get_first_child(); let child = container.get_first_child();
@ -55,7 +53,7 @@ const SlideLayout = new Lang.Class({
let availWidth = Math.round(box.x2 - box.x1); let availWidth = Math.round(box.x2 - box.x1);
let availHeight = Math.round(box.y2 - box.y1); let availHeight = Math.round(box.y2 - box.y1);
let realDirection = this._getRealSlideDirection(child); let realDirection = getRtlSlideDirection(this._direction, child);
let translationX = (realDirection == SlideDirection.LEFT) ? let translationX = (realDirection == SlideDirection.LEFT) ?
(availWidth - natWidth) : (natWidth - availWidth); (availWidth - natWidth) : (natWidth - availWidth);