Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classlib: GUI: Support "has-a" GUI objects by calling asView within Layouts #2188

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions SCClassLibrary/Common/GUI/Base/QLayout.sc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Layout : QObject {
margins_ { arg margins;
this.setProperty( \margins, margins + [0,0,0,0] );
}
asView { ^this }
}

// LINE LAYOUTS ///////////////////////////////////////////////////
Expand All @@ -21,7 +22,7 @@ LineLayout : Layout {
var key;
var i;
if( in.isKindOf(Array) ) {
out[0] = in[0];
out[0] = in[0].asView;
i = 1;
while { i + 1 < in.size } {
key = in[i];
Expand All @@ -32,25 +33,25 @@ LineLayout : Layout {
i = i + 2;
};
}{
out[0] = in;
out[0] = in.asView;
};
^out;
}

add { arg item, stretch = 0, align;
this.invokeMethod( \addItem, [[item, stretch, QAlignment(align)]], true );
this.invokeMethod( \addItem, [[item.asView, stretch, QAlignment(align)]], true );
}

insert { arg item, index=0, stretch = 0, align;
this.invokeMethod( \insertItem, [[item, index, stretch, QAlignment(align)]], true );
this.invokeMethod( \insertItem, [[item.asView, index, stretch, QAlignment(align)]], true );
}

setStretch { arg item, stretch;
this.invokeMethod( \setStretch, [item, stretch], true );
this.invokeMethod( \setStretch, [item.asView, stretch], true );
}

setAlignment { arg item, align;
this.invokeMethod( \setAlignment, [item, QAlignment(align)], true );
this.invokeMethod( \setAlignment, [item.asView, QAlignment(align)], true );
}
}

Expand Down Expand Up @@ -78,7 +79,7 @@ GridLayout : Layout {
var key;
var i;
if( in.isKindOf(Array) ) {
out[0] = in[0];
out[0] = in[0].asView;
i = 1;
while { i + 1 < in.size } {
key = in[i];
Expand All @@ -90,7 +91,7 @@ GridLayout : Layout {
i = i + 2;
};
}{
out[0] = in;
out[0] = in.asView;
};
^out;
}
Expand Down Expand Up @@ -143,11 +144,11 @@ GridLayout : Layout {
}

add { arg item, row, column, align;
this.invokeMethod( \addItem, [[item, row, column, 1, 1, QAlignment(align)]], true );
this.invokeMethod( \addItem, [[item.asView, row, column, 1, 1, QAlignment(align)]], true );
}

addSpanning { arg item, row, column, rowSpan=1, columnSpan=1, align;
this.invokeMethod( \addItem, [[item, row, column,
this.invokeMethod( \addItem, [[item.asView, row, column,
rowSpan, columnSpan,
QAlignment(align)
]], true );
Expand Down Expand Up @@ -194,11 +195,11 @@ StackLayout : Layout {

*qtClass { ^'QcStackLayout' }

*new { arg ...views; ^super.new([views]) }
*new { arg ...views; ^super.new([views.collect(_.asView)]) }

add { arg view; this.insert(view, -1) }
add { arg view; this.insert(view.asView, -1) }

insert { arg view, index = 0; this.invokeMethod( \insertWidget, [index, view] ) }
insert { arg view, index = 0; this.invokeMethod( \insertWidget, [index, view.asView] ) }

index { ^this.getProperty(\currentIndex) }
index_ { arg value; this.setProperty(\currentIndex, value) }
Expand Down