Move 'workspace_relative' definition to workspace.js

'workspace_relative' is used in workspace.js, not in workspacesView.js

Change a couple strings to have single quotes instead of double quotes to indicate that
they don't need to be translated.
This commit is contained in:
Marina Zhurakhinskaya 2010-01-22 20:04:18 -05:00
parent 8184b2c57b
commit 648126e598
2 changed files with 53 additions and 53 deletions

View File

@ -1370,3 +1370,56 @@ Workspace.prototype = {
}; };
Signals.addSignalMethods(Workspace.prototype); Signals.addSignalMethods(Workspace.prototype);
// Create a SpecialPropertyModifier to let us move windows in a
// straight line on the screen even though their containing workspace
// is also moving.
Tweener.registerSpecialPropertyModifier('workspace_relative', _workspaceRelativeModifier, _workspaceRelativeGet);
function _workspaceRelativeModifier(workspace) {
let [startX, startY] = Main.overview.getPosition();
let overviewPosX, overviewPosY, overviewScale;
if (!workspace)
return [];
if (workspace.leavingOverview) {
let [zoomedInX, zoomedInY] = Main.overview.getZoomedInPosition();
overviewPosX = { begin: startX, end: zoomedInX };
overviewPosY = { begin: startY, end: zoomedInY };
overviewScale = { begin: Main.overview.getScale(),
end: Main.overview.getZoomedInScale() };
} else {
overviewPosX = { begin: startX, end: 0 };
overviewPosY = { begin: startY, end: 0 };
overviewScale = { begin: Main.overview.getScale(), end: 1 };
}
return [ { name: 'x',
parameters: { workspacePos: workspace.gridX,
overviewPos: overviewPosX,
overviewScale: overviewScale } },
{ name: 'y',
parameters: { workspacePos: workspace.gridY,
overviewPos: overviewPosY,
overviewScale: overviewScale } }
];
}
function _workspaceRelativeGet(begin, end, time, params) {
let curOverviewPos = (1 - time) * params.overviewPos.begin +
time * params.overviewPos.end;
let curOverviewScale = (1 - time) * params.overviewScale.begin +
time * params.overviewScale.end;
// Calculate the screen position of the window.
let screen = (1 - time) *
((begin + params.workspacePos) * params.overviewScale.begin +
params.overviewPos.begin) +
time *
((end + params.workspacePos) * params.overviewScale.end +
params.overviewPos.end);
// Return the workspace coordinates.
return (screen - curOverviewPos) / curOverviewScale - params.workspacePos;
}

View File

@ -459,11 +459,6 @@ MosaicView.prototype = {
} }
}; };
// Create a SpecialPropertyModifier to let us move windows in a
// straight line on the screen even though their containing workspace
// is also moving.
Tweener.registerSpecialPropertyModifier("workspace_relative", _workspaceRelativeModifier, _workspaceRelativeGet);
function SingleView(width, height, x, y, animate) { function SingleView(width, height, x, y, animate) {
this._init(width, height, x, y, animate); this._init(width, height, x, y, animate);
} }
@ -833,54 +828,6 @@ SingleView.prototype = {
} }
}; };
function _workspaceRelativeModifier(workspace) {
let [startX, startY] = Main.overview.getPosition();
let overviewPosX, overviewPosY, overviewScale;
if (!workspace)
return [];
if (workspace.leavingOverview) {
let [zoomedInX, zoomedInY] = Main.overview.getZoomedInPosition();
overviewPosX = { begin: startX, end: zoomedInX };
overviewPosY = { begin: startY, end: zoomedInY };
overviewScale = { begin: Main.overview.getScale(),
end: Main.overview.getZoomedInScale() };
} else {
overviewPosX = { begin: startX, end: 0 };
overviewPosY = { begin: startY, end: 0 };
overviewScale = { begin: Main.overview.getScale(), end: 1 };
}
return [ { name: "x",
parameters: { workspacePos: workspace.gridX,
overviewPos: overviewPosX,
overviewScale: overviewScale } },
{ name: "y",
parameters: { workspacePos: workspace.gridY,
overviewPos: overviewPosY,
overviewScale: overviewScale } }
];
}
function _workspaceRelativeGet(begin, end, time, params) {
let curOverviewPos = (1 - time) * params.overviewPos.begin +
time * params.overviewPos.end;
let curOverviewScale = (1 - time) * params.overviewScale.begin +
time * params.overviewScale.end;
// Calculate the screen position of the window.
let screen = (1 - time) *
((begin + params.workspacePos) * params.overviewScale.begin +
params.overviewPos.begin) +
time *
((end + params.workspacePos) * params.overviewScale.end +
params.overviewPos.end);
// Return the workspace coordinates.
return (screen - curOverviewPos) / curOverviewScale - params.workspacePos;
}
function WorkspacesViewSwitch() { function WorkspacesViewSwitch() {
this._init(); this._init();
} }