GUIs - Managing Windows within Windows

Hi -
I’d like to squeeze a dozen or so windows within a main Window. I would like something like a “tab” situation, similar to a web browser - but I am unclear how to do this (or if it can be done) with the SC GUI.
Thank you.

Hi,

The TabbedView Quark will do this. Right now there is TabbedView, TabbedView2 and TabbedView2_QT quarks. Read the helpfile for TabbedView2 to see the differences between the versions.

1 Like

I was wondering the same thing a while back and ended up using a slightly different solution - hiding and showing views, which is somewhat similar to the feeling of having tabs:

/// HIT ONE THE TWO TOP BUTTONS TO CHANGE VIEW

(
// buttons to choose which view is visible
b = 2.collect{|i| Button().action_{ |but|
	{ 
		c.visible_(1 - i); 
		d.visible_(i);
		b[i].states_([[\, \, Color.green]]);
		b[1 - i].states_([[\, \, Color.white]])
	}.defer 	
}};

// dummy view A
c = View().layout_(VLayout(
	HLayout(StaticText().string_("VIEW A").font_(\Arial, 20)),
	HLayout(*5.collect{ Button() }),
	HLayout(*[PopUpMenu(), 3.collect{ Button() }].flat),
	nil
)).fixedWidth_(300);

// dummy view B
d = View().layout_(VLayout(
	HLayout(StaticText().string_("VIEW B").font_(\Arial, 20)),
	HLayout(
		VLayout(*[2.collect{PopUpMenu()}, nil].flat),
		HLayout(*3.collect{ Slider() }),
	)
)).fixedWidth_(300).visible_(false);

// Layout of view buttons
e = View().layout_(HLayout(*[b, nil].flat))
.fixedHeight_(50);

v = View().layout_(VLayout(e, HLayout(c, d), nil)).fixedSize_(320, 250).front;
b[0].valueAction_(0)
)
1 Like

StackLayout relieves you of having to show/hide views by hand – just set its index and, done:

(
var stack;

w = Window("StackLayout", Rect.aboutPoint(Window.screenBounds.center, 300, 200)).front;

w.layout = VLayout(
	HLayout(*Array.fill(3, { |i|
		Button().states_([[(i+1).asString]])
		.action_({ stack.index = i })
	})),
	
	stack = StackLayout(
		View().layout_(
			HLayout(*Array.fill(5, { Slider().orientation_(\vertical) }))
		),
		View().layout_(
			VLayout(*Array.fill(5, { Slider().orientation_(\horizontal) }))
		),
		View().layout_(
			GridLayout.rows(
				*Array.fill(25, {
					Button().states_([["", Color.black, Color.rand]])
				}).clump(5)
			)
		)
	)
);
)

hjh

2 Likes