Some minor improvements in handling of selectedItems.

This commit is contained in:
Jürg Lehni 2016-01-14 19:19:39 +01:00
parent d9c9b3d1a2
commit cd366982d6

View file

@ -225,18 +225,23 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
* @type Item[] * @type Item[]
*/ */
getSelectedItems: function() { getSelectedItems: function() {
// TODO: Return groups if their children are all selected, // TODO: Return groups if their children are all selected, and filter
// and filter out their children from the list. // out their children from the list.
// TODO: The order of these items should be that of their // TODO: The order of these items should be that of their drawing order.
// drawing order. var selectedItems = this._selectedItems,
var items = []; items = [];
for (var id in this._selectedItems) { for (var id in selectedItems) {
var item = this._selectedItems[id]; var item = selectedItems[id];
if (item.isInserted()) if (item.isInserted()) {
items.push(item); items.push(item);
} else {
this._selectedItemCount--;
delete selectedItems[id];
}
} }
return items; return items;
}, },
// TODO: Implement setSelectedItems?
// Project#insertChild() and #addChild() are helper functions called in // Project#insertChild() and #addChild() are helper functions called in
// Item#copyTo(), Layer#initialize(), Layer#_insertSibling() // Item#copyTo(), Layer#initialize(), Layer#_insertSibling()
@ -271,7 +276,6 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
return this.insertChild(undefined, item, _preserve); return this.insertChild(undefined, item, _preserve);
}, },
// TODO: Implement setSelectedItems?
_updateSelection: function(item) { _updateSelection: function(item) {
var id = item._id, var id = item._id,
selectedItems = this._selectedItems; selectedItems = this._selectedItems;