2 spacing_ { arg spacing;
3 this.setProperty( \spacing, spacing );
6 margins_ { arg margins;
7 this.setProperty( \margins, margins + [0,0,0,0] );
11 // LINE LAYOUTS ///////////////////////////////////////////////////
13 QLineLayout : QLayout {
15 var serializedItems = items.collect( { |x| this.parse(x) } );
16 ^super.new( [serializedItems] );
23 if( in.isKindOf(Array) ) {
26 while { i + 1 < in.size } {
29 { (key === \stretch) || (key === \s) }, { out[1] = in[i+1] },
30 { (key === \align) || (key === \a) }, { out[2] = QAlignment(in[i+1]) }
40 add { arg item, stretch = 0, align;
41 this.invokeMethod( \addItem, [[item, stretch, QAlignment(align)]], true );
44 insert { arg item, index=0, stretch = 0, align;
45 this.invokeMethod( \insertItem, [[item, index, stretch, QAlignment(align)]], true );
48 setStretch { arg item, stretch;
49 this.invokeMethod( \setStretch, [item, stretch], true );
52 setAlignment { arg item, align;
53 this.invokeMethod( \setAlignment, [item, QAlignment(align)], true );
57 QHLayout : QLineLayout {
58 *implementsClass {^'HLayout'}
59 *qtClass { ^'QcHBoxLayout' }
62 QVLayout : QLineLayout {
63 *implementsClass {^'VLayout'}
64 *qtClass { ^'QcVBoxLayout' }
67 // GRID LAYOUT ///////////////////////////////////////////////////
69 QGridLayout : QLayout {
70 *implementsClass {^'GridLayout'}
73 // get rid of QObject's arguments
77 *qtClass { ^'QcGridLayout' }
79 *parse { arg in, row, col;
80 var out = [nil,row,col,1,1,nil];
83 if( in.isKindOf(Array) ) {
86 while { i + 1 < in.size } {
89 { (key === \rows) || (key === \r) }, { out[3] = in[i+1] },
90 { (key === \columns) || (key === \c) }, { out[4] = in[i+1] },
91 { (key === \align) || (key === \a) }, { out[5] = QAlignment(in[i+1]) }
102 *rows { arg ...rows ;
110 data = this.parse( item, r, c );
111 grid.invokeMethod( \addItem, [data], true );
119 *columns { arg ...cols;
127 data = this.parse( item, r, c );
128 grid.invokeMethod( \addItem, [data], true );
136 add { arg item, row, column, align;
137 this.invokeMethod( \addItem, [[item, row, column, 1, 1, QAlignment(align)]], true );
140 addSpanning { arg item, row, column, rowSpan=1, columnSpan=1, align;
141 this.invokeMethod( \addItem, [[item, row, column,
147 hSpacing_ { arg spacing;
148 this.setProperty( \horizontalSpacing, spacing );
151 vSpacing_ { arg spacing;
152 this.setProperty( \verticalSpacing, spacing );
155 setRowStretch{ arg row, factor;
156 this.invokeMethod( 'setRowStretch', [row, factor], true );
159 setColumnStretch{ arg column, factor;
160 this.invokeMethod( 'setColumnStretch', [column, factor], true );
163 setAlignment { arg item, align;
164 var args = if( item.class === Point )
165 { [item.y, item.x, QAlignment(align)] }
166 { [item, QAlignment(align)] };
168 this.invokeMethod( \setAlignment, args, true );
171 minRowHeight { arg row; ^this.invokeMethod( \minRowHeight, row ); }
173 setMinRowHeight { arg row, height;
174 this.invokeMethod( \setMinRowHeight, [row, height] );
177 minColumnWidth { arg column; ^this.invokeMethod( \minColumnWidth, column ); }
179 setMinColumnWidth { arg column, width;
180 this.invokeMethod( \setMinColumnWidth, [column, width] );
184 QStackLayout : QLayout
186 *implementsClass {^'StackLayout'}
188 *qtClass { ^'QcStackLayout' }
190 *new { arg ...views; ^super.new([views]) }
192 add { arg view; this.insert(view, -1) }
194 insert { arg view, index = 0; this.invokeMethod( \insertWidget, [index, view] ) }
196 index { ^this.getProperty(\currentIndex) }
197 index_ { arg value; this.setProperty(\currentIndex, value) }
199 count { ^this.getProperty(\count) }
201 mode { ^this.getProperty(\stackingMode) }
203 value = value.switch(
208 value = value.clip(0, 1).asInteger;
209 this.setProperty(\stackingMode, value)