File: Resize.schelp

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (90 lines) | stat: -rw-r--r-- 2,145 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
title:: Resize behaviour
summary:: Resize behavior for View and its subclasses
categories:: GUI

section:: Description
method:: resize
The link::Classes/View#-resize:: method takes nine different values as argument defining the behavior of the view when the containing window is resized. Each view responds relatively to the stretches of its parent view.

table::
## 1 || 2 || 3
## 4 || 5 || 6
## 7 || 8 || 9
::

list::
## 1 - fixed to left, fixed to top
## 2 - horizontally elastic, fixed to top
## 3 - fixed to right, fixed to top

## 4 - fixed to left, vertically elastic
## 5 - horizontally elastic, vertically elastic
## 6 - fixed to right, vertically elastic

## 7 - fixed to left, fixed to bottom
## 8 - horizontally elastic, fixed to bottom
## 9 - fixed to right, fixed to bottom
::

section:: Examples

code::
// resize behaviours
// use the PopUpMenus to mix resize modes
(
var a;

a = { |i|
	var w, b, x,k,t,p;
	k=i;
	i = i + 1;
	w = Window("resize:"+i, Rect(10 + (k%3 * 220), Window.screenBounds.height- [250,460,670].at(k/3), 200, 180));
	b = w.view.bounds;
	x = CompositeView(w, w.view.bounds.insetBy(20,20))
		.background_(Color.rand)
		.resize_(i);

	y = CompositeView(x, x.bounds.moveTo(0,0).insetBy(20,20))
		.background_(Color.rand)
		.resize_(i);

	y.decorator = FlowLayout(y.bounds).gap_(0.0 @ 0.0);

	t = StaticText(y, Rect(0, 0, 40, 40))
		.background_(Color.rand.alpha_(0.8))
		.resize_(i)
		.string_(i)
		.font_(Font("Helvetica", 26));

	p=PopUpMenu(y,40@40).items_((1..9).collect(_.asString)).value_(i-1).resize_(i)
			.action_{|m| t.string_((m.value+1).asString); [p,t].do(_.resize_(m.value+1))};

	w.front;
	w.onClose = {a.do(_.close) };

} ! 9;
)


// the popupmenu contains the various modes

(
w = Window("soundfile test", Rect(200, 200, 720, 250));

p = PopUpMenu(w, Rect(10,10,80,24))
	.items_( Array.fill(9, {arg i; (i+1).asString;}) )
	.action_({ arg sbs;
		a.resize_(sbs.value+1);
	});

f = SoundFile.new;
f.openRead(Platform.resourceDir +/+ "sounds/a11wlk01.wav");

a = SoundFileView(w, Rect(10,40, 700, 180))
	.soundfile_(f)
	.readWithTask(0, f.numFrames, showProgress: false )
	.resize_(1);

w.front;
)
::