58 | 58 |
var StoredCoordinates = {
|
59 | 59 |
PRESERVE: 0,
|
60 | 60 |
OVERWRITE:1,
|
|
61 |
ASSIGN:2,
|
61 | 62 |
};
|
62 | 63 |
|
63 | 64 |
class Placeholder extends St.Bin {
|
|
371 | 372 |
this.actor._desktopBackgroundManager.ignoreRelease();
|
372 | 373 |
}
|
373 | 374 |
|
374 | |
_addFileItemTo(fileItem, column, row, overwriteCoordinates) {
|
|
375 |
_addFileItemTo(fileItem, column, row, coordinatesAction) {
|
375 | 376 |
let placeholder = this.layout.get_child_at(column, row);
|
376 | 377 |
placeholder.child = fileItem.actor;
|
377 | 378 |
this._fileItems.push(fileItem);
|
|
385 | 386 |
* Also store the new possition if it has been moved by the user,
|
386 | 387 |
* and not triggered by a screen change.
|
387 | 388 |
*/
|
388 | |
if ((fileItem.savedCoordinates == null) || (overwriteCoordinates == StoredCoordinates.OVERWRITE)) {
|
|
389 |
if ((fileItem.savedCoordinates == null) || (coordinatesAction == StoredCoordinates.OVERWRITE)) {
|
389 | 390 |
let [fileX, fileY] = placeholder.get_transformed_position();
|
390 | 391 |
fileItem.savedCoordinates = [Math.round(fileX), Math.round(fileY)];
|
391 | 392 |
}
|
392 | 393 |
}
|
393 | 394 |
|
394 | |
addFileItemCloseTo(fileItem, x, y, overwriteCoordinates) {
|
395 | |
let [column, row] = this._getEmptyPlaceClosestTo(x, y);
|
396 | |
this._addFileItemTo(fileItem, column, row, overwriteCoordinates);
|
397 | |
}
|
398 | |
|
399 | |
_getEmptyPlaceClosestTo(x, y) {
|
|
395 |
addFileItemCloseTo(fileItem, x, y, coordinatesAction) {
|
|
396 |
let [column, row] = this._getEmptyPlaceClosestTo(x, y, coordinatesAction);
|
|
397 |
this._addFileItemTo(fileItem, column, row, coordinatesAction);
|
|
398 |
}
|
|
399 |
|
|
400 |
_getEmptyPlaceClosestTo(x, y, coordinatesAction) {
|
400 | 401 |
let maxColumns = this._getMaxColumns();
|
401 | 402 |
let maxRows = this._getMaxRows();
|
402 | 403 |
|
|
421 | 422 |
continue;
|
422 | 423 |
|
423 | 424 |
let [proposedX, proposedY] = placeholder.get_transformed_position();
|
|
425 |
if (coordinatesAction == StoredCoordinates.ASSIGN)
|
|
426 |
return [column, row];
|
424 | 427 |
let distance = DesktopIconsUtil.distanceBetweenPoints(proposedX, proposedY, x, y);
|
425 | 428 |
if (distance < minDistance) {
|
426 | 429 |
found = true;
|