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

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

Hi James,
my commit for relative CompositeView was a bit too quick. And a few problems arose from it. Your fix also doesn't really do what we want, because when we ask for the bounds of the view later , we would again get the absolute bounds ;-(
So i completely re-worked it in the c code.
I'm still testing it ... perhaps i could send you a copy to try it yourself?

On Dec 14, 2007, at 2:24 PM, James Harkins wrote:

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

Sc-devel mailing list