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

View file

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

View file

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

View file

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