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

Re: [Sc-devel] Transparent backgrounds in Views



i did option:
a) reverse the drawing order of gadgets in cocoa GUI without reversing the mouse priorities

which means that the view which is is front and is drawn last, receives the user events. but i guess in order to have Fredrik example behaving the same on both GUI kits sciss would need to change the swing osc behaviour, right?
shall i commit my changes, so you can try?
j

On Dec 3, 2007, at 7:48 PM, Fredrik Olofsson wrote:

here's another example that demonstrates this order-of-creation problem. sciss helped me out with this earlier in a private mail.
_f


//works under cocoa: first userview, then slider2d
GUI.cocoa;
//then test this with GUI.swing to see the issue
(
var guiWin= GUI.window.new("for cocoa", Rect(100, 100, 600, 500));
var vTable= GUI.compositeView.new(guiWin, Rect(10, 240, 450, 200));
GUI.userView.new(vTable, vTable.bounds-Rect(0, 0, 0, 40))
	.drawFunc_{
		var xx= vTable.bounds.left+10;
		var yy= vTable.bounds.top+10;
		var ww= vTable.bounds.width-20;
		var hh= vTable.bounds.height-50;
		var stepx= ww/(30-1);
		var stepy= hh/(20-1);
		GUI.pen.setSmoothing(false);
		30.do{|x|
			GUI.pen.line(x*stepx+xx@yy, x*stepx+xx@(yy+hh));
			20.do{|y|
				GUI.pen.line(xx@(y*stepy+yy), xx+ww@(y*stepy+yy));
			};
		};
		GUI.pen.stroke;
	};
GUI.slider2D.new(vTable,
		Rect(vTable.bounds.left+10, vTable.bounds.top+10,
			vTable.bounds.width-20, vTable.bounds.height-50))
	.action_{|sld| [sld.x, sld.y].postln};
guiWin.front;
)



//for swingosc: first create slider2d, then userview
GUI.swing;
//then test this with GUI.cocoa to see the issue
(
var guiWin= GUI.window.new("for swing", Rect(100, 100, 600, 500));
var vTable= GUI.compositeView.new(guiWin, Rect(10, 240, 450, 200));
GUI.slider2D.new(vTable,
		Rect(vTable.bounds.left+10, vTable.bounds.top+10,
			vTable.bounds.width-20, vTable.bounds.height-50))
	.action_{|sld| [sld.x, sld.y].postln};
GUI.userView.new(vTable, vTable.bounds-Rect(0, 0, 0, 40))
	.drawFunc_{
		var xx= vTable.bounds.left+10;
		var yy= vTable.bounds.top+10;
		var ww= vTable.bounds.width-20;
		var hh= vTable.bounds.height-50;
		var stepx= ww/(30-1);
		var stepy= hh/(20-1);
		GUI.pen.setSmoothing(false);	//not working for swingosc
		30.do{|x|
			GUI.pen.line(x*stepx+xx@yy, x*stepx+xx@(yy+hh));
			20.do{|y|
				GUI.pen.line(xx@(y*stepy+yy), xx+ww@(y*stepy+yy));
			};
		};
		GUI.pen.stroke;
	};
guiWin.front;
)



Am 03.12.2007 um 18:26 schrieb Jan Trutzschler:

well, looking at the code, we would need to introduce another for- loop, but then it would work as expected.


On Dec 2, 2007, at 3:20 PM, Sciss wrote:

thanks. i have no insight into the code, but maybe it's just that the drawing for-loop needs to run in reverse direction!

Am 02.12.2007 um 07:26 schrieb Jan Trutzschler:

yes you're right, i would need to look into that. Not sure at the moment how to change the mouse focus in sc.


On Dec 1, 2007, at 9:42 PM, Sciss wrote:

on a related issue, jan, i wanted to ask you if you think it's possible to change the z-order of gadgets in cocoa GUI. the problem is things like the example from thor:

GUI.cocoa;
GUI.swing;
(
var size;
size = 12;
a = GUI.window.new("test", Rect(200 , 450, 10 + (size * 17), 10 + (size * 17))).front;


b = GUI.slider2D.new(a, Rect(0, 0, size * 17, size * 17))
	.knobColor_(Color.blue)
	.x_(0.8)
	.background_(Color.green.alpha_(0.0))
//	.fillColor_(Color.blue);
	;

c = GUI.slider2D.new(a, Rect(0, 0, size * 17, size * 17))
	.knobColor_(Color.red)
	.x_(0.4)
	.background_(Color.green.alpha_(0.0))
)

they are identical in cocoa and swing, but in cocoa the red slider receives mouse actions, in swing the blue one; that is, i adopted the z-ordering of cocoa by putting earlier created views in front of those created later, but i have no influence on the mouse tracking (java is doing that for me), so gadgets painted in front of others have priority regarding mouse tracking. i think that behaviour is logical. so my question is if it would be possible to

a) reverse the drawing order of gadgets in cocoa GUI without reversing the mouse priorities b) alternatively, reversing the mouse priorities without reversing the drawing order

if this is solved, people could safely use layered gadgets with both GUI kits... i think variant a) is better because it kind of sounds logical that views created later appear on top of old ones.

as i said, in SwingGUI i cannot decouple the painting and mouse focus order, so if that's possible in the cocoa GUI, it would be quite useful IMO...

ciao, -sciss-


  #|
     fredrikolofsson.com     klippav.org     musicalfieldsforever.com
  |#

_______________________________________________
Sc-devel mailing list
Sc-devel@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-devel