Rename getSelected methods to isSelected.

This commit is contained in:
Jonathan Puckey 2011-04-21 19:51:49 +02:00
parent d831d66758
commit cf541901dd
4 changed files with 16 additions and 16 deletions

View file

@ -77,10 +77,10 @@ var Item = this.Item = Base.extend({
}
},
getSelected: function() {
isSelected: function() {
if (this.children) {
for (var i = 0, l = this.children.length; i < l; i++) {
if (this.children[i].getSelected())
if (this.children[i].isSelected())
return true;
}
} else {
@ -279,7 +279,7 @@ var Item = this.Item = Base.extend({
* Removes the item.
*/
remove: function() {
if(this.getSelected())
if(this.isSelected())
this.setSelected(false);
return this.removeFromParent();
},

View file

@ -129,12 +129,12 @@ var Path = this.Path = PathItem.extend({
}
},
getSelected: function() {
isSelected: function() {
return this._selectedSegmentCount > 0;
},
setSelected: function(selected) {
var wasSelected = this.getSelected();
var wasSelected = this.isSelected();
var length = this._segments.length;
if (!wasSelected != !selected && length) {
var selectedItems = this._document._selectedItems;
@ -291,16 +291,16 @@ var Path = this.Path = PathItem.extend({
pointSelected = segment._selectionState == SelectionState.POINT;
// TODO: draw handles depending on selection state of
// segment.point and neighbouring segments.
if (pointSelected || segment.getSelected(segment._handleIn))
if (pointSelected || segment.isSelected(segment._handleIn))
drawHandle(ctx, point, segment._handleIn);
if (pointSelected || segment.getSelected(segment._handleOut))
if (pointSelected || segment.isSelected(segment._handleOut))
drawHandle(ctx, point, segment._handleOut);
// Draw a rectangle at segment.point:
ctx.save();
ctx.beginPath();
ctx.rect(point._x - 2, point._y - 2, 4, 4);
ctx.fill();
// TODO: Only draw white rectangle if point.getSelected()
// TODO: Only draw white rectangle if point.isSelected()
// is false:
if (!pointSelected) {
ctx.beginPath();

View file

@ -125,7 +125,7 @@ var Segment = this.Segment = Base.extend({
return this._path && this._path._segments[this.getIndex() - 1] || null;
},
getSelected: function(/* point */) {
isSelected: function(/* point */) {
var point = arguments.length ? arguments[0] : this.point;
var state = this._selectionState;
if (point == this.point) {
@ -180,11 +180,11 @@ var Segment = this.Segment = Base.extend({
// instead depending on the selection state of their
// neighbors.
handleInSelected = previous != null
&& (previous._point.getSelected()
|| previous._handleOut.getSelected());
&& (previous._point.isSelected()
|| previous._handleOut.isSelected());
handleOutSelected = next != null
&& (next._point.getSelected()
|| next._handleOut.getSelected());
&& (next._point.isSelected()
|| next._handleOut.isSelected());
}
pointSelected = selected;
}
@ -244,7 +244,7 @@ var Segment = this.Segment = Base.extend({
remove: function() {
if (this._path) {
this._path._segments.splice(this.getIndex(), 1);
if (this.getSelected())
if (this.isSelected())
this._path._selectedSegmentCount--;
return true;
}

View file

@ -34,8 +34,8 @@ var SegmentPoint = Point.extend({
this._segment.setSelected(this, selected);
},
getSelected: function() {
return this._segment.getSelected(this);
isSelected: function() {
return this._segment.isSelected(this);
},
statics: {