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 *qtClass { ^'QcHBoxLayout'; }
61 QVLayout : QLineLayout {
62 *qtClass { ^'QcVBoxLayout'; }
65 // GRID LAYOUT ///////////////////////////////////////////////////
67 QGridLayout : QLayout {
69 // get rid of QObject's arguments
73 *qtClass { ^'QcGridLayout' }
75 *parse { arg in, row, col;
76 var out = [nil,row,col,1,1,nil];
79 if( in.isKindOf(Array) ) {
82 while { i + 1 < in.size } {
85 { (key === \rows) || (key === \r) }, { out[3] = in[i+1] },
86 { (key === \columns) || (key === \c) }, { out[4] = in[i+1] },
87 { (key === \align) || (key === \a) }, { out[5] = QAlignment(in[i+1]) }
106 data = this.parse( item, r, c );
107 grid.invokeMethod( \addItem, [data], true );
115 *columns { arg ...cols;
123 data = this.parse( item, r, c );
124 grid.invokeMethod( \addItem, [data], true );
132 add { arg item, row, column, align;
133 this.invokeMethod( \addItem, [[item, row, column, 1, 1, QAlignment(align)]], true );
136 addSpanning { arg item, row, column, rowSpan=1, columnSpan=1, align;
137 this.invokeMethod( \addItem, [[item, row, column,
143 hSpacing_ { arg spacing;
144 this.setProperty( \horizontalSpacing, spacing );
147 vSpacing_ { arg spacing;
148 this.setProperty( \verticalSpacing, spacing );
151 setRowStretch{ arg row, factor;
152 this.invokeMethod( 'setRowStretch', [row, factor], true );
155 setColumnStretch{ arg column, factor;
156 this.invokeMethod( 'setColumnStretch', [column, factor], true );
159 setAlignment { arg item, align;
160 var args = if( item.class === Point )
161 { [item.y, item.x, QAlignment(align)] }
162 { [item, QAlignment(align)] };
164 this.invokeMethod( \setAlignment, args, true );
167 minRowHeight { arg row; ^this.invokeMethod( \minRowHeight, row ); }
169 setMinRowHeight { arg row, height;
170 this.invokeMethod( \setMinRowHeight, [row, height] );
173 minColumnWidth { arg column; ^this.invokeMethod( \minColumnWidth, column ); }
175 setMinColumnWidth { arg column, width;
176 this.invokeMethod( \setMinColumnWidth, [column, width] );
180 QStackLayout : QLayout
182 *qtClass { ^'QcStackLayout' }
184 *new { arg ...views; ^super.new([views]) }
186 add { arg view; this.insert(view, -1) }
188 insert { arg view, index = 0; this.invokeMethod( \insertWidget, [index, view] ) }
190 index { ^this.getProperty(\currentIndex) }
191 index_ { arg value; this.setProperty(\currentIndex, value) }
193 count { ^this.getProperty(\count) }
195 mode { ^this.getProperty(\stackingMode) }
197 value = value.switch(
202 value = value.clip(0, 1).asInteger;
203 this.setProperty(\stackingMode, value)