Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
ecf4baec
Commit
ecf4baec
authored
Dec 01, 2010
by
Rhys Weatherley
Browse files
Better icons for the GLSL code completer
parent
9af44368
Changes
14
Hide whitespace changes
Inline
Side-by-side
src/libs/glsl/glslsymbol.cpp
View file @
ecf4baec
...
...
@@ -76,7 +76,7 @@ Symbol *Scope::lookup(const QString &name) const
return
0
;
}
Q
StringList
Scope
::
members
()
const
Q
List
<
Symbol
*>
Scope
::
members
()
const
{
return
Q
StringList
();
return
Q
List
<
Symbol
*>
();
}
src/libs/glsl/glslsymbol.h
View file @
ecf4baec
...
...
@@ -73,7 +73,7 @@ public:
Symbol
*
lookup
(
const
QString
&
name
)
const
;
virtual
Q
StringList
members
()
const
;
virtual
Q
List
<
Symbol
*>
members
()
const
;
virtual
void
add
(
Symbol
*
symbol
)
=
0
;
virtual
Symbol
*
find
(
const
QString
&
name
)
const
=
0
;
...
...
src/libs/glsl/glslsymbols.cpp
View file @
ecf4baec
...
...
@@ -54,9 +54,9 @@ Block::Block(Scope *enclosingScope)
{
}
Q
StringList
Block
::
members
()
const
Q
List
<
Symbol
*>
Block
::
members
()
const
{
return
_members
.
key
s
();
return
_members
.
value
s
();
}
void
Block
::
add
(
Symbol
*
symbol
)
...
...
@@ -100,9 +100,9 @@ Namespace::~Namespace()
qDeleteAll
(
_overloadSets
);
}
Q
StringList
Namespace
::
members
()
const
Q
List
<
Symbol
*>
Namespace
::
members
()
const
{
return
_members
.
key
s
();
return
_members
.
value
s
();
}
void
Namespace
::
add
(
Symbol
*
symbol
)
...
...
@@ -116,6 +116,7 @@ void Namespace::add(Symbol *symbol)
}
else
if
(
Function
*
firstFunction
=
sym
->
asFunction
())
{
OverloadSet
*
o
=
new
OverloadSet
(
this
);
_overloadSets
.
append
(
o
);
o
->
setName
(
symbol
->
name
());
o
->
addFunction
(
firstFunction
);
o
->
addFunction
(
fun
);
sym
=
o
;
...
...
src/libs/glsl/glslsymbols.h
View file @
ecf4baec
...
...
@@ -70,7 +70,7 @@ class GLSL_EXPORT Block: public Scope
public:
Block
(
Scope
*
enclosingScope
=
0
);
virtual
Q
StringList
members
()
const
;
virtual
Q
List
<
Symbol
*>
members
()
const
;
virtual
void
add
(
Symbol
*
symbol
);
virtual
Block
*
asBlock
()
{
return
this
;
}
...
...
@@ -92,7 +92,7 @@ public:
virtual
Namespace
*
asNamespace
()
{
return
this
;
}
virtual
Q
StringList
members
()
const
;
virtual
Q
List
<
Symbol
*>
members
()
const
;
virtual
const
Type
*
type
()
const
;
virtual
Symbol
*
find
(
const
QString
&
name
)
const
;
...
...
src/libs/glsl/glsltypes.cpp
View file @
ecf4baec
...
...
@@ -331,12 +331,12 @@ bool ArrayType::isLessThan(const Type *other) const
return
elementType
()
<
array
->
elementType
();
}
Q
StringList
Struct
::
members
()
const
Q
List
<
Symbol
*>
Struct
::
members
()
const
{
Q
StringList
m
;
Q
List
<
Symbol
*>
m
;
foreach
(
Symbol
*
s
,
_members
)
{
if
(
!
s
->
name
().
isEmpty
())
m
.
append
(
s
->
name
()
);
m
.
append
(
s
);
}
return
m
;
}
...
...
@@ -438,12 +438,12 @@ bool Function::isLessThan(const Type *other) const
return
false
;
}
Q
StringList
Function
::
members
()
const
Q
List
<
Symbol
*>
Function
::
members
()
const
{
Q
StringList
m
;
Q
List
<
Symbol
*>
m
;
foreach
(
Argument
*
arg
,
_arguments
)
{
if
(
!
arg
->
name
().
isEmpty
())
m
.
append
(
arg
->
name
()
);
m
.
append
(
arg
);
}
return
m
;
}
...
...
src/libs/glsl/glsltypes.h
View file @
ecf4baec
...
...
@@ -131,7 +131,7 @@ public:
const
Type
*
elementType
()
const
{
return
indexElementType
();
}
int
dimension
()
const
{
return
_dimension
;
}
Q
StringList
members
()
const
{
return
_members
.
key
s
();
}
Q
List
<
Symbol
*>
members
()
const
{
return
_members
.
value
s
();
}
virtual
void
add
(
Symbol
*
symbol
);
virtual
Symbol
*
find
(
const
QString
&
name
)
const
;
...
...
@@ -193,7 +193,7 @@ public:
Struct
(
Scope
*
scope
=
0
)
:
Scope
(
scope
)
{}
Q
StringList
members
()
const
;
Q
List
<
Symbol
*>
members
()
const
;
virtual
void
add
(
Symbol
*
member
);
virtual
Symbol
*
find
(
const
QString
&
name
)
const
;
...
...
@@ -238,7 +238,7 @@ public:
virtual
Symbol
*
find
(
const
QString
&
name
)
const
;
virtual
Q
StringList
members
()
const
;
virtual
Q
List
<
Symbol
*>
members
()
const
;
virtual
void
add
(
Symbol
*
symbol
)
{
if
(
!
symbol
)
return
;
...
...
src/plugins/glsleditor/glslcodecompletion.cpp
View file @
ecf4baec
...
...
@@ -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
);
}
...
...
src/plugins/glsleditor/glslcodecompletion.h
View file @
ecf4baec
...
...
@@ -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
...
...
src/plugins/glsleditor/glsleditor.qrc
View file @
ecf4baec
...
...
@@ -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>
src/plugins/glsleditor/images/func.png
0 → 100644
View file @
ecf4baec
583 Bytes
src/plugins/glsleditor/images/keyword.png
0 → 100644
View file @
ecf4baec
341 Bytes
src/plugins/glsleditor/images/other.png
0 → 100644
View file @
ecf4baec
377 Bytes
src/plugins/glsleditor/images/type.png
0 → 100644
View file @
ecf4baec
573 Bytes
src/plugins/glsleditor/images/var.png
0 → 100644
View file @
ecf4baec
530 Bytes
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment