View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

cocoa vs swing differences

Home   How To   Code Pool   Public Library   Theory   Events
this page lists some inconsistencies or possible bugs in the cocoa and swingosc graphical systems. note that issues may have been fixed but not removed from the below list. also search the mailing lists and see swingosc's helpfiles and bugtracker http://www.sciss.de/swingOSC/

///////// bug in cocoa - addArc adds an extra line (sciss)
GUI.cocoa;
GUI.swing;
(
w = GUI.window.new.front;
w.drawHook = { GUI.pen.moveTo( 10 @ 10 ); GUI.pen.addArc( 130 @ 130,  30, pi/3, 2*pi/3 ); GUI.pen.stroke }; w.refresh;
)


///////// bug in cocoa - addArc adds an extra line (wouter)
GUI.cocoa;
GUI.swing;
(
w = GUI.window.new().front;
w.drawHook = {
	GUI.pen.moveTo( 10@10 );
	GUI.pen.addArc( 200@200, 100, pi, pi );
	GUI.pen.lineTo( 390@390 );
	GUI.pen.stroke;
	};
)


///////// bug in cocoa - line automatically strokes (redfrik)
GUI.cocoa;
GUI.swing;
(
w= GUI.window.new.front;
w.drawHook= {
	GUI.pen.line(10@10, 290@290);
	//GUI.pen.stroke;	//cocoa draws this automatically somehow
	GUI.pen.strokeOval(Rect(10, 20, 30, 40));
};
w.refresh;
)


///////// difference - smoothing off and setting width looks a bit different (redfrik)
update090621: seems ok now with sc3.3.1 and swingosc0.62
/*
GUI.cocoa;
GUI.swing;
(
w= GUI.window.new.front;
w.drawHook= {
	GUI.pen.setSmoothing(false);
	GUI.pen.width_(1);		//swingosc resets smoothing here?
	GUI.pen.strokeRect(Rect(10, 10, 290, 290));	//swingosc still anti-aliased
};
w.refresh;
)

GUI.cocoa;
GUI.swing;
(
w= GUI.window.new.front;
w.drawHook= {
	GUI.pen.width_(1);		//swapping order and it looks ok
	GUI.pen.setSmoothing(false);
	GUI.pen.strokeRect(Rect(10, 10, 290, 290));
};
w.refresh;
)
*/


///////// gotcha - order of views: must be first userview, then slider2d (redfrik)
update090621: works now with sc3.3.1 and swingosc0.62
GUI.swing;
GUI.cocoa;
(
var w= GUI.window.new("", Rect(100, 100, 600, 500));
var v= GUI.compositeView.new(w, Rect(10, 240, 450, 200));
GUI.userView.new(v, v.bounds)
	.drawFunc_{
		var xx= v.bounds.left+10;
		var yy= v.bounds.top+10;
		var ww= v.bounds.width-20;
		var hh= v.bounds.height-50;
		var stepx= ww/(30-1);
		var stepy= hh/(20-1);
		GUI.pen.setSmoothing(false);	//(also 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;
	};
GUI.slider2D.new(v,
		Rect(10, 10,
			v.bounds.width-20, v.bounds.height-50))
	.action_{|sld| [sld.x, sld.y].postln};
w.front;
)

//if order of slider and userview flipped - then not working and looks strange
(
var w= GUI.window.new("", Rect(100, 100, 600, 500));
var v= GUI.compositeView.new(w, Rect(10, 240, 450, 200));
GUI.slider2D.new(v,
		Rect(10, 10,
			v.bounds.width-20, v.bounds.height-50))
	.action_{|sld| [sld.x, sld.y].postln};
GUI.userView.new(v, v.bounds)
	.drawFunc_{
		var xx= v.bounds.left+10;
		var yy= v.bounds.top+10;
		var ww= v.bounds.width-20;
		var hh= v.bounds.height-50;
		var stepx= ww/(30-1);
		var stepy= hh/(20-1);
		GUI.pen.setSmoothing(false);	//(also 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;
	};
w.front;
)


///////// buttons and windows (andrea valle)
GUI.swing ;
(
		w = GUI.window.new.front;
		w.view.background_(Color.white);
		w.drawHook = {
			GUI.pen.translate(100, 100);
			10.do{
				// set the Color
				GUI.pen.color = Color.red(rrand(0.0, 1), rrand(0.0, 0.5));
				GUI.pen.addArc((100.rand)@(100.rand), rrand(10, 100), 2pi.rand, pi);
				GUI.pen.perform([\stroke, \fill].choose);
			}
		};
		w.refresh;

GUI.button.new(w, w.view.bounds)
)

// clickin on the button
// nothing happens (ok)
// then with:


GUI.cocoa

// clicking differs (interestingly...)
// what am I missing?



Link to this Page