11 #include "ui_VuoNodeLibrary.h"
29 #include <objc/objc-runtime.h>
32 map<pair<QString, QString>, QStringList> VuoNodeLibrary::tokensForNodeClass;
33 map<string, int> VuoNodeLibrary::nodeClassFrequency;
34 set<string> VuoNodeLibrary::stopWords;
35 map<VuoCompilerNodeClass *, int> VuoNodeLibrary::newlyInstalledNodeClasses;
47 ui->nodeClassList->verticalScrollBar()->setAttribute(Qt::WA_MacSmallSize);
48 ui->nodeClassList->horizontalScrollBar()->setAttribute(Qt::WA_MacSmallSize);
49 ui->nodePopoverPane->verticalScrollBar()->setAttribute(Qt::WA_MacSmallSize);
50 ui->nodePopoverPane->horizontalScrollBar()->setAttribute(Qt::WA_MacSmallSize);
54 ui->splitter->setStretchFactor(0, 1);
55 ui->splitter->setStretchFactor(1, 0);
57 this->setFocusProxy(ui->textFilter);
58 setTabOrder(ui->textFilter, ui->nodeClassList);
59 ui->VuoNodeLibraryContents->setFocusProxy(ui->nodeClassList);
63 updateListViewTimer =
new QTimer(
this);
64 updateListViewTimer->setObjectName(
"VuoNodeLibrary::updateListViewTimer");
65 updateListViewTimer->setSingleShot(
true);
66 connect(updateListViewTimer, &QTimer::timeout,
this, &VuoNodeLibrary::updateListViewForNewFilterTextNow);
68 connect(ui->nodeClassList, &VuoNodeClassList::itemSelectionChanged,
this,
static_cast<void (QWidget::*)()
>(&QWidget::update));
71 connect(ui->splitter, &QSplitter::splitterMoved,
this, &VuoNodeLibrary::emitNodeDocumentationPanelHeightChanged);
72 connect(ui->textFilter, &VuoNodeLibraryTextFilter::textChanged,
this, &VuoNodeLibrary::updateListViewForNewFilterTextOnTimer);
75 ui->textFilter->installEventFilter(
this);
76 this->hasBeenShown =
false;
77 this->preferredNodeDocumentationPanelHeight = ((
VuoEditor *)qApp)->getPreferredNodeDocumentationPanelHeight();
78 this->preferredNodeLibraryWidth = ((
VuoEditor *)qApp)->getPreferredNodeLibraryWidth();
79 this->defaultMinimumWidth = minimumWidth();
80 this->defaultMaximumWidth = maximumWidth();
83 this->compiler = compiler;
85 populateNodeClassFrequencyMap();
86 populateStopWordList();
87 updateListViewForNewFilterTextNow();
103 for (
int i = nodeClasses.size() - 1; i >= 0; --i)
119 nodeClasses.erase(nodeClasses.begin() + i);
131 if (event->type() == QEvent::KeyPress)
133 QKeyEvent *keyEvent = (QKeyEvent *)(event);
134 if ((keyEvent->key() == Qt::Key_Up) ||
135 (keyEvent->key() == Qt::Key_Down) ||
136 (keyEvent->key() == Qt::Key_PageUp) ||
137 (keyEvent->key() == Qt::Key_PageDown) ||
138 (keyEvent->key() == Qt::Key_Home) ||
139 (keyEvent->key() == Qt::Key_End) ||
140 (keyEvent->key() == Qt::Key_Return))
142 QApplication::sendEvent(ui->nodeClassList, event);
147 object->removeEventFilter(
this);
148 QApplication::sendEvent(
object, event);
149 object->installEventFilter(
this);
155 return QDockWidget::eventFilter(
object, event);
165 updateListViewForNewDisplayMode();
175 updateListViewForNewDisplayMode();
184 this->compiler = compiler;
190 void VuoNodeLibrary::recordNodeClassCapitalizations()
195 capitalizationForNodeClass[QString(className.c_str()).toLower().toUtf8().constData()] = className;
209 popover->
setTextWidth(ui->nodePopoverPane->viewport()->rect().width());
210 popoverForNodeClass[nodeClass->
getClassName()] = popover;
221 map<string, VuoNodePopover *>::iterator popover = popoverForNodeClass.find(className);
222 if (popover != popoverForNodeClass.end())
223 return popover->second;
226 VuoNodePopover *newPopover = initializeNodePopoverForClass(nodeClass, compiler);
234 void VuoNodeLibrary::populateList(vector<VuoCompilerNodeClass *> nodeClasses,
bool resetSelection)
236 QList<QListWidgetItem *> preselectedItems = ui->nodeClassList->selectedItems();
237 set<string> preselectedClasses;
241 foreach (QListWidgetItem *item, preselectedItems)
245 ui->nodeClassList->clear();
246 int firstSelectedMatchIndex = -1;
247 int currentItemIndex = 0;
254 QListWidgetItem *item =
new QListWidgetItem();
255 item->setData(Qt::DisplayRole, className.c_str());
260 ui->nodeClassList->addItem(item);
262 if (preselectedClasses.find(className) != preselectedClasses.end())
264 item->setSelected(
true);
266 if (firstSelectedMatchIndex == -1)
267 firstSelectedMatchIndex = currentItemIndex;
270 item->setSelected(
false);
276 if (ui->nodeClassList->count() >= 1)
278 if (firstSelectedMatchIndex >= 0)
279 ui->nodeClassList->setCurrentItem(ui->nodeClassList->item(firstSelectedMatchIndex));
282 ui->nodeClassList->item(0)->setSelected(
true);
283 ui->nodeClassList->setCurrentItem(ui->nodeClassList->item(0));
287 ui->nodeClassList->update();
293 void VuoNodeLibrary::updateListViewForNewDisplayMode()
295 updateListView(
false);
301 void VuoNodeLibrary::updateListViewForNewFilterTextOnTimer()
303 ui->nodeClassList->selectionFinalized =
false;
304 updateListViewTimer->start(100);
310 void VuoNodeLibrary::updateListViewForNewFilterTextNow()
312 updateListView(
true);
313 ui->nodeClassList->selectionFinalized =
true;
319 bool VuoNodeLibrary::nodeHasPortMatchingString(
VuoCompilerNodeClass *cnc,
string needle,
bool isInput)
324 string name = p->getName();
325 std::transform(name.begin(), name.end(), name.begin(), ::tolower);
326 if (name.find(needle) != string::npos)
336 std::transform(key.begin(), key.end(), key.begin(), ::tolower);
337 if (key.find(needle) != string::npos)
346 std::transform(specializedType.begin(), specializedType.end(), specializedType.begin(), ::tolower);
347 if (specializedType.find(needle) != string::npos)
362 QString actionText, sourcePath;
367 else if ((sourceType ==
".fs") && cnc->
isIsf())
371 else if ((sourceType ==
".vuonode") && !cnc->
isBuiltIn() && !nodeClassEditable)
380 void VuoNodeLibrary::updateListView(
bool resetSelection)
383 QString textFilter = ui->textFilter->text();
384 ui->nodeClassList->setFilterText(textFilter);
385 QStringList tokenizedTextFilter = textFilter.split(QRegExp(
"\\s+"), QString::SkipEmptyParts);
388 QStringList predicates;
389 for (QString token : tokenizedTextFilter)
391 if (token.startsWith(
"in:")
392 || token.startsWith(
"out:")
393 || token.startsWith(
"source:"))
396 tokenizedTextFilter.removeOne(token);
400 vector<VuoCompilerNodeClass *> matchingNodeClasses = getMatchingNodeClassesForSearchTerms(tokenizedTextFilter);
403 if ((matchingNodeClasses.size() == 0) && textFilter.contains(
'.'))
405 tokenizedTextFilter = textFilter.split(QRegExp(
"[\\s\\.]+"), QString::SkipEmptyParts);
406 matchingNodeClasses = getMatchingNodeClassesForSearchTerms(tokenizedTextFilter);
410 for (QString predicate : predicates)
412 string filterValue = predicate.split(
':')[1].toLower().toStdString();
414 if (predicate.startsWith(
"in:"))
416 return !nodeHasPortMatchingString(cnc, filterValue,
true);
418 else if (predicate.startsWith(
"out:"))
420 return !nodeHasPortMatchingString(cnc, filterValue,
false);
422 else if (predicate.startsWith(
"source:"))
424 return !nodeHasSourceType(cnc, filterValue);
427 matchingNodeClasses.erase(std::remove_if(matchingNodeClasses.begin(), matchingNodeClasses.end(), predicateFunction), matchingNodeClasses.end());
430 populateList(matchingNodeClasses, resetSelection);
437 vector<VuoCompilerNodeClass *> VuoNodeLibrary::getMatchingNodeClassesForSearchTerms(QStringList rawTermList)
439 QStringList termList = applyFilterTransformations(rawTermList);
440 int numTokens = termList.size();
441 map<int, map<int, vector<VuoCompilerNodeClass *> > > nodeClassesWithTitleAndClassNameMatches;
450 int numTokensFirstMatchedInTitle = 0;
451 int numTokensFirstMatchedInClassName = 0;
452 bool tokenSearchFailed =
false;
454 for (
int tokenIndex = 0; (! tokenSearchFailed) && (tokenIndex < numTokens); ++tokenIndex)
456 QString currentToken = termList.at(tokenIndex);
457 QStringMatcher textFilterPattern(currentToken, Qt::CaseInsensitive);
458 bool foundCurrentTokenInTitle =
false;
459 bool foundCurrentTokenInClassName =
false;
460 bool foundCurrentTokenInKeywords =
false;
464 for (QStringList::iterator nodeTitleToken = nodeTitleTokens.begin(); (! foundCurrentTokenInTitle) && (nodeTitleToken != nodeTitleTokens.end()); ++nodeTitleToken)
469 if (textFilterPattern.indexIn(*nodeTitleToken) == 0)
470 foundCurrentTokenInTitle =
true;
473 if (foundCurrentTokenInTitle)
474 numTokensFirstMatchedInTitle++;
476 if (! foundCurrentTokenInTitle)
478 for (QStringList::iterator nodeClassNameToken = nodeClassNameTokens.begin(); (! foundCurrentTokenInClassName) && (nodeClassNameToken != nodeClassNameTokens.end()); ++nodeClassNameToken)
483 if (textFilterPattern.indexIn(*nodeClassNameToken) == 0)
484 foundCurrentTokenInClassName =
true;
488 if (foundCurrentTokenInClassName)
489 numTokensFirstMatchedInClassName++;
491 if (!(foundCurrentTokenInTitle || foundCurrentTokenInClassName))
495 foreach (
string automaticKeyword, automaticKeywords)
496 keywords.push_back(automaticKeyword);
511 map<string, VuoCompilerType *> loadedTypes = compiler->
getTypes();
512 for (map<string, VuoCompilerType *>::iterator i = loadedTypes.begin(); i != loadedTypes.end(); ++i)
514 string typeName = i->first;
517 (typeName !=
"VuoMathExpressionList"))
527 QStringList formattedKeywords;
528 foreach (
string keyword, keywords)
530 QStringList tokenizedKeywords = QString(keyword.c_str()).split(QRegExp(
"\\s+"), QString::SkipEmptyParts);
531 foreach (QString tokenizedKeyword, tokenizedKeywords)
532 formattedKeywords.push_back(tokenizedKeyword);
535 for (
int i = 0; (!foundCurrentTokenInKeywords) && (i < formattedKeywords.size()); ++i)
537 QString keyword = formattedKeywords[i];
541 if (textFilterPattern.indexIn(keyword) == 0)
542 foundCurrentTokenInKeywords =
true;
546 if (!(foundCurrentTokenInTitle || foundCurrentTokenInClassName || foundCurrentTokenInKeywords ||
isStopWord(currentToken.toUtf8().constData())))
547 tokenSearchFailed =
true;
550 if (!tokenSearchFailed)
551 nodeClassesWithTitleAndClassNameMatches[numTokensFirstMatchedInTitle][numTokensFirstMatchedInClassName].push_back(nodeClass);
557 vector<VuoCompilerNodeClass *> matchingNodeClasses;
558 for (
int i = numTokens; i >= 0; i--)
560 for (
int j = numTokens-i; j >= 0; j--)
562 vector<VuoCompilerNodeClass *> currentMatches = nodeClassesWithTitleAndClassNameMatches[i][j];
567 sort(currentMatches.begin(), currentMatches.end(), nodeClassLessThan);
569 matchingNodeClasses.insert(matchingNodeClasses.end(), currentMatches.begin(), currentMatches.end());
573 return matchingNodeClasses;
580 QStringList VuoNodeLibrary::applyFilterTransformations(QStringList filterTokenList)
582 QStringList transformedTokenList;
583 foreach (QString token, filterTokenList)
589 else if (token ==
"=>")
594 transformedTokenList.append(
"add");
595 else if (token ==
"-")
596 transformedTokenList.append(
"subtract");
597 else if (token ==
"/")
598 transformedTokenList.append(
"divide");
599 else if ((token ==
"*") || (token ==
"•") || (token ==
"×"))
600 transformedTokenList.append(
"multiply");
601 else if (token ==
"<")
602 transformedTokenList.append(
"less");
603 else if (token ==
">")
604 transformedTokenList.append(
"greater");
605 else if ((token ==
"==") || (token ==
"=") || (token ==
"≠") || (token ==
"!=") || (token ==
"<>"))
606 transformedTokenList.append(
"equal");
607 else if ((token ==
"<=") || (token ==
">="))
608 transformedTokenList.append(
"compare");
609 else if (token ==
"|")
610 transformedTokenList.append(
"value");
611 else if (token ==
"%")
612 transformedTokenList.append(
"limit");
613 else if (token ==
"^")
614 transformedTokenList.append(
"exponentiate");
616 transformedTokenList.append(token);
619 return transformedTokenList;
628 for (
int nodeClassIndex = 0; nodeClassIndex < ui->nodeClassList->count(); ++nodeClassIndex)
629 ui->nodeClassList->setRowHidden(nodeClassIndex,
false);
631 ui->nodeClassList->update();
644 filterText = ui->textFilter->text();
646 selectedNodeClasses.clear();
647 QList<QListWidgetItem *> selectedItems = ui->nodeClassList->selectedItems();
648 foreach (QListWidgetItem *item, selectedItems)
649 selectedNodeClasses.insert(ui->nodeClassList->getNodeClassForItem(item)->getBase()->getClassName());
660 disconnect(ui->textFilter, &QLineEdit::textChanged,
this, &VuoNodeLibrary::updateListViewForNewFilterTextOnTimer);
661 ui->textFilter->setText(filterText);
662 connect(ui->textFilter, &QLineEdit::textChanged,
this, &VuoNodeLibrary::updateListViewForNewFilterTextOnTimer);
664 ui->nodeClassList->disablePopovers();
666 foreach (
string nodeClassName, selectedNodeClasses)
668 ui->nodeClassList->enablePopovers();
679 return (documentationWidget? documentationWidget->
getSelectedText() :
"");
691 pair<QString, QString> namePair = make_pair(nodeName, className);
692 map<pair<QString, QString>, QStringList>::iterator i = VuoNodeLibrary::tokensForNodeClass.find(namePair);
693 if (i != VuoNodeLibrary::tokensForNodeClass.end())
696 QStringList tokenizedNodeName = nodeName.split(QRegExp(
"\\s+"), QString::SkipEmptyParts);
697 QString classNameDelimitedByCaseTransitions = className;
698 classNameDelimitedByCaseTransitions.replace(QRegExp(
"([a-z0-9])([A-Z])"),
"\\1.\\2");
699 QStringList tokenizedClassName = className.split(QRegExp(
"\\."), QString::SkipEmptyParts);
700 QStringList classNameTokenizedAlsoByCaseTransitions = classNameDelimitedByCaseTransitions.split(QRegExp(
"\\."), QString::SkipEmptyParts);
702 QStringList classNameSuffixes;
703 if (!className.isEmpty())
705 QRegExp dotTerminatedPrefix(
"^.*\\.");
706 dotTerminatedPrefix.setMinimal(
true);
708 QString currentClassNameSuffix = className;
709 classNameSuffixes.append(currentClassNameSuffix);
710 while (currentClassNameSuffix.contains(
'.'))
711 classNameSuffixes.append(currentClassNameSuffix.remove(dotTerminatedPrefix));
714 tokenizedNodeName.append(tokenizedClassName);
715 tokenizedNodeName.append(classNameTokenizedAlsoByCaseTransitions);
716 tokenizedNodeName.append(classNameSuffixes);
719 VuoNodeLibrary::tokensForNodeClass[namePair] = tokenizedNodeName;
721 return tokenizedNodeName;
739 ui->textFilter->setFocus();
740 ui->textFilter->selectAll();
748 ui->textFilter->setText(text);
766 bool disablePropagation = isHidden();
768 if (!disablePropagation)
777 bool disablePropagation = isHidden();
779 int oldWidth =
event->oldSize().width();
780 int newWidth =
event->size().width();
782 if (oldWidth != newWidth)
784 int documentationPaneContentWidth = ui->nodePopoverPane->viewport()->rect().width();
786 if (!disablePropagation)
793 if (!disablePropagation)
796 this->preferredNodeLibraryWidth = newWidth;
800 int oldHeight =
event->oldSize().height();
801 int newHeight =
event->size().height();
803 if (oldHeight != newHeight)
805 if (!disablePropagation)
814 if (!disablePropagation)
815 emitNodeDocumentationPanelHeightChanged();
823 void VuoNodeLibrary::emitNodeDocumentationPanelHeightChanged()
825 QList<int> widgetSizes = ui->splitter->sizes();
826 int newSize = widgetSizes[1];
828 this->preferredNodeDocumentationPanelHeight = newSize;
838 bool disablePropagation = isHidden();
840 if (!disablePropagation)
849 if (event->key() == Qt::Key_Escape)
853 if (ui->textFilter->text().isEmpty())
856 ui->textFilter->clear();
867 ui->nodePopoverPane->takeWidget();
875 bool disablePropagation = isHidden();
880 if (preferredNodeLibraryWidth >= 0)
882 setMinimumWidth(preferredNodeLibraryWidth);
883 setMaximumWidth(minimumWidth()+1);
887 updateSplitterPosition();
892 int documentationPaneContentWidth = ui->nodePopoverPane->viewport()->rect().width() -
893 ui->nodePopoverPane->verticalScrollBar()->sizeHint().width();
895 if (!disablePropagation)
901 if (!this->hasBeenShown)
902 ui->nodeClassList->enablePopovers();
904 this->hasBeenShown =
true;
917 setMinimumWidth(defaultMinimumWidth);
918 setMaximumWidth(defaultMaximumWidth);
928 widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
929 widget()->setMinimumWidth(this->preferredNodeLibraryWidth >= 0?
930 this->preferredNodeLibraryWidth :
931 this->defaultMinimumWidth);
932 widget()->setMaximumWidth(this->preferredNodeLibraryWidth >= 0?
933 this->preferredNodeLibraryWidth :
934 this->defaultMinimumWidth);
938 widget()->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
939 widget()->setMinimumWidth(this->defaultMinimumWidth);
940 widget()->setMaximumWidth(this->defaultMaximumWidth);
948 void VuoNodeLibrary::updateSplitterPosition()
950 if (this->preferredNodeDocumentationPanelHeight != -1)
952 QList<int> oldWidgetSizes = ui->splitter->sizes();
953 QList<int> newWidgetSizes;
955 int totalAvailableSize = 0;
956 foreach(
int size, oldWidgetSizes)
957 totalAvailableSize += size;
960 newWidgetSizes.append(totalAvailableSize - this->preferredNodeDocumentationPanelHeight);
963 newWidgetSizes.append(this->preferredNodeDocumentationPanelHeight);
964 ui->splitter->setSizes(newWidgetSizes);
974 string lowercaseNodeClassName = QString(nodeClassName.c_str()).toLower().toUtf8().constData();
995 ui->nodeClassList->enablePopoversAndDisplayCurrent();
1004 if (ui->nodePopoverPane->widget() == panelContentWidget)
1009 QString savedWorkingDir = QDir::currentPath();
1010 if (!resourceDir.isEmpty())
1011 QDir::setCurrent(resourceDir);
1016 ui->nodePopoverPane->setWidget(panelContentWidget);
1018 if (!resourceDir.isEmpty())
1019 QDir::setCurrent(savedWorkingDir);
1031 VuoNodeLibrary::~VuoNodeLibrary()
1040 releaseNodePopovers();
1066 if (nodeClass1IsSubcomposition && !nodeClass2IsSubcomposition)
1069 else if (nodeClass2IsSubcomposition && !nodeClass1IsSubcomposition)
1072 else if (nodeClass1IsSubcomposition && nodeClass2IsSubcomposition)
1074 bool nodeClass1InstalledThisSession = newlyInstalledNodeClasses.find(nodeClass1) != newlyInstalledNodeClasses.end();
1075 bool nodeClass2InstalledThisSession = newlyInstalledNodeClasses.find(nodeClass2) != newlyInstalledNodeClasses.end();
1077 if (nodeClass1InstalledThisSession && !nodeClass2InstalledThisSession)
1079 else if (nodeClass2InstalledThisSession && !nodeClass1InstalledThisSession)
1081 else if (nodeClass1InstalledThisSession && nodeClass2InstalledThisSession)
1082 return (newlyInstalledNodeClasses[nodeClass1] > newlyInstalledNodeClasses[nodeClass2]);
1084 return (nodeClassName1 < nodeClassName2);
1089 bool nodeClass2IsTypecast = nodeClass2->getBase()->isTypecastNodeClass();
1090 if (nodeClass1IsTypecast && !nodeClass2IsTypecast)
1092 else if (nodeClass2IsTypecast && !nodeClass1IsTypecast)
1096 int nodeClass1Frequency = nodeClassFrequency[nodeClassName1];
1097 int nodeClass2Frequency = nodeClassFrequency[nodeClassName2];
1099 return ((nodeClass1Frequency > nodeClass2Frequency) ||
1100 ((nodeClass1Frequency == nodeClass2Frequency) && (nodeClassName1 < nodeClassName2)));
1110 loadedNodeClasses.clear();
1114 releaseNodePopovers();
1127 const vector<VuoCompilerNodeClass *> &nodeClassesToAdd)
1129 if (nodeClassesToRemove.size() >= 1)
1133 releaseNodePopovers();
1137 for (
int i = loadedNodeClasses.size() - 1; i >= 0; --i)
1139 string nodeClassName = loadedNodeClasses[i]->getBase()->getClassName();
1140 if (std::find(nodeClassesToRemove.begin(), nodeClassesToRemove.end(), nodeClassName) != nodeClassesToRemove.end())
1141 loadedNodeClasses.erase(loadedNodeClasses.begin() + i);
1145 vector<VuoCompilerNodeClass *> nodeClassesToAddCopy = nodeClassesToAdd;
1148 if (std::find(loadedNodeClasses.begin(), loadedNodeClasses.end(), nodeClassToAdd) == loadedNodeClasses.end())
1149 loadedNodeClasses.push_back(nodeClassToAdd);
1151 recordNodeClassCapitalizations();
1156 bool clearFilterText =
false;
1157 if (clearFilterText)
1160 disconnect(ui->textFilter, &QLineEdit::textChanged,
this, &VuoNodeLibrary::updateListViewForNewFilterTextOnTimer);
1162 ui->textFilter->setText(
"");
1165 connect(ui->textFilter, &QLineEdit::textChanged,
this, &VuoNodeLibrary::updateListViewForNewFilterTextOnTimer);
1169 ui->nodeClassList->disablePopovers();
1170 updateListView(
false);
1171 ui->nodeClassList->enablePopovers();
1174 if (nodeClassesToRemove.size() >= 1)
1193 bool searchDone = !targetNodeClassName.empty();
1194 for (
int i = 0; i < ui->nodeClassList->count() && !searchDone; ++i)
1196 QListWidgetItem *currentItem = ui->nodeClassList->item(i);
1198 if (currentNodeClassName == targetNodeClassName)
1200 ui->nodeClassList->setCurrentItem(currentItem);
1201 currentItem->setSelected(
true);
1206 if (resetPreviousSelection)
1209 for (
int i = 0; i < ui->nodeClassList->count(); ++i)
1211 QListWidgetItem *currentItem = ui->nodeClassList->item(i);
1213 if (currentNodeClassName != targetNodeClassName)
1214 currentItem->setSelected(
false);
1218 ui->nodeClassList->update();
1220 if (highlightAsNewlyInstalled)
1221 newlyInstalledNodeClasses[compiler->
getNodeClass(targetNodeClassName)] = newlyInstalledNodeClasses.size();
1223 updateListView(
false);
1231 void VuoNodeLibrary::populateNodeClassFrequencyMap()
1233 #include "VuoNodeClassFrequencyMap.hh"
1239 void VuoNodeLibrary::populateStopWordList()
1241 stopWords.insert(
"a");
1242 stopWords.insert(
"an");
1243 stopWords.insert(
"for");
1244 stopWords.insert(
"from");
1245 stopWords.insert(
"in");
1246 stopWords.insert(
"on");
1247 stopWords.insert(
"of");
1248 stopWords.insert(
"the");
1249 stopWords.insert(
"to");
1250 stopWords.insert(
"with");
1258 return (stopWords.find(word.toLower().toUtf8().constData()) != stopWords.end());
1261 void VuoNodeLibrary::releaseNodePopovers()
1265 for (
auto i : popoverForNodeClass)
1266 i.second->cleanup();
1269 popoverForNodeClass.clear();
1275 void VuoNodeLibrary::updateColor(
bool isDark)
1277 QString titleTextColor = isDark ?
"#303030" :
"#808080";
1278 QString titleBackgroundColor = isDark ?
"#919191" :
"#efefef";
1279 QString dockwidgetBackgroundColor = isDark ?
"#505050" :
"#efefef";
1280 QString listBackgroundColor = isDark ?
"#262626" :
"#ffffff";
1281 QString scrollBarColor = isDark ?
"#505050" :
"#dfdfdf";
1282 QString focusRingColor = isDark ?
"#1d6ae5" :
"#74acec";
1284 setStyleSheet(VUO_QSTRINGIFY(
1286 titlebar-close-icon: url(:/Icons/dockwidget-close-%3.png);
1291 QDockWidget::title {
1294 background-color: %2;
1298 QDockWidget::float-button {
1303 .arg(titleTextColor)
1304 .arg(titleBackgroundColor)
1305 .arg(isDark ?
"dark" :
"light")
1308 ui->splitter->setStyleSheet(VUO_QSTRINGIFY(
1310 background: transparent;
1314 background-color: %1;
1317 .arg(dockwidgetBackgroundColor)
1321 QString nodeClassListStyle = VUO_QSTRINGIFY(
1326 border: 1px solid %1;
1328 margin: 3px 2px 0 3px;
1333 border: 2px solid %3;
1336 QAbstractScrollArea::corner {
1340 .arg(dockwidgetBackgroundColor)
1341 .arg(listBackgroundColor)
1342 .arg(focusRingColor);
1345 nodeClassListStyle += VUO_QSTRINGIFY(
1347 background: transparent;
1351 QScrollBar::handle {
1358 QAbstractScrollArea::corner,
1360 QScrollBar::sub-line,
1362 QScrollBar::sub-page {
1363 background: transparent;
1367 .arg(scrollBarColor);
1369 ui->nodeClassList->setStyleSheet(nodeClassListStyle);
1372 QString nodePopoverPaneStyle = VUO_QSTRINGIFY(
1378 margin: 0 2px 3px 3px;
1381 .arg(listBackgroundColor);
1384 nodePopoverPaneStyle += VUO_QSTRINGIFY(
1386 background: transparent;
1390 QScrollBar::handle {
1397 QAbstractScrollArea::corner,
1399 QScrollBar::sub-line,
1401 QScrollBar::sub-page {
1402 background: transparent;
1406 .arg(scrollBarColor);
1408 ui->nodePopoverPane->setStyleSheet(nodePopoverPaneStyle);
1414 setWindowFlags(windowFlags() | Qt::Dialog);
1416 id nsView = (id)winId();
1417 id nsWindow = objc_msgSend(nsView, sel_getUid(
"window"));
1418 unsigned long styleMask = 0;
1419 styleMask |= 1 << 0;
1420 styleMask |= 1 << 1;
1421 styleMask |= 1 << 3;
1422 styleMask |= 1 << 4;
1424 styleMask |= 1 << 13;
1425 objc_msgSend(nsWindow, sel_getUid(
"setStyleMask:"), styleMask);
1428 objc_msgSend(nsWindow, sel_getUid(
"setMovableByWindowBackground:"),
false);