GlslEditor: Remove duplicated icons

This change makes GlslCompletionAssist reuse the equivalent icons
from CPlusPlus, and adds specific ones for "Attribute", "Uniform"
and "Varying".

Change-Id: Ic8860274a9f421d28cfec86ed0d1badb7e1cf92e
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
This commit is contained in:
Alessandro Portale
2016-04-06 23:16:17 +02:00
parent 01f4e4a8c6
commit 0788ec7f48
16 changed files with 77 additions and 41 deletions

View File

@@ -78,6 +78,9 @@ IconsCodeModelFunctionColor=ffd34373
IconsCodeModelVariableColor=ff2bbbcc IconsCodeModelVariableColor=ff2bbbcc
IconsCodeModelEnumColor=ffc0b550 IconsCodeModelEnumColor=ffc0b550
IconsCodeModelMacroColor=ff477ba0 IconsCodeModelMacroColor=ff477ba0
IconsCodeModelAttributeColor=ff316511
IconsCodeModelUniformColor=ff994899
IconsCodeModelVaryingColor=ffa08833
IconsCodeModelOverlayBackgroundColor=88000000 IconsCodeModelOverlayBackgroundColor=88000000
IconsCodeModelOverlayForegroundColor=ffdcdcdc IconsCodeModelOverlayForegroundColor=ffdcdcdc
InfoBarBackground=ff505000 InfoBarBackground=ff505000

View File

@@ -72,6 +72,9 @@ IconsCodeModelFunctionColor=fff36393
IconsCodeModelVariableColor=ff2bbbcc IconsCodeModelVariableColor=ff2bbbcc
IconsCodeModelEnumColor=ffc0b550 IconsCodeModelEnumColor=ffc0b550
IconsCodeModelMacroColor=ff476ba0 IconsCodeModelMacroColor=ff476ba0
IconsCodeModelAttributeColor=ff316511
IconsCodeModelUniformColor=ff994899
IconsCodeModelVaryingColor=ffa08833
IconsCodeModelOverlayBackgroundColor=70ffffff IconsCodeModelOverlayBackgroundColor=70ffffff
IconsCodeModelOverlayForegroundColor=ff232425 IconsCodeModelOverlayForegroundColor=ff232425
InfoBarBackground=ffffffe1 InfoBarBackground=ffffffe1

View File

@@ -82,6 +82,9 @@ IconsCodeModelFunctionColor=ffd34373
IconsCodeModelVariableColor=ff2bbbcc IconsCodeModelVariableColor=ff2bbbcc
IconsCodeModelEnumColor=ffc0b550 IconsCodeModelEnumColor=ffc0b550
IconsCodeModelMacroColor=ff476ba0 IconsCodeModelMacroColor=ff476ba0
IconsCodeModelAttributeColor=ff316511
IconsCodeModelUniformColor=ff994899
IconsCodeModelVaryingColor=ffa08833
IconsCodeModelOverlayBackgroundColor=70ffffff IconsCodeModelOverlayBackgroundColor=70ffffff
IconsCodeModelOverlayForegroundColor=ff232425 IconsCodeModelOverlayForegroundColor=ff232425
InfoBarBackground=ffffffe1 InfoBarBackground=ffffffe1

View File

@@ -160,6 +160,9 @@ public:
IconsCodeModelVariableColor, IconsCodeModelVariableColor,
IconsCodeModelEnumColor, IconsCodeModelEnumColor,
IconsCodeModelMacroColor, IconsCodeModelMacroColor,
IconsCodeModelAttributeColor,
IconsCodeModelUniformColor,
IconsCodeModelVaryingColor,
IconsCodeModelOverlayBackgroundColor, IconsCodeModelOverlayBackgroundColor,
IconsCodeModelOverlayForegroundColor, IconsCodeModelOverlayForegroundColor,

View File

