[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Sc-devel] BUG: bounds_ always uses absolute origin

Hey Jan,

While debugging the flow view problem with relative origin parents, I found this little gem:

// this works
w = GUI.window.new("test", Rect(20, 20, 300, 300)).front;
c = GUI.compositeView.new(w, Rect(100, 100, 100, 100))
t = GUI.staticText.new(c, Rect(0, 0, 90, 20)).string_("hello");

// this don't
t.bounds = Rect(4, 4, 90.0, 20.0);

The trouble is, this is exactly how decorators work -- the new view gets placed initially using the original bounds, then the decorator's place method is called which sets the new view's bounds to the calculated position.

I can fix it in SCView like this, but maybe for performance this logic should be moved into the backend?

+ SCView {
bounds_ { arg rect;
var parentView, parentBounds;
if((parentView = this.parent.asView).relativeOrigin) {
parentBounds = parentView.bounds;
this.setProperty(\bounds, rect.moveBy(parentBounds.left, parentBounds.top));
} {
this.setProperty(\bounds, rect)

Let me know if this change is okay to commit, or if you would rather do do it in the primitive.

: H. James Harkins

: jamshark70@xxxxxxxxxxxxxxxxx

: http://www.dewdrop-world.net


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman