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

Re: [sc-users] drawing outside a UserView broken?




On 19 Jun 2009, at 11:24, Wouter Snoei wrote:

Hi Scott,

As it is you could add a function to draw hook like so: myWindow.drawHook = myWindow.drawHook.addFunc(mycustomFocusRingFunc);

that could be an interesting way to do it. Didn't know that.

This would not overwrite existing instructions, but a better approach might be a general hook for custom focus rings for any view.
That would have to be in the main distro right?

Yes. I think this would be a nice feature for 3.4.

S.



I just tested another method; automatic enlargement by 4px to each side of the userview. It seems to work, except from within HLayoutView and VLayoutView, since they seem to call primitives and don't allow overlapping views. My method is the following:

-- from RoundButton.sc (subclass of SCUserView)

init { |parent, bounds|
		relativeOrigin = true;
super.init( parent, bounds.asRect.insetBy(-4,-4) ); // init 4px larger
		super.focusColor = Color.clear;
		}
		
drawBounds { ^this.bounds.moveTo(4,4); } // used for the drawing

bounds { ^super.bounds.insetBy(4,4); } // fake the views actual bounds
bounds_ { |newBounds| super.bounds = newBounds.asRect.insetBy(-4,-4); }

--

Do you see any problems with this approach? And would there be a way to avoid problems with the HLayoutView / VLayoutView ?


cheers,
Wouter



On 19 Jun 2009, at 10:42, Wouter Snoei wrote:

Hi guys,

hmm.. is see. Well, could there maybe at least be the option of making the constrained layer expand 2 px outside the views bounds? I mean is it that weird to want to draw a little bit outside a userview? I can imagine one also wants to be able to put up a shadow or something like that around it?

Using the drawhook is no option here; that would mean every SmoothSlider and RoundButton would need to have an entry in it, which would require a system similar to the OSCresponders and block out any direct use of drawHook. Not desirable.

cheers,
Wouter

Op 19 jun 2009, om 11:23 heeft Scott Wilson het volgende geschreven:

I agree that drawing outside a view's bounds seems really dodgy. The fact that it worked be for is if not a bug, at least is not a feature!

Why don't you use SCWindow:drawHook_ to draw the focus ring?

S.

On 19 Jun 2009, at 10:16, thelych@xxxxxxxxx wrote:

hi wouter,

with relativeOrigin = true the UserView draws in a separate, and constrained layer whose bounds are equal to the view bounds.
you cannot draw outside of it. It's like it clips the region.

there is no workaround.

I do not consider it as a bug. Actually i think drawing inside a view should be constrained to its bounds.

since relativeOrigin will be / is deprecated, a *possible workaround* would be to add a flag to disable this layer and allow to draw outside of the view but this possibility will be a kind of *hack* : meaning there is few cases where those extended drawings won't be refreshed correctly, probably leaving the window with dirty drawings inside.

that should be probably discussed in the dev-list before.

until then you have to use relativeOrigin = false to draw your custom focus ring... wich i know may not stand in future releases.

best,
charles

Le 19 juin 09 à 10:40, Wouter Snoei a écrit :

Hi,

I'm trying to update my lib to reflect the deprication of relativeOrigin, but stumbled across a problem: as soon as I set relativeOrigin to false on a UserView, it doesn't draw outside its borders anymore. This is problematic since I draw my own focus rings around all my gui widgets. Even when I do a refreshInRect with the correct bounds it still doesn't draw. Is this a bug or a feature? And in any case; how to work around it?

(
w = Window().front;
w.addFlowLayout;

a = UserView( w, 100@100 ).relativeOrigin_(false)
	.focusColor_( Color.clear )
	.drawFunc_({ |vw|
		var bounds = vw.bounds;
		Pen.addRect( bounds.insetBy(-1,-1) );
		Pen.line( bounds.leftTop, bounds.rightBottom );
		Pen.line( bounds.rightTop, bounds.leftBottom );
		Pen.stroke
		});
	
b = UserView( w, 100@100 ).relativeOrigin_(true)
	.focusColor_( Color.clear )
	.drawFunc_({ |vw|
		var bounds = vw.bounds.moveTo(0,0);
		Pen.addRect( bounds.insetBy(-1,-1) ); // doesn't show!!
		Pen.line( bounds.leftTop, bounds.rightBottom );
		Pen.line( bounds.rightTop, bounds.leftBottom );
		Pen.stroke
		});
)

cheers,
Wouter

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/