@@ -41,7 +41,9 @@
#include <texteditor/codeassist/genericproposal.h> #include <texteditor/codeassist/genericproposal.h>
#include <texteditor/codeassist/functionhintproposal.h> #include <texteditor/codeassist/functionhintproposal.h>
#include <cplusplus/ExpressionUnderCursor.h> #include <cplusplus/ExpressionUnderCursor.h>
#include <cplusplus/Icons.h>
#include <utils/icon.h>
#include <utils/faketooltip.h> #include <utils/faketooltip.h>
#include <QIcon> #include <QIcon>
@@ -138,6 +140,57 @@ static bool checkStartOfIdentifier(const QString &word)
return false; return false;
} }
enum IconTypes {
IconTypeAttribute,
IconTypeUniform,
IconTypeKeyword,
IconTypeVarying,
IconTypeConst,
IconTypeVariable,
IconTypeType,
IconTypeFunction,
IconTypeOther
};
static QIcon glslIcon(IconTypes iconType)
{
using namespace CPlusPlus;
using namespace Utils;
const QString member = QLatin1String(":/codemodel/images/member.png");
switch (iconType) {
case IconTypeType:
return Icons::iconForType(Icons::ClassIconType);
case IconTypeConst:
return Icons::iconForType(Icons::EnumeratorIconType);
case IconTypeKeyword:
return Icons::iconForType(Icons::KeywordIconType);
case IconTypeFunction:
return Icons::iconForType(Icons::FuncPublicIconType);
case IconTypeVariable:
return Icons::iconForType(Icons::VarPublicIconType);
case IconTypeAttribute: {
static const QIcon icon =
Icon({{member, Theme::IconsCodeModelAttributeColor}}, Icon::Tint).icon();
return icon;
}
case IconTypeUniform: {
static const QIcon icon =
Icon({{member, Theme::IconsCodeModelUniformColor}}, Icon::Tint).icon();
return icon;
}
case IconTypeVarying: {
static const QIcon icon =
Icon({{member, Theme::IconsCodeModelVaryingColor}}, Icon::Tint).icon();
return icon;
}
case IconTypeOther:
default:
return Icons::iconForType(Icons::NamespaceIconType);
}
}
// ---------------------------- // ----------------------------
// GlslCompletionAssistProvider // GlslCompletionAssistProvider
// ---------------------------- // ----------------------------
@@ -223,15 +276,6 @@ int GlslFunctionHintProposalModel::activeArgument(const QString &prefix) const
// ----------------------------- // -----------------------------
GlslCompletionAssistProcessor::GlslCompletionAssistProcessor() GlslCompletionAssistProcessor::GlslCompletionAssistProcessor()
: m_startPosition(0) : m_startPosition(0)
, m_keywordIcon(QLatin1String(":/glsleditor/images/keyword.png"))
, m_varIcon(QLatin1String(":/glsleditor/images/var.png"))
, m_functionIcon(QLatin1String(":/glsleditor/images/func.png"))
, m_typeIcon(QLatin1String(":/glsleditor/images/type.png"))
, m_constIcon(QLatin1String(":/glsleditor/images/const.png"))
, m_attributeIcon(QLatin1String(":/glsleditor/images/attribute.png"))
, m_uniformIcon(QLatin1String(":/glsleditor/images/uniform.png"))
, m_varyingIcon(QLatin1String(":/glsleditor/images/varying.png"))
, m_otherIcon(QLatin1String(":/glsleditor/images/other.png"))
{} {}
GlslCompletionAssistProcessor::~GlslCompletionAssistProcessor() GlslCompletionAssistProcessor::~GlslCompletionAssistProcessor()
@@ -385,9 +429,9 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i
0 0
}; };
for (int index = 0; attributeNames[index]; ++index) for (int index = 0; attributeNames[index]; ++index)
m_completions << createCompletionItem(QString::fromLatin1(attributeNames[index]), m_attributeIcon); m_completions << createCompletionItem(QString::fromLatin1(attributeNames[index]), glslIcon(IconTypeAttribute));
for (int index = 0; uniformNames[index]; ++index) for (int index = 0; uniformNames[index]; ++index)
m_completions << createCompletionItem(QString::fromLatin1(uniformNames[index]), m_uniformIcon); m_completions << createCompletionItem(QString::fromLatin1(uniformNames[index]), glslIcon(IconTypeUniform));
} }
} }
@@ -395,7 +439,7 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i
QStringList keywords = GLSL::Lexer::keywords(languageVariant(m_interface->mimeType())); QStringList keywords = GLSL::Lexer::keywords(languageVariant(m_interface->mimeType()));
// m_keywordCompletions.clear(); // m_keywordCompletions.clear();
for (int index = 0; index < keywords.size(); ++index) for (int index = 0; index < keywords.size(); ++index)
m_completions << createCompletionItem(keywords.at(index), m_keywordIcon); m_completions << createCompletionItem(keywords.at(index), glslIcon(IconTypeKeyword));
// m_keywordVariant = languageVariant(m_interface->mimeType()); // m_keywordVariant = languageVariant(m_interface->mimeType());
// } // }
@@ -408,23 +452,23 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i
if (var) { if (var) {
int storageType = var->qualifiers() & GLSL::QualifiedTypeAST::StorageMask; int storageType = var->qualifiers() & GLSL::QualifiedTypeAST::StorageMask;
if (storageType == GLSL::QualifiedTypeAST::Attribute) if (storageType == GLSL::QualifiedTypeAST::Attribute)
icon = m_attributeIcon; icon = glslIcon(IconTypeAttribute);
else if (storageType == GLSL::QualifiedTypeAST::Uniform) else if (storageType == GLSL::QualifiedTypeAST::Uniform)
icon = m_uniformIcon; icon = glslIcon(IconTypeUniform);
else if (storageType == GLSL::QualifiedTypeAST::Varying) else if (storageType == GLSL::QualifiedTypeAST::Varying)
icon = m_varyingIcon; icon = glslIcon(IconTypeVarying);
else if (storageType == GLSL::QualifiedTypeAST::Const) else if (storageType == GLSL::QualifiedTypeAST::Const)
icon = m_constIcon; icon = glslIcon(IconTypeConst);
else else
icon = m_varIcon; icon = glslIcon(IconTypeVariable);
} else if (s->asArgument()) { } else if (s->asArgument()) {
icon = m_varIcon; icon = glslIcon(IconTypeVariable);
} else if (s->asFunction() || s->asOverloadSet()) { } else if (s->asFunction() || s->asOverloadSet()) {
icon = m_functionIcon; icon = glslIcon(IconTypeFunction);
} else if (s->asStruct()) { } else if (s->asStruct()) {
icon = m_typeIcon; icon = glslIcon(IconTypeType);
} else { } else {
icon = m_otherIcon; icon = glslIcon(IconTypeOther);
} }
if (specialMembers.contains(s->name())) if (specialMembers.contains(s->name()))
m_completions << createCompletionItem(s->name(), icon, SpecialMemberOrder); m_completions << createCompletionItem(s->name(), icon, SpecialMemberOrder);

