11#include "ui_VuoNodeLibrary.h"
30#include <objc/objc-runtime.h>
33map<pair<QString, QString>, QStringList> VuoNodeLibrary::tokensForNodeClass;
34map<string, int> VuoNodeLibrary::nodeClassFrequency;
35set<string> VuoNodeLibrary::stopWords;
36map<VuoCompilerNodeClass *, int> VuoNodeLibrary::newlyInstalledNodeClasses;
48 ui->nodeClassList->verticalScrollBar()->setAttribute(Qt::WA_MacSmallSize);
49 ui->nodeClassList->horizontalScrollBar()->setAttribute(Qt::WA_MacSmallSize);
50 ui->nodePopoverPane->verticalScrollBar()->setAttribute(Qt::WA_MacSmallSize);
51 ui->nodePopoverPane->horizontalScrollBar()->setAttribute(Qt::WA_MacSmallSize);
55 ui->splitter->setStretchFactor(0, 1);
56 ui->splitter->setStretchFactor(1, 0);
58 this->setFocusProxy(ui->textFilter);
59 setTabOrder(ui->textFilter, ui->nodeClassList);
60 ui->VuoNodeLibraryContents->setFocusProxy(ui->nodeClassList);
64 updateListViewTimer =
new QTimer(
this);
65 updateListViewTimer->setObjectName(
"VuoNodeLibrary::updateListViewTimer");
66 updateListViewTimer->setSingleShot(
true);
67 connect(updateListViewTimer, &QTimer::timeout,
this, &VuoNodeLibrary::updateListViewForNewFilterTextNow);
69 connect(ui->nodeClassList, &VuoNodeClassList::itemSelectionChanged,
this,
static_cast<void (QWidget::*)()
>(&QWidget::update));
72 connect(ui->splitter, &QSplitter::splitterMoved,
this, &VuoNodeLibrary::emitNodeDocumentationPanelHeightChanged);
73 connect(ui->textFilter, &VuoNodeLibraryTextFilter::textChanged,
this, &VuoNodeLibrary::updateListViewForNewFilterTextOnTimer);
76 ui->textFilter->installEventFilter(
this);
77 this->hasBeenShown =
false;
78 this->preferredNodeDocumentationPanelHeight = ((
VuoEditor *)qApp)->getPreferredNodeDocumentationPanelHeight();
79 this->preferredNodeLibraryWidth = ((
VuoEditor *)qApp)->getPreferredNodeLibraryWidth();
80 this->defaultMinimumWidth = minimumWidth();
81 this->defaultMaximumWidth = maximumWidth();
84 this->compiler = compiler;
85 this->moduleManager = moduleManager;
87 populateNodeClassFrequencyMap();
88 populateStopWordList();
89 updateListViewForNewFilterTextNow();
105 for (
int i = nodeClasses.size() - 1; i >= 0; --i)
121 nodeClasses.erase(nodeClasses.begin() + i);
133 if (event->type() == QEvent::KeyPress)
135 QKeyEvent *keyEvent = (QKeyEvent *)(event);
136 if ((keyEvent->key() == Qt::Key_Up) ||
137 (keyEvent->key() == Qt::Key_Down) ||
138 (keyEvent->key() == Qt::Key_PageUp) ||
139 (keyEvent->key() == Qt::Key_PageDown) ||
140 (keyEvent->key() == Qt::Key_Home) ||
141 (keyEvent->key() == Qt::Key_End) ||
142 (keyEvent->key() == Qt::Key_Return))
144 QApplication::sendEvent(ui->nodeClassList, event);
149 object->removeEventFilter(
this);
150 QApplication::sendEvent(
object, event);
151 object->installEventFilter(
this);
157 return QDockWidget::eventFilter(
object, event);
167 updateListViewForNewDisplayMode();
177 updateListViewForNewDisplayMode();
186 this->compiler = compiler;
194 this->moduleManager = moduleManager;
200void VuoNodeLibrary::recordNodeClassCapitalizations()
205 capitalizationForNodeClass[QString(className.c_str()).toLower().toUtf8().constData()] = className;
219 popover->
setTextWidth(ui->nodePopoverPane->viewport()->rect().width());
220 popoverForNodeClass[nodeClass->
getClassName()] = popover;
231 map<string, VuoNodePopover *>::iterator popover = popoverForNodeClass.find(className);
232 if (popover != popoverForNodeClass.end())
233 return popover->second;
236 VuoNodePopover *newPopover = initializeNodePopoverForClass(nodeClass, compiler);
244void VuoNodeLibrary::populateList(vector<VuoCompilerNodeClass *> nodeClasses,
bool resetSelection)
246 QList<QListWidgetItem *> preselectedItems = ui->nodeClassList->selectedItems();
247 set<string> preselectedClasses;
251 foreach (QListWidgetItem *item, preselectedItems)
255 ui->nodeClassList->clear();
256 int firstSelectedMatchIndex = -1;
257 int currentItemIndex = 0;
264 QListWidgetItem *item =
new QListWidgetItem();
265 item->setData(Qt::DisplayRole, className.c_str());
270 ui->nodeClassList->addItem(item);
272 if (preselectedClasses.find(className) != preselectedClasses.end())
274 item->setSelected(
true);
276 if (firstSelectedMatchIndex == -1)
277 firstSelectedMatchIndex = currentItemIndex;
280 item->setSelected(
false);
286 if (ui->nodeClassList->count() >= 1)
288 if (firstSelectedMatchIndex >= 0)
289 ui->nodeClassList->setCurrentItem(ui->nodeClassList->item(firstSelectedMatchIndex));
292 ui->nodeClassList->item(0)->setSelected(
true);
293 ui->nodeClassList->setCurrentItem(ui->nodeClassList->item(0));
297 ui->nodeClassList->update();
303void VuoNodeLibrary::updateListViewForNewDisplayMode()
305 updateListView(
false);
311void VuoNodeLibrary::updateListViewForNewFilterTextOnTimer()
313 ui->nodeClassList->selectionFinalized =
false;
314 updateListViewTimer->start(100);
320void VuoNodeLibrary::updateListViewForNewFilterTextNow()
322 updateListView(
true);
323 ui->nodeClassList->selectionFinalized =
true;
329bool VuoNodeLibrary::nodeHasPortMatchingString(
VuoCompilerNodeClass *cnc,
string needle,
bool isInput)
334 string name = p->getName();
335 std::transform(name.begin(), name.end(), name.begin(), ::tolower);
336 if (name.find(needle) != string::npos)
346 std::transform(key.begin(), key.end(), key.begin(), ::tolower);
347 if (key.find(needle) != string::npos)
354 for (
string specializedType : genericType->getCompatibleSpecializedTypes(compatibility))
356 std::transform(specializedType.begin(), specializedType.end(), specializedType.begin(), ::tolower);
357 if (specializedType.find(needle) != string::npos)
372 QString actionText, sourcePath;
377 else if ((sourceType ==
".fs") && cnc->
isIsf())
381 else if ((sourceType ==
".vuonode") && !cnc->
isBuiltIn() && !nodeClassEditable)
390void VuoNodeLibrary::updateListView(
bool resetSelection)
393 QString textFilter = ui->textFilter->text();
394 ui->nodeClassList->setFilterText(textFilter);
395 QStringList tokenizedTextFilter = textFilter.split(QRegExp(
"\\s+"), QString::SkipEmptyParts);
398 QStringList predicates;
399 for (QString token : tokenizedTextFilter)
401 if (token.startsWith(
"in:")
402 || token.startsWith(
"out:")
403 || token.startsWith(
"source:"))
406 tokenizedTextFilter.removeOne(token);
410 vector<VuoCompilerNodeClass *> matchingNodeClasses = getMatchingNodeClassesForSearchTerms(tokenizedTextFilter);
413 if ((matchingNodeClasses.size() == 0) && textFilter.contains(
'.'))
415 tokenizedTextFilter = textFilter.split(QRegExp(
"[\\s\\.]+"), QString::SkipEmptyParts);
416 matchingNodeClasses = getMatchingNodeClassesForSearchTerms(tokenizedTextFilter);
420 for (QString predicate : predicates)
422 string filterValue = predicate.split(
':')[1].toLower().toStdString();
424 if (predicate.startsWith(
"in:"))
426 return !nodeHasPortMatchingString(cnc, filterValue,
true);
428 else if (predicate.startsWith(
"out:"))
430 return !nodeHasPortMatchingString(cnc, filterValue,
false);
432 else if (predicate.startsWith(
"source:"))
434 return !nodeHasSourceType(cnc, filterValue);
437 matchingNodeClasses.erase(std::remove_if(matchingNodeClasses.begin(), matchingNodeClasses.end(), predicateFunction), matchingNodeClasses.end());
440 populateList(matchingNodeClasses, resetSelection);
447vector<VuoCompilerNodeClass *> VuoNodeLibrary::getMatchingNodeClassesForSearchTerms(QStringList rawTermList)
449 QStringList termList = applyFilterTransformations(rawTermList);
450 int numTokens = termList.size();
451 map<int, map<int, vector<VuoCompilerNodeClass *> > > nodeClassesWithTitleAndClassNameMatches;
460 int numTokensFirstMatchedInTitle = 0;
461 int numTokensFirstMatchedInClassName = 0;
462 bool tokenSearchFailed =
false;
464 for (
int tokenIndex = 0; (! tokenSearchFailed) && (tokenIndex < numTokens); ++tokenIndex)
466 QString currentToken = termList.at(tokenIndex);
467 QStringMatcher textFilterPattern(currentToken, Qt::CaseInsensitive);
468 bool foundCurrentTokenInTitle =
false;
469 bool foundCurrentTokenInClassName =
false;
470 bool foundCurrentTokenInKeywords =
false;
474 for (QStringList::iterator nodeTitleToken = nodeTitleTokens.begin(); (! foundCurrentTokenInTitle) && (nodeTitleToken != nodeTitleTokens.end()); ++nodeTitleToken)
479 if (textFilterPattern.indexIn(*nodeTitleToken) == 0)
480 foundCurrentTokenInTitle =
true;
483 if (foundCurrentTokenInTitle)
484 numTokensFirstMatchedInTitle++;
486 if (! foundCurrentTokenInTitle)
488 for (QStringList::iterator nodeClassNameToken = nodeClassNameTokens.begin(); (! foundCurrentTokenInClassName) && (nodeClassNameToken != nodeClassNameTokens.end()); ++nodeClassNameToken)
493 if (textFilterPattern.indexIn(*nodeClassNameToken) == 0)
494 foundCurrentTokenInClassName =
true;
498 if (foundCurrentTokenInClassName)
499 numTokensFirstMatchedInClassName++;
501 if (!(foundCurrentTokenInTitle || foundCurrentTokenInClassName))
505 foreach (
string automaticKeyword, automaticKeywords)
506 keywords.push_back(automaticKeyword);
521 for (
auto i : moduleManager->getLoadedSingletonTypes(true))
522 keywords.push_back(i.second->getBase()->getDefaultTitle());
526 QStringList formattedKeywords;
527 foreach (
string keyword, keywords)
529 QStringList tokenizedKeywords = QString(keyword.c_str()).split(QRegExp(
"\\s+"), QString::SkipEmptyParts);
530 foreach (QString tokenizedKeyword, tokenizedKeywords)
531 formattedKeywords.push_back(tokenizedKeyword);
534 for (
int i = 0; (!foundCurrentTokenInKeywords) && (i < formattedKeywords.size()); ++i)
536 QString keyword = formattedKeywords[i];
540 if (textFilterPattern.indexIn(keyword) == 0)
541 foundCurrentTokenInKeywords =
true;
545 if (!(foundCurrentTokenInTitle || foundCurrentTokenInClassName || foundCurrentTokenInKeywords ||
isStopWord(currentToken.toUtf8().constData())))
546 tokenSearchFailed =
true;
549 if (!tokenSearchFailed)
550 nodeClassesWithTitleAndClassNameMatches[numTokensFirstMatchedInTitle][numTokensFirstMatchedInClassName].push_back(nodeClass);
556 vector<VuoCompilerNodeClass *> matchingNodeClasses;
557 for (
int i = numTokens; i >= 0; i--)
559 for (
int j = numTokens-i; j >= 0; j--)
561 vector<VuoCompilerNodeClass *> currentMatches = nodeClassesWithTitleAndClassNameMatches[i][j];
566 sort(currentMatches.begin(), currentMatches.end(), nodeClassLessThan);
568 matchingNodeClasses.insert(matchingNodeClasses.end(), currentMatches.begin(), currentMatches.end());
572 return matchingNodeClasses;
579QStringList VuoNodeLibrary::applyFilterTransformations(QStringList filterTokenList)
581 QStringList transformedTokenList;
582 foreach (QString token, filterTokenList)
588 else if (token ==
"=>")
593 transformedTokenList.append(
"add");
594 else if (token ==
"-")
595 transformedTokenList.append(
"subtract");
596 else if (token ==
"/")
597 transformedTokenList.append(
"divide");
598 else if ((token ==
"*") || (token ==
"•") || (token ==
"×"))
599 transformedTokenList.append(
"multiply");
600 else if (token ==
"<")
601 transformedTokenList.append(
"less");
602 else if (token ==
">")
603 transformedTokenList.append(
"greater");
604 else if ((token ==
"==") || (token ==
"=") || (token ==
"≠") || (token ==
"!=") || (token ==
"<>"))
605 transformedTokenList.append(
"equal");
606 else if ((token ==
"<=") || (token ==
">="))
607 transformedTokenList.append(
"compare");
608 else if (token ==
"|")
609 transformedTokenList.append(
"value");
610 else if (token ==
"%")
611 transformedTokenList.append(
"limit");
612 else if (token ==
"^")
613 transformedTokenList.append(
"exponentiate");
615 transformedTokenList.append(token);
618 return transformedTokenList;
627 for (
int nodeClassIndex = 0; nodeClassIndex < ui->nodeClassList->count(); ++nodeClassIndex)
628 ui->nodeClassList->setRowHidden(nodeClassIndex,
false);
630 ui->nodeClassList->update();
643 filterText = ui->textFilter->text();
645 selectedNodeClasses.clear();
646 QList<QListWidgetItem *> selectedItems = ui->nodeClassList->selectedItems();
647 foreach (QListWidgetItem *item, selectedItems)
648 selectedNodeClasses.insert(ui->nodeClassList->getNodeClassForItem(item)->getBase()->getClassName());
659 disconnect(ui->textFilter, &QLineEdit::textChanged,
this, &VuoNodeLibrary::updateListViewForNewFilterTextOnTimer);
660 ui->textFilter->setText(filterText);
661 connect(ui->textFilter, &QLineEdit::textChanged,
this, &VuoNodeLibrary::updateListViewForNewFilterTextOnTimer);
663 ui->nodeClassList->disablePopovers();
665 foreach (
string nodeClassName, selectedNodeClasses)
667 ui->nodeClassList->enablePopovers();
678 return (documentationWidget? documentationWidget->
getSelectedText() :
"");
690 pair<QString, QString> namePair = make_pair(nodeName, className);
691 map<pair<QString, QString>, QStringList>::iterator i = VuoNodeLibrary::tokensForNodeClass.find(namePair);
692 if (i != VuoNodeLibrary::tokensForNodeClass.end())
695 QStringList tokenizedNodeName = nodeName.split(QRegExp(
"\\s+"), QString::SkipEmptyParts);
696 QString classNameDelimitedByCaseTransitions = className;
697 classNameDelimitedByCaseTransitions.replace(QRegExp(
"([a-z0-9])([A-Z])"),
"\\1.\\2");
698 QStringList tokenizedClassName = className.split(QRegExp(
"\\."), QString::SkipEmptyParts);
699 QStringList classNameTokenizedAlsoByCaseTransitions = classNameDelimitedByCaseTransitions.split(QRegExp(
"\\."), QString::SkipEmptyParts);
701 QStringList classNameSuffixes;
702 if (!className.isEmpty())
704 QRegExp dotTerminatedPrefix(
"^.*\\.");
705 dotTerminatedPrefix.setMinimal(
true);
707 QString currentClassNameSuffix = className;
708 classNameSuffixes.append(currentClassNameSuffix);
709 while (currentClassNameSuffix.contains(
'.'))
710 classNameSuffixes.append(currentClassNameSuffix.remove(dotTerminatedPrefix));
713 tokenizedNodeName.append(tokenizedClassName);
714 tokenizedNodeName.append(classNameTokenizedAlsoByCaseTransitions);
715 tokenizedNodeName.append(classNameSuffixes);
718 VuoNodeLibrary::tokensForNodeClass[namePair] = tokenizedNodeName;
720 return tokenizedNodeName;
738 ui->textFilter->setFocus();
739 ui->textFilter->selectAll();
747 ui->textFilter->setFocus();
755 ui->textFilter->setText(text);
763 ui->textFilter->insert(text);
781 bool disablePropagation = isHidden();
783 if (!disablePropagation)
792 bool disablePropagation = isHidden();
794 int oldWidth =
event->oldSize().width();
795 int newWidth =
event->size().width();
797 if (oldWidth != newWidth)
799 int documentationPaneContentWidth = ui->nodePopoverPane->viewport()->rect().width();
801 if (!disablePropagation)
808 if (!disablePropagation)
811 this->preferredNodeLibraryWidth = newWidth;
815 int oldHeight =
event->oldSize().height();
816 int newHeight =
event->size().height();
818 if (oldHeight != newHeight)
820 if (!disablePropagation)
829 if (!disablePropagation)
830 emitNodeDocumentationPanelHeightChanged();
838void VuoNodeLibrary::emitNodeDocumentationPanelHeightChanged()
840 QList<int> widgetSizes = ui->splitter->sizes();
841 int newSize = widgetSizes[1];
843 this->preferredNodeDocumentationPanelHeight = newSize;
853 bool disablePropagation = isHidden();
855 if (!disablePropagation)
864 if (event->key() == Qt::Key_Escape)
868 if (ui->textFilter->text().isEmpty())
871 ui->textFilter->clear();
882 ui->nodePopoverPane->takeWidget();
890 bool disablePropagation = isHidden();
895 if (preferredNodeLibraryWidth >= 0)
897 setMinimumWidth(preferredNodeLibraryWidth+1);
898 setMinimumWidth(preferredNodeLibraryWidth);
903 setMinimumWidth(minimumWidth()+1);
904 setMinimumWidth(minimumWidth()-1);
908 updateSplitterPosition();
913 int documentationPaneContentWidth = ui->nodePopoverPane->viewport()->rect().width() -
914 ui->nodePopoverPane->verticalScrollBar()->sizeHint().width();
916 if (!disablePropagation)
922 if (!this->hasBeenShown)
923 ui->nodeClassList->enablePopovers();
925 this->hasBeenShown =
true;
938 setMinimumWidth(defaultMinimumWidth);
939 setMaximumWidth(defaultMaximumWidth);
949 widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
950 widget()->setMinimumWidth(this->preferredNodeLibraryWidth >= 0?
951 this->preferredNodeLibraryWidth :
952 this->defaultMinimumWidth);
953 widget()->setMaximumWidth(this->preferredNodeLibraryWidth >= 0?
954 this->preferredNodeLibraryWidth :
955 this->defaultMinimumWidth);
959 widget()->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
960 widget()->setMinimumWidth(this->defaultMinimumWidth);
961 widget()->setMaximumWidth(this->defaultMaximumWidth);
969void VuoNodeLibrary::updateSplitterPosition()
971 if (this->preferredNodeDocumentationPanelHeight != -1)
973 QList<int> oldWidgetSizes = ui->splitter->sizes();
974 QList<int> newWidgetSizes;
976 int totalAvailableSize = 0;
977 foreach(
int size, oldWidgetSizes)
978 totalAvailableSize += size;
981 newWidgetSizes.append(totalAvailableSize - this->preferredNodeDocumentationPanelHeight);
984 newWidgetSizes.append(this->preferredNodeDocumentationPanelHeight);
985 ui->splitter->setSizes(newWidgetSizes);
995 string lowercaseNodeClassName = QString(nodeClassName.c_str()).toLower().toUtf8().constData();
1016 ui->nodeClassList->enablePopoversAndDisplayCurrent();
1025 if (ui->nodePopoverPane->widget() == panelContentWidget)
1030 QString savedWorkingDir = QDir::currentPath();
1031 if (!resourceDir.isEmpty())
1032 QDir::setCurrent(resourceDir);
1037 ui->nodePopoverPane->setWidget(panelContentWidget);
1039 if (!resourceDir.isEmpty())
1040 QDir::setCurrent(savedWorkingDir);
1052VuoNodeLibrary::~VuoNodeLibrary()
1061 releaseNodePopovers();
1087 if (nodeClass1IsSubcomposition && !nodeClass2IsSubcomposition)
1090 else if (nodeClass2IsSubcomposition && !nodeClass1IsSubcomposition)
1093 else if (nodeClass1IsSubcomposition && nodeClass2IsSubcomposition)
1095 bool nodeClass1InstalledThisSession = newlyInstalledNodeClasses.find(nodeClass1) != newlyInstalledNodeClasses.end();
1096 bool nodeClass2InstalledThisSession = newlyInstalledNodeClasses.find(nodeClass2) != newlyInstalledNodeClasses.end();
1098 if (nodeClass1InstalledThisSession && !nodeClass2InstalledThisSession)
1100 else if (nodeClass2InstalledThisSession && !nodeClass1InstalledThisSession)
1102 else if (nodeClass1InstalledThisSession && nodeClass2InstalledThisSession)
1103 return (newlyInstalledNodeClasses[nodeClass1] > newlyInstalledNodeClasses[nodeClass2]);
1105 return (nodeClassName1 < nodeClassName2);
1110 bool nodeClass2IsTypecast = nodeClass2->getBase()->isTypecastNodeClass();
1111 if (nodeClass1IsTypecast && !nodeClass2IsTypecast)
1113 else if (nodeClass2IsTypecast && !nodeClass1IsTypecast)
1117 int nodeClass1Frequency = nodeClassFrequency[nodeClassName1];
1118 int nodeClass2Frequency = nodeClassFrequency[nodeClassName2];
1120 return ((nodeClass1Frequency > nodeClass2Frequency) ||
1121 ((nodeClass1Frequency == nodeClass2Frequency) && (nodeClassName1 < nodeClassName2)));
1131 loadedNodeClasses.clear();
1135 releaseNodePopovers();
1148 const vector<VuoCompilerNodeClass *> &nodeClassesToAdd)
1150 if (nodeClassesToRemove.size() >= 1)
1154 releaseNodePopovers();
1158 for (
int i = loadedNodeClasses.size() - 1; i >= 0; --i)
1160 string nodeClassName = loadedNodeClasses[i]->getBase()->getClassName();
1161 if (std::find(nodeClassesToRemove.begin(), nodeClassesToRemove.end(), nodeClassName) != nodeClassesToRemove.end())
1162 loadedNodeClasses.erase(loadedNodeClasses.begin() + i);
1166 vector<VuoCompilerNodeClass *> nodeClassesToAddCopy = nodeClassesToAdd;
1169 if (std::find(loadedNodeClasses.begin(), loadedNodeClasses.end(), nodeClassToAdd) == loadedNodeClasses.end())
1170 loadedNodeClasses.push_back(nodeClassToAdd);
1172 recordNodeClassCapitalizations();
1177 bool clearFilterText =
false;
1178 if (clearFilterText)
1181 disconnect(ui->textFilter, &QLineEdit::textChanged,
this, &VuoNodeLibrary::updateListViewForNewFilterTextOnTimer);
1183 ui->textFilter->setText(
"");
1186 connect(ui->textFilter, &QLineEdit::textChanged,
this, &VuoNodeLibrary::updateListViewForNewFilterTextOnTimer);
1190 ui->nodeClassList->disablePopovers();
1191 updateListView(
false);
1192 ui->nodeClassList->enablePopovers();
1195 if (nodeClassesToRemove.size() >= 1)
1214 bool searchDone = targetNodeClassName.empty();
1215 for (
int i = 0; i < ui->nodeClassList->count() && !searchDone; ++i)
1217 QListWidgetItem *currentItem = ui->nodeClassList->item(i);
1219 if (currentNodeClassName == targetNodeClassName)
1221 ui->nodeClassList->setCurrentItem(currentItem);
1222 currentItem->setSelected(
true);
1227 if (resetPreviousSelection)
1230 for (
int i = 0; i < ui->nodeClassList->count(); ++i)
1232 QListWidgetItem *currentItem = ui->nodeClassList->item(i);
1234 if (currentNodeClassName != targetNodeClassName)
1235 currentItem->setSelected(
false);
1239 ui->nodeClassList->update();
1241 if (highlightAsNewlyInstalled)
1242 newlyInstalledNodeClasses[compiler->
getNodeClass(targetNodeClassName)] = newlyInstalledNodeClasses.size();
1244 updateListView(
false);
1252void VuoNodeLibrary::populateNodeClassFrequencyMap()
1254#include "VuoNodeClassFrequencyMap.hh"
1260void VuoNodeLibrary::populateStopWordList()
1262 stopWords.insert(
"a");
1263 stopWords.insert(
"an");
1264 stopWords.insert(
"for");
1265 stopWords.insert(
"from");
1266 stopWords.insert(
"in");
1267 stopWords.insert(
"on");
1268 stopWords.insert(
"of");
1269 stopWords.insert(
"the");
1270 stopWords.insert(
"to");
1271 stopWords.insert(
"with");
1279 return (stopWords.find(word.toLower().toUtf8().constData()) != stopWords.end());
1282void VuoNodeLibrary::releaseNodePopovers()
1286 for (
auto i : popoverForNodeClass)
1287 i.second->cleanup();
1290 popoverForNodeClass.clear();
1296void VuoNodeLibrary::updateColor(
bool isDark)
1298 QString titleTextColor = isDark ?
"#303030" :
"#808080";
1299 QString titleBackgroundColor = isDark ?
"#919191" :
"#efefef";
1300 QString dockwidgetBackgroundColor = isDark ?
"#505050" :
"#efefef";
1301 QString listBackgroundColor = isDark ?
"#262626" :
"#ffffff";
1302 QString scrollBarColor = isDark ?
"#505050" :
"#dfdfdf";
1303 QString focusRingColor = isDark ?
"#1d6ae5" :
"#74acec";
1305 setStyleSheet(VUO_QSTRINGIFY(
1307 titlebar-close-icon: url(:/Icons/dockwidget-close-%3.png);
1312 QDockWidget::title {
1315 background-color: %2;
1319 QDockWidget::float-button {
1324 .arg(titleTextColor)
1325 .arg(titleBackgroundColor)
1326 .arg(isDark ?
"dark" :
"light")
1329 ui->splitter->setStyleSheet(VUO_QSTRINGIFY(
1331 background: transparent;
1335 background-color: %1;
1338 .arg(dockwidgetBackgroundColor)
1342 QString nodeClassListStyle = VUO_QSTRINGIFY(
1347 border: 1px solid %1;
1349 margin: 3px 2px 0 3px;
1354 border: 2px solid %3;
1357 QAbstractScrollArea::corner {
1361 .arg(dockwidgetBackgroundColor)
1362 .arg(listBackgroundColor)
1363 .arg(focusRingColor);
1366 nodeClassListStyle += VUO_QSTRINGIFY(
1368 background: transparent;
1372 QScrollBar::handle {
1379 QAbstractScrollArea::corner,
1380 QScrollBar::add-line,
1381 QScrollBar::sub-line,
1382 QScrollBar::add-page,
1383 QScrollBar::sub-page {
1384 background: transparent;
1388 .arg(scrollBarColor);
1390 ui->nodeClassList->setStyleSheet(nodeClassListStyle);
1393 QString nodePopoverPaneStyle = VUO_QSTRINGIFY(
1399 margin: 0 2px 3px 3px;
1402 .arg(listBackgroundColor);
1405 nodePopoverPaneStyle += VUO_QSTRINGIFY(
1407 background: transparent;
1411 QScrollBar::handle {
1418 QAbstractScrollArea::corner,
1419 QScrollBar::add-line,
1420 QScrollBar::sub-line,
1421 QScrollBar::add-page,
1422 QScrollBar::sub-page {
1423 background: transparent;
1427 .arg(scrollBarColor);
1429 ui->nodePopoverPane->setStyleSheet(nodePopoverPaneStyle);
1435 setWindowFlags(windowFlags() | Qt::Dialog);
1437 id nsView = (id)winId();
1438 id nsWindow = ((id (*)(id, SEL))objc_msgSend)(nsView, sel_getUid(
"window"));
1439 unsigned long styleMask = 0;
1440 styleMask |= 1 << 0;
1441 styleMask |= 1 << 1;
1442 styleMask |= 1 << 3;
1443 styleMask |= 1 << 4;
1445 styleMask |= 1 << 13;
1446 ((void (*)(id, SEL,
unsigned long))objc_msgSend)(nsWindow, sel_getUid(
"setStyleMask:"), styleMask);
1449 ((void (*)(id, SEL,
BOOL))objc_msgSend)(nsWindow, sel_getUid(
"setMovableByWindowBackground:"), NO);