Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / SCClassLibrary / Common / GUI / osx / scide_scapp / viewExtensionsOSX.sc
blob230d4cdbe1ecd24995ba69ec30a7a5cb9ef19be9
3 + SCWindow {
5         flow { arg func,bounds;
6                 var f;
7                 f = FlowView(this,bounds ?? { this.bounds });
8                 func.value(f);
9                 f.resizeToFit;
10                 ^f
11         }
12         comp { arg func,bounds;
13                 var f;
14                 f = GUI.compositeView.new(this,bounds ?? { this.bounds });
15                 func.value(f);
16                 ^f
17         }
20 + SCView {
21         
22         children { ^nil }
23         deepDo { arg function;
24                 // includes self
25                 function.value(this);
26                 this.children.do({arg child;
27                         child.deepDo(function);
28                 });
29         }
30         allChildren {
31                 // includes self
32                 var all;
33                 all = Array.new;
34                 this.deepDo({ arg child; all = all.add(child) });
35                 ^all
36         }
39 + SCViewHolder {
41         children { ^[view] }
42         deepDo { arg function;
43                 // includes self
44                 function.value(this);
45                 this.children.do({arg child;
46                         child.deepDo(function);
47                 });
48         }
49         allChildren {
50                 // includes self
51                 var all;
52                 all = Array.new;
53                 this.deepDo({ arg child; all = all.add(child) });
54                 ^all
55         }
58 + SCContainerView {
60         flow { arg func,bounds;
61                 var f,comp;
62                 f = FlowView(this,bounds); // flow view intellegently calc defaults bounds
63                 func.value(f);
64                 if(bounds.isNil,{ f.resizeToFit });
65                 ^f
66         }
67         horz { arg func,bounds;
68                 var comp;
69                 comp = GUI.hLayoutView.new(this,bounds ?? { this.bounds });
70                 comp.tryPerform('spacing_',GUI.skin.gap.x);
71                 func.value(comp);
72                 ^comp
73         }
74         vert { arg func,bounds;
75                 var comp;
76                 comp = GUI.vLayoutView.new(this,bounds ?? { this.bounds });
77                 comp.tryPerform('spacing_',GUI.skin.gap.y);
78                 func.value(comp);
79                 ^comp
80         }
81         comp { arg func,bounds;
82                 var comp;
83                 comp = GUI.compositeView.new(this,bounds ?? { this.bounds });
84                 func.value(comp);
85                 ^comp
86         }
87         scroll { arg func,bounds,autohidesScrollers=true,autoScrolls=true,
88                                         hasHorizontalScroller=true,hasVerticalScroller=true;
89                 var comp;
90                 comp = GUI.scrollView.new(this,bounds ?? { this.bounds });
91                 comp.autohidesScrollers = autohidesScrollers;
92                 comp.autoScrolls = autoScrolls;
93                 comp.hasHorizontalScroller = hasHorizontalScroller;
94                 comp.hasVerticalScroller = hasVerticalScroller;
95                 func.value(comp);
96                 ^comp
97         }
100 + SCLayoutView {
102         // because a scroll view inside an h or v layout will crash the lang
103         // layer in a composite view to protect it until we fix that bug.
104         scroll { arg func,bounds,autohidesScrollers=true,autoScrolls=true,
105                                         hasHorizontalScroller=true,hasVerticalScroller=true;
106                 var scroll;
107                 this.comp({ |comp|
108                                 ^comp.scroll(func,comp.bounds.setOriginAbsolute(comp),
109                                         autohidesScrollers,autoScrolls,hasHorizontalScroller,hasVerticalScroller);
110                 })
111         }