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

[sc-users] Stretching a View & Everything It Contains



Hello All,

I have a window with a bunch of views contained within it, and these views
themselves contain other views too. I'd like to have this window be of any
size and for everything that's contained within it to automatically stay
proportionate to the window size and in relation to everything else. 

There's View::resizeTo, which does this to a single view, but doesn't affect
a View's children. Ideally, I'd like to just stretch the parent view and
have the children view's adapt accordingly, if possible?

Instead, I'm drawing all the views relative to the Window's bounds and have
a ~scaleW parameter, which scales every View I'm drawing's width and
position, but my attempt at this method does not seem to work as I'd like
either. 

I wonder if someone could help?
Many thanks,
Adam

Just try the following code with the Window's width at 1000 and ~scaleW at
1, and then with Window's width at 500 and ~scaleW at 0.5, and you should
see the problem: 


(
//w.close;
~newMiddleLayer = {
	var newLayer = View(~middleLayout, Rect(0, 0, 1000, 80/4));
	newLayer.decorator = FlowLayout( newLayer.bounds, 0@0, ~scaleW*1.22@0 );
	72.do{|i|
		if (i == 71, {DragBoth( newLayer, ~w1*~scaleW@(80/4) ).background_(
Color.white )}, {
		switch (i%12)
		{0}	{DragBoth( newLayer, ~w1*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );}
		{1}	{DragBoth( newLayer, ~w2*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );}
		{2}	{DragBoth( newLayer, ~w3*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );}
		{3}	{DragBoth( newLayer, ~w2*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );}
		{4}	{DragBoth( newLayer, ~w1*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );}
		{5}	{DragBoth( newLayer, ~w1*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );}
		{6}	{DragBoth( newLayer, ~w2*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );}
		{7}	{DragBoth( newLayer, ~w3*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );}
		{8}	{DragBoth( newLayer, ~w2*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );}
		{9}	{DragBoth( newLayer, ~w3*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );}
		{10}{DragBoth( newLayer, ~w2*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );}
		{11}{DragBoth( newLayer, ~w1*~scaleW@(80/4) ).object_("").background_(
~dropbothColor );};
	});
	};
	newLayer
};

w = Window("",1000@200);
w.front;

~numOfMiddleLayers = 10;
~middleLayers = [];

~scaleW = 1;

~w1=17;
~w2=10;
~w3=11;

~middleScrollView = ScrollView(w.view, Rect(0, 0, 1000, 200));
~middleScrollView.hasHorizontalScroller = false;

~middleLayout = VLayoutView(~middleScrollView, Rect(-1, 0, 1000-1, 180));
~middleLayout.acceptsMouseOver = true;

~numOfMiddleLayers.do({|layerIndex|

	var thisLayer = ~newMiddleLayer.value();
	~middleLayers = ~middleLayers.add(thisLayer);
});

)






--
Sent from: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/SuperCollider-Users-New-Use-this-f2676391.html

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/