This file is indexed.

/usr/share/SuperCollider/HelpSource/Classes/CompositeView.schelp is in supercollider-common 1:3.8.0~repack-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
class:: CompositeView
summary:: A view that contains other views.
categories:: GUI>Views
related:: Classes/FlowView, Classes/FlowLayout

description::

note::
In Qt GUI, every view can be a parent to other views, so CompositeView redirects to the same class as link::Classes/View:: - you can use the latter equivalently.
::

CompositeView can be used as the parent of other views, while also being a child of a Window or another CompositeView itself. Aside from that it has not special methods of its own.

note::
In Cocoa GUI, this view accepts key actions, but not mouse clicks or drags.
::


classmethods::
private:: key


examples::

subsection:: Coordinate System

Containers use relative coordinates, i.e.  views are placed relative to the upper left corner of the container.
code::
(
w = Window.new;

c = CompositeView(w, Rect(50, 0, 300, 300));
a = Slider2D(c, Rect(0, 0, 100, 100)); // actually displays at (50, 0)
b = Slider2D(c, Rect(100, 100, 100, 100));

c.background = Color.rand;

w.front;
)

c.bounds_(Rect(100, 0, 300, 300)); // contents adjust since coords are relative
c.resize_(6); // contents adjust since coords are relative
::

subsection:: Keydown Bubbling

Key actions "bubble up" to the parent view if a view does not define one itself. In the following example, a and b do not have keyDown actions themselves, so the key event is passed to c, the parent, which defines the key down action. d's parent is the SCTopView, which has no key down action. See also link::Classes/View::.
code::
( //Click on the different views and hit keys on the keyboard.

w = Window.new;

c = CompositeView(w, Rect(0, 0, 200, 200)).background_(Color.grey.alpha_(0.3));

a = Slider2D(c,Rect(0, 0, 100, 100)).background_(Color.rand);
b = Slider2D(c,Rect(100, 100, 100, 100)).background_(Color.rand);

w.front;

c.keyDownAction = {
	"keydown bubbled up to c".postln;
};

// d is on window w, not on composite view c
d = Slider2D(w,Rect(200, 200, 100, 100));
d.background = Color.black;
)
::

subsection:: Decorators

A 'decorator' object can be set to handle layout management. All views added to the CompositeView will now be placed by the decorator. Currently the only one existing is link::Classes/FlowLayout::. You can use the ContainerView's addFlowLayout method as a short cut to assigning FlowLayout to decorator.
code::
(
a = Window.new;

b = CompositeView(a,Rect(0, 0, 500, 500));
b.decorator = FlowLayout(b.bounds);
//b.addFlowLayout; // you can also write this for convenience

// adding views to b automatically use the decorator
// no need to use parent.decorator.place
c = Slider2D(b,Rect(0, 0, 100, 100)); // size matters
d = Slider2D(b,Rect(0, 0, 100, 100)); // origin doesn't

a.front;
)
::

You can also use an empty composite view nicely as a spacer in link::Classes/VLayoutView::, link::Classes/HLayoutView::, or views that have a link::Classes/FlowLayout:: as their decorator.
code::
(
a = Window.new;
b = CompositeView(a, Rect(0, 0, 500, 500));

b.decorator = FlowLayout(Rect(0, 0, 500, 500));

Slider2D(b,Rect(0, 0, 100, 100)).background_(Color.rand);
CompositeView(b, Rect(0, 0, 70, 100)); // just used for spacing
Slider2D(b,Rect(0, 0, 100, 100)).background_(Color.rand);
Slider2D(b,Rect(0, 0, 100, 100)).background_(Color.rand);

b.decorator.nextLine;

Slider2D(b, Rect(0, 0, 100, 100)).background_(Color.rand);
Slider2D(b, Rect(0, 0, 100, 100)).background_(Color.rand);
CompositeView(b, Rect(0, 0, 70, 100)); // just used for spacing
Slider2D(b,Rect(0,0,100,100)).background_(Color.rand);

a.front;
)
::

subsection:: Hiding / Swapping

You can stack CompositeViews on top of each other and use a button show only one of them:
code::
(
var colors = [Color.blue, Color.red, Color.green];
a = Window.new;
q = 3;

b = Button(a, Rect(0, 0, 160, 20));

b.states = Array.fill(q, { arg i;
	[i.asString, Color.white, colors.wrapAt(i)]
});

b.action = { arg butt;
	p.visible = false;
	p = c.at(butt.value);
	p.visible = true;
};

c = Array.fill(q, { arg i;
	b = CompositeView(a, Rect(0, 25, 300, 300));
	b.background = colors[i].alpha_(0.2);
	b.visible = false;
	b;
});

5.do{ arg i; Slider(c[0], Rect(10, i * 30 + 10, 150, 25)).value_(1.0.rand) };
5.do{ arg i; Slider(c[1], Rect(i * 30 + 10, 10, 25, 150)).value_(1.0.rand) };
Slider2D(c[2], Rect(10, 10, 155, 150)).x_(1.0.rand).y_(1.0.rand);

p = c.at(0); // previous
p.visible = true; // show first one

a.front;
)
::

subsection:: Nested Example

In this example, the link::Classes/StaticText:: accepts mouse clicks, since container views can't:
code::
(
w = Window.new.front;
v = CompositeView.new(w, w.view.bounds.insetBy(10)).background_(Color.rand);
v.decorator = FlowLayout(v.bounds);

l = "SUPERCOLLIDER".scramble;
t = Array.fill(9, {arg i; var n, r, q;
	n = CompositeView.new(v, Rect(20, 20, 121, 121)).background_(Color.rand);
	q = StaticText(n, n.bounds.moveTo(0,0).insetBy(25)).string_(l[i]).align_(\center);
	q.enabled = true;
	q.font = Font("Geneva", 10);
	q.background_(Color.rand);
	q.mouseDownAction = {
		n.background_(Color.rand);
		q.font=q.font.size_(5 + q.font.size + 7 % 60)
	};
});
)
::