diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-12-01 14:00:30 +1000 |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-12-01 14:57:14 +1000 |
commit | ecf4baec663e5c2368056a6a79efa7078719026c (patch) | |
tree | 0cfc9ccfdb711cf2224daf3e5a82f00d836c9dfe /src/plugins/glsleditor | |
parent | 9af4436875df8c1f8c5916c702ee15d237105710 (diff) | |
download | qt-creator-ecf4baec663e5c2368056a6a79efa7078719026c.tar.gz |
Better icons for the GLSL code completer
Diffstat (limited to 'src/plugins/glsleditor')
-rw-r--r-- | src/plugins/glsleditor/glslcodecompletion.cpp | 58 | ||||
-rw-r--r-- | src/plugins/glsleditor/glslcodecompletion.h | 5 | ||||
-rw-r--r-- | src/plugins/glsleditor/glsleditor.qrc | 5 | ||||
-rw-r--r-- | src/plugins/glsleditor/images/func.png | bin | 0 -> 583 bytes | |||
-rw-r--r-- | src/plugins/glsleditor/images/keyword.png | bin | 0 -> 341 bytes | |||
-rw-r--r-- | src/plugins/glsleditor/images/other.png | bin | 0 -> 377 bytes | |||
-rw-r--r-- | src/plugins/glsleditor/images/type.png | bin | 0 -> 573 bytes | |||
-rw-r--r-- | src/plugins/glsleditor/images/var.png | bin | 0 -> 530 bytes |
8 files changed, 28 insertions, 40 deletions
diff --git a/src/plugins/glsleditor/glslcodecompletion.cpp b/src/plugins/glsleditor/glslcodecompletion.cpp index 9ae1505918..ff89180275 100644 --- a/src/plugins/glsleditor/glslcodecompletion.cpp +++ b/src/plugins/glsleditor/glslcodecompletion.cpp @@ -95,37 +95,6 @@ static bool checkStartOfIdentifier(const QString &word) return false; } -// Temporary workaround until we have proper icons for QML completion items -static QIcon iconForColor(const QColor &color) -{ - QPixmap pix(6, 6); - - int pixSize = 20; - QBrush br(color); - - QPixmap pm(2 * pixSize, 2 * pixSize); - QPainter pmp(&pm); - pmp.fillRect(0, 0, pixSize, pixSize, Qt::lightGray); - pmp.fillRect(pixSize, pixSize, pixSize, pixSize, Qt::lightGray); - pmp.fillRect(0, pixSize, pixSize, pixSize, Qt::darkGray); - pmp.fillRect(pixSize, 0, pixSize, pixSize, Qt::darkGray); - pmp.fillRect(0, 0, 2 * pixSize, 2 * pixSize, color); - br = QBrush(pm); - - QPainter p(&pix); - int corr = 1; - QRect r = pix.rect().adjusted(corr, corr, -corr, -corr); - p.setBrushOrigin((r.width() % pixSize + pixSize) / 2 + corr, (r.height() % pixSize + pixSize) / 2 + corr); - p.fillRect(r, br); - - p.fillRect(r.width() / 4 + corr, r.height() / 4 + corr, - r.width() / 2, r.height() / 2, - QColor(color.rgb())); - p.drawRect(pix.rect().adjusted(0, 0, -1, -1)); - - return pix; -} - static const char *glsl_keywords[] = { // ### TODO: get the keywords from the lexer "attribute", @@ -519,9 +488,13 @@ CodeCompletion::CodeCompletion(QObject *parent) : ICompletionCollector(parent), m_editor(0), m_startPosition(-1), - m_restartCompletion(false) + m_restartCompletion(false), + m_varIcon(":/glsleditor/images/var.png"), + m_functionIcon(":/glsleditor/images/func.png"), + m_typeIcon(":/glsleditor/images/type.png"), + m_otherIcon(":/glsleditor/images/other.png") { - const QIcon keywordIcon = iconForColor(Qt::darkYellow); + const QIcon keywordIcon(QLatin1String(":/glsleditor/images/keyword.png")); for (const char **it = glsl_keywords; *it; ++it) { TextEditor::CompletionItem item(this); item.text = QString::fromLatin1(*it); @@ -599,9 +572,7 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor) CPlusPlus::ExpressionUnderCursor expressionUnderCursor; GLSLTextEditor *edit = qobject_cast<GLSLTextEditor *>(editor->widget()); - const QIcon symbolIcon = iconForColor(Qt::darkCyan); - - QStringList members; + QList<GLSL::Symbol *> members; QStringList specialMembers; bool functionCall = (ch == QLatin1Char('(') && pos == editor->position() - 1); @@ -705,11 +676,18 @@ int CodeCompletion::startCompletion(TextEditor::ITextEditable *editor) m_completions += m_keywordCompletions; } - foreach (const QString &s, members) { + foreach (GLSL::Symbol *s, members) { TextEditor::CompletionItem item(this); - item.icon = symbolIcon; - item.text = s; - if (specialMembers.contains(s)) + if (s->asVariable() || s->asArgument()) + item.icon = m_varIcon; + else if (s->asFunction() || s->asOverloadSet()) + item.icon = m_functionIcon; + else if (s->asStruct()) + item.icon = m_typeIcon; + else + item.icon = m_otherIcon; + item.text = s->name(); + if (specialMembers.contains(item.text)) item.order = SpecialMemberOrder; m_completions.append(item); } diff --git a/src/plugins/glsleditor/glslcodecompletion.h b/src/plugins/glsleditor/glslcodecompletion.h index d3b110f131..f8110bcffc 100644 --- a/src/plugins/glsleditor/glslcodecompletion.h +++ b/src/plugins/glsleditor/glslcodecompletion.h @@ -106,6 +106,11 @@ private: QPointer<FunctionArgumentWidget> m_functionArgumentWidget; static bool glslCompletionItemLessThan(const TextEditor::CompletionItem &l, const TextEditor::CompletionItem &r); + + QIcon m_varIcon; + QIcon m_functionIcon; + QIcon m_typeIcon; + QIcon m_otherIcon; }; } // namespace Internal diff --git a/src/plugins/glsleditor/glsleditor.qrc b/src/plugins/glsleditor/glsleditor.qrc index cb1c737c9a..4003791125 100644 --- a/src/plugins/glsleditor/glsleditor.qrc +++ b/src/plugins/glsleditor/glsleditor.qrc @@ -2,5 +2,10 @@ <qresource prefix="/glsleditor"> <file>GLSLEditor.mimetypes.xml</file> <file>images/glslfile.png</file> + <file>images/keyword.png</file> + <file>images/var.png</file> + <file>images/func.png</file> + <file>images/type.png</file> + <file>images/other.png</file> </qresource> </RCC> diff --git a/src/plugins/glsleditor/images/func.png b/src/plugins/glsleditor/images/func.png Binary files differnew file mode 100644 index 0000000000..e515e76e61 --- /dev/null +++ b/src/plugins/glsleditor/images/func.png diff --git a/src/plugins/glsleditor/images/keyword.png b/src/plugins/glsleditor/images/keyword.png Binary files differnew file mode 100644 index 0000000000..e5a51858d9 --- /dev/null +++ b/src/plugins/glsleditor/images/keyword.png diff --git a/src/plugins/glsleditor/images/other.png b/src/plugins/glsleditor/images/other.png Binary files differnew file mode 100644 index 0000000000..18d2941572 --- /dev/null +++ b/src/plugins/glsleditor/images/other.png diff --git a/src/plugins/glsleditor/images/type.png b/src/plugins/glsleditor/images/type.png Binary files differnew file mode 100644 index 0000000000..88432d2cb1 --- /dev/null +++ b/src/plugins/glsleditor/images/type.png diff --git a/src/plugins/glsleditor/images/var.png b/src/plugins/glsleditor/images/var.png Binary files differnew file mode 100644 index 0000000000..089cfb45e5 --- /dev/null +++ b/src/plugins/glsleditor/images/var.png |