Change the way associated PathStyles are created and updated.

This commit is contained in:
Jürg Lehni 2011-05-16 19:21:36 +01:00
parent 05c0eb0e51
commit c4203fe174
3 changed files with 5 additions and 8 deletions

View file

@ -19,6 +19,7 @@ var Item = this.Item = Base.extend({
initialize: function() {
paper.project.activeLayer.appendTop(this);
this._style = PathStyle.create(this);
this.setStyle(this._project.getCurrentStyle());
},
@ -629,7 +630,7 @@ var Item = this.Item = Base.extend({
},
setStyle: function(style) {
this._style = PathStyle.create(this, style);
this._style.initialize(style);
},
// TODO: toString

View file

@ -44,13 +44,9 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
},
statics: {
create: function(item, other) {
create: function(item) {
var style = new PathStyle(PathStyle.dont);
// We need _item to be set before calling initialize(), since
// it is setting bean properties that propagate changes through
// all of item's children.
style._item = item;
style.initialize(other);
return style;
}
}

View file

@ -33,7 +33,7 @@ var Project = this.Project = Base.extend({
this.activeView = canvas ? new ProjectView(canvas) : null;
this._selectedItems = {};
this._selectedItemCount = 0;
this.setCurrentStyle(null);
this._currentStyle = PathStyle.create(null);
},
getCurrentStyle: function() {
@ -41,7 +41,7 @@ var Project = this.Project = Base.extend({
},
setCurrentStyle: function(style) {
this._currentStyle = PathStyle.create(null, style);
this._currentStyle.initialize(style);
},
activate: function() {