View File

@@ -34,7 +34,6 @@
#include <texteditor/codeassist/ifunctionhintproposalmodel.h> #include <texteditor/codeassist/ifunctionhintproposalmodel.h>
#include <QIcon>
#include <QScopedPointer> #include <QScopedPointer>
#include <QSharedPointer> #include <QSharedPointer>
@@ -107,16 +106,6 @@ private:
int m_startPosition; int m_startPosition;
QScopedPointer<const GlslCompletionAssistInterface> m_interface; QScopedPointer<const GlslCompletionAssistInterface> m_interface;
QIcon m_keywordIcon;
QIcon m_varIcon;
QIcon m_functionIcon;
QIcon m_typeIcon;
QIcon m_constIcon;
QIcon m_attributeIcon;
QIcon m_uniformIcon;
QIcon m_varyingIcon;
QIcon m_otherIcon;
}; };
class GlslCompletionAssistInterface : public TextEditor::AssistInterface class GlslCompletionAssistInterface : public TextEditor::AssistInterface

View File

@@ -2,14 +2,5 @@
<qresource prefix="/glsleditor"> <qresource prefix="/glsleditor">
<file>GLSLEditor.mimetypes.xml</file> <file>GLSLEditor.mimetypes.xml</file>
<file>images/glslfile.png</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/const.png</file>
<file>images/attribute.png</file>
<file>images/uniform.png</file>
<file>images/varying.png</file>
<file>images/other.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B