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

feat: add \hide to styling dict to allow hiding elements from gui #395

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 21 additions & 1 deletion Modality/Classes/GUI/MKtlGUI.sc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ MKtlGUI {
"%: will show %'s % elements in % views.\n".postf(thisMethod, mktl,
mktl.elementsDict.size, elemsToShow.size);

// Remove elements that have the hide flag set in the style dict
elemsToShow = elemsToShow.reject({ |el|
try {el.elemDesc[ \style ].notNil && el.elemDesc[ \style ][ \hide ] == true} ? false;
});

views = elemsToShow.collect({ |item|
var style, bounds, parView = parent, redirView, newViews;
var itemIsGroup = item.isKindOf(MKtlElementGroup);
Expand Down Expand Up @@ -394,7 +399,22 @@ MKtlGUI {
if (mktl.elementGroup.elements.isEmpty) {
^[1, 2]
};
^mktl.elementGroup.flat.collect({ |item|
^mktl.elementGroup.flat
// Remove element from count if it is hidden
.reject({|item|
var desc = item.elemDesc;

if(desc.isNil, {
false
}, {
if(desc[ \style ].isNil, {
false
}, {
desc[ \style ][ \hide ] == true
})
})

}).collect({ |item|
var desc = item.elemDesc;
desc !? {
((desc[ \style ] ?? { ( row: 0, column: 0, width: 0, height: 0 ) })
Expand Down