ui: extended color scheme and added new color scheme bad_rainbow

* added color scheme template
* define fill, border, text, icon and hatching colors for each node with states normal and focus
* define colors for each edge with states normal and focus
* use default node and edge colors when no type specific ones are defined
* use normal colors for nodes and edges when no focused are defined
* allow nodes and edges to imitate look of others with "like" tag
* added style for bundle
* added style for count circle
This commit is contained in:
Eberhard Graether
2015-11-20 15:24:20 +01:00
parent 9f0df1bcee
commit f5f4eed509
17 changed files with 997 additions and 284 deletions
+241
View File
@@ -0,0 +1,241 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
COLOR:
1. HEX RGB: #RRGGBB - e.g. #00FF00
2. HEX ARGB: #AARRGGBB - e.g. #5500FF00
3. Qt5 color name - e.g. white (http://doc.qt.io/qt-5/qcolor.html)
-->
<config>
<search>
<background></background>
<button>
<normal></normal>
<hover></hover>
<press></press>
<disabled></disabled>
<icon></icon>
</button>
<field>
<text></text>
<background></background>
<highlight></highlight>
</field>
<popup>
<text></text>
<by_text></by_text>
<background></background>
<highlight></highlight>
</popup>
<query>
<none>
<normal></normal>
<hover></hover>
</none>
<command>
<normal></normal>
<hover></hover>
</command>
<operator>
<normal></normal>
<hover></hover>
</operator>
</query>
</search>
<code>
<background></background>
<file>
<background></background>
<title>
<text></text>
<normal></normal>
<hover></hover>
<press></press>
<icon></icon>
</title>
<ref_count>
<text></text>
<background></background>
</ref_count>
</file>
<snippet>
<background></background>
<title>
<text></text>
<background></background>
<hover></hover>
</title>
<line_number>
<text></text>
<background></background>
</line_number>
<syntax>
<normal></normal>
<directive></directive>
<keyword></keyword>
<type></type>
<comment></comment>
<number></number>
<quotation></quotation>
<function></function>
</syntax>
<selection>
<location>
<normal>
<border></border>
<fill></fill>
</normal>
<focus>
<border></border>
<fill></fill>
</focus>
<active>
<border></border>
<fill></fill>
</active>
</location>
<scope>
<normal>
<border></border>
<fill></fill>
</normal>
<focus>
<border></border>
<fill></fill>
</focus>
<active>
<border></border>
<fill></fill>
</active>
</scope>
<error>
<normal>
<border></border>
<fill></fill>
</normal>
<focus>
<border></border>
<fill></fill>
</focus>
<active>
<border></border>
<fill></fill>
</active>
</error>
</selection>
</snippet>
</code>
<graph>
<background></background>
<node>
<!-- REQUIRED -->
<default>
<!-- NODE TEMPLATE-->
<like><!-- NODE TYPE NAME: Imitates the look of that node type. If defined all colors will be ignored --></like>
<fill>
<normal></normal>
<focus></focus> <!-- If not defined, the normal tag is used -->
</fill>
<border>
<normal></normal>
<focus></focus> <!-- If not defined, the normal tag is used -->
</border>
<text>
<normal></normal>
<focus></focus> <!-- If not defined, the normal tag is used -->
</text>
<icon>
<normal></normal>
<focus></focus> <!-- If not defined, the normal tag is used -->
</icon>
<hatching>
<normal></normal>
<focus></focus> <!-- If not defined, the normal tag is used -->
</hatching>
</default>
<!-- OPTIONAL: type specific node colors can be overriden by using the TEMPLATE within a type tag below -->
<type></type>
<class></class>
<struct></struct>
<enum></enum>
<typedef></typedef>
<template_parameter_type></template_parameter_type>
<function></function>
<method></method>
<field></field>
<global_variable></global_variable>
<enum_constant></enum_constant>
<undefined></undefined>
<namespace></namespace>
<file></file>
<macro></macro>
<access></access>
<bundle></bundle>
<count_number></count_number> <!-- The small circles with numbers in the graph -->
</node>
<edge>
<!-- REQUIRED -->
<default>
<!-- EDGE TEMPLATE-->
<like><!-- EDGE TYPE NAME: Imitates the look of that edge type. If defined all colors will be ignored --></like>
<normal></normal>
<focus></focus> <!-- If not defined, the normal tag is used -->
</default>
<!-- OPTIONAL: type specific edge colors can be overriden by using the TEMPLATE within a type tag below -->
<type_of></type_of>
<return_type></return_type>
<parameter_type></parameter_type>
<type_use></type_use>
<inheritance></inheritance>
<typedef></typedef>
<override></override>
<call></call>
<use></use>
<template_parameter></template_parameter>
<template_argument></template_argument>
<template_default_argument></template_default_argument>
<template_specialization></template_specialization>
<include></include>
<macro_use></macro_use>
<aggregation></aggregation>
</edge>
</graph>
<tool_tip>
<text></text>
<background></background>
</tool_tip>
</config>
+323
View File
@@ -0,0 +1,323 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
<search>
<background>#494949</background>
<button>
<normal>#808080</normal>
<hover>#B1B1B1</hover>
<press>#CCCCCC</press>
<disabled>#606060</disabled>
<icon>white</icon>
</button>
<field>
<text>#3D3D3D</text>
<background>#808080</background>
<highlight>#B1B1B1</highlight>
</field>
<popup>
<text>#3D3D3D</text>
<by_text>#A0A0A0</by_text>
<background>#CCCCCC</background>
<highlight>#FFFFFF</highlight>
</popup>
<query>
<none>
<normal>#B1B1B1</normal>
<hover>#CCCCCC</hover>
</none>
<command>
<normal>#406D4D</normal>
<hover>#4E855E</hover>
</command>
<operator>
<normal>#7D2724</normal>
<hover>#8C2B29</hover>
</operator>
</query>
</search>
<code>
<background>#494949</background>
<file>
<background>#CCCCCC</background>
<title>
<text>black</text>
<normal>#CCCCCC</normal>
<hover>#BBBBBB</hover>
<press>#AAAAAA</press>
<icon>black</icon>
</title>
<ref_count>
<text>#C4C4C4</text>
<background>#494949</background>
</ref_count>
</file>
<snippet>
<background>#494949</background>
<title>
<text>#A0A0A0</text>
<background>transparent</background>
<hover>#2F2F2F</hover>
</title>
<line_number>
<text>#C4C4C4</text>
<background>#494949</background>
</line_number>
<syntax>
<normal>#C4C4C4</normal>
<directive>#00A0B6</directive>
<keyword>#00A0B6</keyword>
<type>#FF4A52</type>
<comment>#A0A0A4</comment>
<number>#EE7326</number>
<quotation>#D663D6</quotation>
<function>#FBBA00</function>
</syntax>
<selection>
<location>
<normal>
<border>transparent</border>
<fill>transparent</fill>
</normal>
<focus>
<border>#B2B2B2</border>
<fill>transparent</fill>
</focus>
<active>
<border>#B2B2B2</border>
<fill>#4A4A4A</fill>
</active>
</location>
<scope>
<normal>
<border>transparent</border>
<fill>transparent</fill>
</normal>
<focus>
<border>transparent</border>
<fill>transparent</fill>
</focus>
<active>
<border>transparent</border>
<fill>transparent</fill>
</active>
</scope>
<error>
<normal>
<border>transparent</border>
<fill>#A0FF0000</fill>
</normal>
<focus>
<border>transparent</border>
<fill>#FFFF0000</fill>
</focus>
<active>
<border>transparent</border>
<fill>#FFFF0000</fill>
</active>
</error>
</selection>
</snippet>
</code>
<graph>
<background>#494949</background>
<node>
<default>
<fill>
<normal>#807F80</normal>
</fill>
<border>
<normal>#FFFFFF</normal>
</border>
<text>
<normal>#3D3D3D</normal>
</text>
<icon>
<normal>#3D3D3D</normal>
</icon>
<hatching>
<normal>#494949</normal>
</hatching>
</default>
<type>
<border>
<normal>#20FFFFFF</normal>
<focus>#FFFFFF</focus>
</border>
<text>
<normal>#FFFFFF</normal>
</text>
<icon>
<normal>#FFFFFF</normal>
</icon>
</type>
<class>
<like>type</like>
</class>
<struct>
<like>type</like>
</struct>
<enum>
<like>type</like>
</enum>
<typedef>
<like>type</like>
</typedef>
<template_parameter_type>
<like>type</like>
</template_parameter_type>
<function>
<fill>
<normal>#FBBA00</normal>
<focus>#FFD05A</focus>
</fill>
<border>
<normal>transparent</normal>
<focus>#FFFFFF</focus>
</border>
</function>
<method>
<like>function</like>
</method>
<global_variable>
<fill>
<normal>#00A0B6</normal>
<focus>#3BAFB2</focus>
</fill>
<border>
<normal>transparent</normal>
<focus>#FFFFFF</focus>
</border>
</global_variable>
<field>
<like>global_variable</like>
</field>
<enum_constant>
<like>global_variable</like>
</enum_constant>
<undefined>
<fill>
<normal>#00000000</normal>
</fill>
<border>
<normal>#78282D</normal>
</border>
</undefined>
<namespace>
<like>undefined</like>
</namespace>
<file>
<fill>
<normal>#4E82F6</normal>
<focus>#7FA9F4</focus>
</fill>
<border>
<normal>#20FFFFFF</normal>
<focus>#FFFFFF</focus>
</border>
</file>
<macro>
<like>file</like>
</macro>
<access>
<fill>
<normal>#CCCCCC</normal>
</fill>
</access>
<bundle>
<fill>
<normal>#494949</normal>
</fill>
<border>
<normal>#80FFFFFF</normal>
<focus>#FFFFFF</focus>
</border>
<text>
<normal>#FFFFFF</normal>
</text>
<icon>
<normal>#FFFFFF</normal>
</icon>
</bundle>
<count_number>
<fill>
<normal>#494949</normal>
</fill>
<border>
<normal>#CCCCCC</normal>
</border>
<text>
<normal>#CCCCCC</normal>
</text>
</count_number>
</node>
<edge>
<default>
<normal>#797979</normal>
</default>
<override>
<normal>#CC5E89</normal>
</override>
<call>
<normal>#FBBA00</normal>
</call>
<use>
<normal>#2A6484</normal>
</use>
<template_parameter>
<normal>#C1305D</normal>
</template_parameter>
<template_argument>
<normal>#C1305D</normal>
</template_argument>
<template_default_argument>
<normal>#C1305D</normal>
</template_default_argument>
<template_specialization>
<normal>#C1305D</normal>
</template_specialization>
<include>
<normal>#4E82F6</normal>
</include>
<macro_use>
<normal>#4E82F6</normal>
</macro_use>
<aggregation>
<normal>#5D5D5D</normal>
<focus>#6D6D6D</focus>
</aggregation>
</edge>
</graph>
<tool_tip>
<text>#F7F7F7</text>
<background>#777777</background>
</tool_tip>
</config>
+97 -82
View File
@@ -134,154 +134,169 @@
</code> </code>
<graph> <graph>
<text>black</text>
<background>white</background> <background>white</background>
<border>#3C3C3C</border>
<icon>black</icon>
<hatching>white</hatching>
<node> <node>
<default>
<fill>
<normal>#ededed</normal>
</fill>
<border>
<normal>#3C3C3C</normal>
</border>
<text>
<normal>black</normal>
</text>
<icon>
<normal>black</normal>
</icon>
<hatching>
<normal>white</normal>
</hatching>
</default>
<type> <type>
<normal>#ededed</normal> <border>
<hover>#ededed</hover> <normal>#203C3C3C</normal>
<focus>#3C3C3C</focus>
</border>
</type> </type>
<class> <class>
<normal>#ededed</normal> <like>type</like>
<hover>#ededed</hover>
</class> </class>
<struct> <struct>
<normal>#ededed</normal> <like>type</like>
<hover>#ededed</hover>
</struct> </struct>
<enum> <enum>
<normal>#ededed</normal> <like>type</like>
<hover>#ededed</hover>
</enum> </enum>
<typedef> <typedef>
<normal>#ededed</normal> <like>type</like>
<hover>#ededed</hover>
</typedef> </typedef>
<template_parameter_type> <template_parameter_type>
<normal>#ededed</normal> <like>type</like>
<hover>#ededed</hover>
</template_parameter_type> </template_parameter_type>
<function> <function>
<normal>#F4D07D</normal> <fill>
<hover>#F4BC3D</hover> <normal>#F4D07D</normal>
<focus>#F4BC3D</focus>
</fill>
<border>
<normal>transparent</normal>
<focus>#3C3C3C</focus>
</border>
</function> </function>
<method> <method>
<normal>#F4D07D</normal> <like>function</like>
<hover>#F4BC3D</hover>
</method> </method>
<field>
<normal>#7BB5D4</normal>
<hover>#42A1D4</hover>
</field>
<global_variable> <global_variable>
<normal>#7BB5D4</normal> <fill>
<hover>#42A1D4</hover> <normal>#7BB5D4</normal>
<focus>#42A1D4</focus>
</fill>
<border>
<normal>transparent</normal>
<focus>#3C3C3C</focus>
</border>
</global_variable> </global_variable>
<field>
<like>global_variable</like>
</field>
<enum_constant> <enum_constant>
<normal>#7BB5D4</normal> <like>global_variable</like>
<hover>#42A1D4</hover>
</enum_constant> </enum_constant>
<undefined> <undefined>
<normal>#CC8D91</normal> <fill>
<hover>#CC8D91</hover> <normal>#00000000</normal>
</fill>
<border>
<normal>#CC8D91</normal>
</border>
</undefined> </undefined>
<namespace> <namespace>
<normal>#CC8D91</normal> <like>undefined</like>
<hover>#CC8D91</hover>
</namespace> </namespace>
<file> <file>
<normal>#DDD</normal> <fill>
<hover>#CCC</hover> <normal>#DDD</normal>
<focus>#CCC</focus>
</fill>
<border>
<normal>#203C3C3C</normal>
<focus>#3C3C3C</focus>
</border>
</file> </file>
<macro> <macro>
<normal>#DDD</normal> <like>file</like>
<hover>#CCC</hover>
</macro> </macro>
<access>
<fill>
<normal>white</normal>
</fill>
</access>
<bundle>
<fill>
<normal>white</normal>
</fill>
<border>
<normal>#803C3C3C</normal>
<focus>#3C3C3C</focus>
</border>
</bundle>
<count_number>
<fill>
<normal>white</normal>
</fill>
<border>
<normal>#7C7C7C</normal>
</border>
<text>
<normal>#5C5C5C</normal>
</text>
</count_number>
</node> </node>
<edge> <edge>
<type_of> <default>
<normal>#878787</normal> <normal>#878787</normal>
<hover>#878787</hover> </default>
</type_of>
<return_type>
<normal>#878787</normal>
<hover>#878787</hover>
</return_type>
<parameter_type>
<normal>#878787</normal>
<hover>#878787</hover>
</parameter_type>
<type_use>
<normal>#878787</normal>
<hover>#878787</hover>
</type_use>
<inheritance>
<normal>#878787</normal>
<hover>#878787</hover>
</inheritance>
<typedef>
<normal>#878787</normal>
<hover>#878787</hover>
</typedef>
<override> <override>
<normal>#CC5E89</normal> <normal>#CC5E89</normal>
<hover>#CC5E89</hover>
</override> </override>
<call> <call>
<normal>#F4BC3D</normal> <normal>#F4BC3D</normal>
<hover>#F4BC3D</hover>
</call> </call>
<use> <use>
<normal>#3190BA</normal> <normal>#3190BA</normal>
<hover>#3190BA</hover>
</use> </use>
<template_parameter> <template_parameter>
<normal>#C1305D</normal> <normal>#C1305D</normal>
<hover>#C1305D</hover>
</template_parameter> </template_parameter>
<template_argument> <template_argument>
<normal>#C1305D</normal> <like>template_parameter</like>
<hover>#C1305D</hover>
</template_argument> </template_argument>
<template_default_argument> <template_default_argument>
<normal>#C1305D</normal> <like>template_parameter</like>
<hover>#C1305D</hover>
</template_default_argument> </template_default_argument>
<template_specialization> <template_specialization>
<normal>#C1305D</normal> <like>template_parameter</like>
<hover>#C1305D</hover>
</template_specialization> </template_specialization>
<template_member_specialization> <template_member_specialization>
<normal>#C1305D</normal> <like>template_parameter</like>
<hover>#C1305D</hover>
</template_member_specialization> </template_member_specialization>
<include>
<normal>#878787</normal>
<hover>#878787</hover>
</include>
<aggregation> <aggregation>
<normal>#EEE</normal> <normal>#EEE</normal>
<hover>#DDD</hover> <focus>#DDD</focus>
</aggregation> </aggregation>
<macro_use>
<normal>#878787</normal>
<hover>#878787</hover>
</macro_use>
</edge> </edge>
</graph> </graph>
+111 -74
View File
@@ -134,154 +134,191 @@
</code> </code>
<graph> <graph>
<text>#F7F7F7</text>
<border>#C3C3C3</border>
<background>#272728</background> <background>#272728</background>
<icon>#F7F7F7</icon>
<hatching>#272728</hatching>
<node> <node>
<default>
<fill>
<normal>#4D4D4D</normal>
</fill>
<border>
<normal>#C3C3C3</normal>
</border>
<text>
<normal>#F7F7F7</normal>
</text>
<icon>
<normal>#F7F7F7</normal>
</icon>
<hatching>
<normal>#272728</normal>
</hatching>
</default>
<type> <type>
<normal>#4D4D4D</normal> <border>
<hover>#4D4D4D</hover> <normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</type> </type>
<class> <class>
<normal>#4D4D4D</normal> <border>
<hover>#4D4D4D</hover> <normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</class> </class>
<struct> <struct>
<normal>#4D4D4D</normal> <border>
<hover>#4D4D4D</hover> <normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</struct> </struct>
<enum> <enum>
<normal>#4D4D4D</normal> <border>
<hover>#4D4D4D</hover> <normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</enum> </enum>
<typedef> <typedef>
<normal>#4D4D4D</normal> <border>
<hover>#4D4D4D</hover> <normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</typedef> </typedef>
<template_parameter_type> <template_parameter_type>
<normal>#4D4D4D</normal> <border>
<hover>#4D4D4D</hover> <normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</template_parameter_type> </template_parameter_type>
<function> <function>
<normal>#7A681F</normal> <fill>
<hover>#9C8528</hover> <normal>#7A681F</normal>
<focus>#9C8528</focus>
</fill>
<border>
<normal>transparent</normal>
<focus>#C3C3C3</focus>
</border>
</function> </function>
<method> <method>
<normal>#7A681F</normal> <like>function</like>
<hover>#9C8528</hover>
</method> </method>
<field>
<normal>#21516B</normal>
<hover>#2A6484</hover>
</field>
<global_variable> <global_variable>
<normal>#21516B</normal> <fill>
<hover>#2A6484</hover> <normal>#21516B</normal>
<focus>#2A6484</focus>
</fill>
<border>
<normal>transparent</normal>
<focus>#C3C3C3</focus>
</border>
</global_variable> </global_variable>
<field>
<like>global_variable</like>
</field>
<enum_constant> <enum_constant>
<normal>#21516B</normal> <like>global_variable</like>>
<hover>#2A6484</hover>
</enum_constant> </enum_constant>
<undefined> <undefined>
<normal>#78282D</normal> <fill>
<hover>#78282D</hover> <normal>#00000000</normal>
</fill>
<border>
<normal>#78282D</normal>
</border>
</undefined> </undefined>
<namespace> <namespace>
<normal>#78282D</normal> <like>undefined</like>
<hover>#78282D</hover>
</namespace> </namespace>
<file> <file>
<normal>#1B564E</normal> <fill>
<hover>#247368</hover> <normal>#1B564E</normal>
<focus>#247368</focus>
</fill>
<border>
<normal>#20C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</file> </file>
<macro> <macro>
<normal>#1B564E</normal> <like>file</like>
<hover>#247368</hover>
</macro> </macro>
<access>
<fill>
<normal>#272728</normal>
</fill>
</access>
<bundle>
<fill>
<normal>#272728</normal>
</fill>
<border>
<normal>#80C3C3C3</normal>
<focus>#C3C3C3</focus>
</border>
</bundle>
<count_number>
<fill>
<normal>#272728</normal>
</fill>
<border>
<normal>#C3C3C3</normal>
</border>
<text>
<normal>#F7F7F7</normal>
</text>
</count_number>
</node> </node>
<edge> <edge>
<type_of> <default>
<normal>#797979</normal> <normal>#797979</normal>
<hover>#797979</hover> </default>
</type_of>
<return_type>
<normal>#797979</normal>
<hover>#797979</hover>
</return_type>
<parameter_type>
<normal>#797979</normal>
<hover>#797979</hover>
</parameter_type>
<type_use>
<normal>#797979</normal>
<hover>#797979</hover>
</type_use>
<inheritance>
<normal>#797979</normal>
<hover>#797979</hover>
</inheritance>
<typedef>
<normal>#797979</normal>
<hover>#797979</hover>
</typedef>
<override> <override>
<normal>#CC5E89</normal> <normal>#CC5E89</normal>
<hover>#CC5E89</hover>
</override> </override>
<call> <call>
<normal>#9C8528</normal> <normal>#9C8528</normal>
<hover>#9C8528</hover>
</call> </call>
<use> <use>
<normal>#2A6484</normal> <normal>#2A6484</normal>
<hover>#2A6484</hover>
</use> </use>
<template_parameter> <template_parameter>
<normal>#C1305D</normal> <normal>#C1305D</normal>
<hover>#C1305D</hover>
</template_parameter> </template_parameter>
<template_argument> <template_argument>
<normal>#C1305D</normal> <normal>#C1305D</normal>
<hover>#C1305D</hover>
</template_argument> </template_argument>
<template_default_argument> <template_default_argument>
<normal>#C1305D</normal> <normal>#C1305D</normal>
<hover>#C1305D</hover>
</template_default_argument> </template_default_argument>
<template_specialization> <template_specialization>
<normal>#C1305D</normal> <normal>#C1305D</normal>
<hover>#C1305D</hover>
</template_specialization> </template_specialization>
<template_member_specialization> <template_member_specialization>
<normal>#C1305D</normal> <normal>#C1305D</normal>
<hover>#C1305D</hover>
</template_member_specialization> </template_member_specialization>
<include> <include>
<normal>#247368</normal> <normal>#247368</normal>
<hover>#247368</hover>
</include> </include>
<macro_use>
<normal>#247368</normal>
</macro_use>
<aggregation> <aggregation>
<normal>#5D5D5D</normal> <normal>#5D5D5D</normal>
<hover>#6D6D6D</hover> <focus>#6D6D6D</focus>
</aggregation> </aggregation>
<macro_use>
<normal>#247368</normal>
<hover>#247368</hover>
</macro_use>
</edge> </edge>
</graph> </graph>
+2 -1
View File
@@ -3,6 +3,7 @@
#include <QPainter> #include <QPainter>
#include <QScrollBar> #include <QScrollBar>
#include "component/view/GraphViewStyle.h"
#include "settings/ApplicationSettings.h" #include "settings/ApplicationSettings.h"
#include "settings/ColorScheme.h" #include "settings/ColorScheme.h"
@@ -106,7 +107,7 @@ void QtAutocompletionDelegate::paint(QPainter* painter, const QStyleOptionViewIt
Node::NodeType nodeType = static_cast<Node::NodeType>(index.sibling(index.row(), index.column() + 3).data().toInt()); Node::NodeType nodeType = static_cast<Node::NodeType>(index.sibling(index.row(), index.column() + 3).data().toInt());
if (type.size()) if (type.size())
{ {
color = QColor(scheme->getNodeTypeColor(nodeType).c_str()); color = QColor(GraphViewStyle::getNodeColor(Node::getTypeString(nodeType), false).fill.c_str());
} }
else else
{ {
+10 -6
View File
@@ -13,6 +13,7 @@
#include "utility/utility.h" #include "utility/utility.h"
#include "utility/utilityString.h" #include "utility/utilityString.h"
#include "component/view/GraphViewStyle.h"
#include "qt/element/QtAutocompletionList.h" #include "qt/element/QtAutocompletionList.h"
#include "settings/ColorScheme.h" #include "settings/ColorScheme.h"
@@ -603,8 +604,7 @@ void QtSmartSearchBox::updateElements()
m_elements.clear(); m_elements.clear();
ColorScheme* scheme = ColorScheme::getInstance().get(); ColorScheme* scheme = ColorScheme::getInstance().get();
std::string searchTextColor = scheme->getColor("search/field/text");
std::string textColor = scheme->getColor("search/field/text");
for (const SearchMatch& match : m_matches) for (const SearchMatch& match : m_matches)
{ {
@@ -616,12 +616,16 @@ void QtSmartSearchBox::updateElements()
std::string color; std::string color;
std::string hoverColor; std::string hoverColor;
std::string textColor = searchTextColor;
std::string textHoverColor = searchTextColor;
if (match.searchType == SearchMatch::SEARCH_TOKEN) if (match.searchType == SearchMatch::SEARCH_TOKEN)
{ {
element->setObjectName(QString::fromStdString("search_element_" + match.getNodeTypeAsString())); element->setObjectName(QString::fromStdString("search_element_" + match.getNodeTypeAsString()));
color = scheme->getNodeTypeColor(match.nodeType); color = GraphViewStyle::getNodeColor(Node::getTypeString(match.nodeType), false).fill;
hoverColor = scheme->getNodeTypeColor(match.nodeType, "hover"); hoverColor = GraphViewStyle::getNodeColor(Node::getTypeString(match.nodeType), true).fill;
textColor = GraphViewStyle::getNodeColor(Node::getTypeString(match.nodeType), false).text;
textHoverColor = GraphViewStyle::getNodeColor(Node::getTypeString(match.nodeType), true).text;
} }
else else
{ {
@@ -633,8 +637,8 @@ void QtSmartSearchBox::updateElements()
} }
std::stringstream css; std::stringstream css;
css << "QPushButton {border: none; padding: 0px 4px; background-color:" << color << "; color:" << textColor << ";} "; css << "QPushButton { border: none; padding: 0px 4px; background-color:" << color << "; color:" << textColor << ";} ";
css << "QPushButton:hover { background-color:" << hoverColor << ";} "; css << "QPushButton:hover { background-color:" << hoverColor << "; color:" << textHoverColor << ";} ";
element->setStyleSheet(css.str().c_str()); element->setStyleSheet(css.str().c_str());
+6 -11
View File
@@ -7,7 +7,6 @@
#include "utility/utility.h" #include "utility/utility.h"
#include "qt/graphics/QtCountCircleItem.h" #include "qt/graphics/QtCountCircleItem.h"
#include "settings/ColorScheme.h"
QtStraightLineItem::QtStraightLineItem(QGraphicsItem* parent) QtStraightLineItem::QtStraightLineItem(QGraphicsItem* parent)
: QGraphicsLineItem(parent) : QGraphicsLineItem(parent)
@@ -25,7 +24,8 @@ QtStraightLineItem::~QtStraightLineItem()
} }
void QtStraightLineItem::updateLine( void QtStraightLineItem::updateLine(
Vec4i ownerRect, Vec4i targetRect, int number, GraphViewStyle::EdgeStyle style, bool showArrow Vec4i ownerRect, Vec4i targetRect, int number,
GraphViewStyle::EdgeStyle style, GraphViewStyle::NodeStyle countStyle, bool showArrow
){ ){
prepareGeometryChange(); prepareGeometryChange();
@@ -101,15 +101,10 @@ void QtStraightLineItem::updateLine(
m_arrowRight->hide(); m_arrowRight->hide();
} }
QColor color(style.color.c_str()); this->setPen(QPen(QBrush(style.color.c_str()), style.width, Qt::SolidLine, Qt::RoundCap));
this->setPen(QPen(QBrush(color), style.width, Qt::SolidLine, Qt::RoundCap)); m_circle->setStyle(countStyle.color.fill.c_str(), countStyle.color.text.c_str(), countStyle.color.border.c_str(), 1);
color = color.darker(110); m_arrowLeft->setPen(QPen(QBrush(countStyle.color.border.c_str()), 1, Qt::SolidLine, Qt::RoundCap));
m_arrowRight->setPen(QPen(QBrush(countStyle.color.border.c_str()), 1, Qt::SolidLine, Qt::RoundCap));
ColorScheme* scheme = ColorScheme::getInstance().get();
m_circle->setStyle(scheme->getColor("graph/background").c_str(), scheme->getColor("graph/text").c_str(), color, 2);
m_arrowLeft->setPen(QPen(QBrush(color), 2, Qt::SolidLine, Qt::RoundCap));
m_arrowRight->setPen(QPen(QBrush(color), 2, Qt::SolidLine, Qt::RoundCap));
} }
+3 -1
View File
@@ -16,7 +16,9 @@ public:
QtStraightLineItem(QGraphicsItem* parent); QtStraightLineItem(QGraphicsItem* parent);
virtual ~QtStraightLineItem(); virtual ~QtStraightLineItem();
void updateLine(Vec4i ownerRect, Vec4i targetRect, int number, GraphViewStyle::EdgeStyle style, bool showArrow); void updateLine(
Vec4i ownerRect, Vec4i targetRect, int number,
GraphViewStyle::EdgeStyle style, GraphViewStyle::NodeStyle countStyle, bool showArrow);
private: private:
QtCountCircleItem* m_circle; QtCountCircleItem* m_circle;
@@ -91,8 +91,10 @@ void QtGraphEdge::updateLine()
owner.swap(target); owner.swap(target);
} }
GraphViewStyle::NodeStyle countStyle = GraphViewStyle::getStyleOfCountCircle();
dynamic_cast<QtStraightLineItem*>(m_child)->updateLine( dynamic_cast<QtStraightLineItem*>(m_child)->updateLine(
owner->getBoundingRect(), target->getBoundingRect(), m_weight, style, showArrow); owner->getBoundingRect(), target->getBoundingRect(), m_weight, style, countStyle, showArrow);
} }
else else
{ {
@@ -345,7 +345,7 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
QPen pen(Qt::transparent); QPen pen(Qt::transparent);
if (style.borderWidth > 0) if (style.borderWidth > 0)
{ {
pen.setColor(style.borderColor.c_str()); pen.setColor(style.color.border.c_str());
pen.setWidthF(style.borderWidth); pen.setWidthF(style.borderWidth);
if (style.borderDashed) if (style.borderDashed)
{ {
@@ -354,16 +354,16 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
} }
m_rect->setPen(pen); m_rect->setPen(pen);
m_rect->setBrush(QBrush(style.color.c_str())); m_rect->setBrush(QBrush(style.color.fill.c_str()));
qreal radius = style.cornerRadius; qreal radius = style.cornerRadius;
m_rect->setRadius(radius); m_rect->setRadius(radius);
if (style.hatchingColor.size()) if (style.hasHatching)
{ {
QtDeviceScaledPixmap pattern("data/gui/graph_view/images/pattern.png"); QtDeviceScaledPixmap pattern("data/gui/graph_view/images/pattern.png");
pattern.scaleToHeight(10); pattern.scaleToHeight(10);
QPixmap pixmap = utility::colorizePixmap(pattern.pixmap(), style.hatchingColor.c_str()); QPixmap pixmap = utility::colorizePixmap(pattern.pixmap(), style.color.hatching.c_str());
if (!m_undefinedRect) if (!m_undefinedRect)
{ {
@@ -384,7 +384,7 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
QtDeviceScaledPixmap pixmap(QString::fromStdString(style.iconPath)); QtDeviceScaledPixmap pixmap(QString::fromStdString(style.iconPath));
pixmap.scaleToHeight(style.iconSize); pixmap.scaleToHeight(style.iconSize);
m_icon = new QGraphicsPixmapItem(utility::colorizePixmap(pixmap.pixmap(), style.iconColor.c_str()), this); m_icon = new QGraphicsPixmapItem(utility::colorizePixmap(pixmap.pixmap(), style.color.icon.c_str()), this);
m_icon->setPos(style.iconOffset.x, style.iconOffset.y); m_icon->setPos(style.iconOffset.x, style.iconOffset.y);
} }
@@ -396,6 +396,6 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
} }
m_text->setFont(font); m_text->setFont(font);
m_text->setBrush(QBrush(style.textColor.c_str())); m_text->setBrush(QBrush(style.color.text.c_str()));
m_text->setPos(style.iconOffset.x + style.iconSize + style.textOffset.x, style.textOffset.y); m_text->setPos(style.iconOffset.x + style.iconSize + style.textOffset.x, style.textOffset.y);
} }
@@ -56,7 +56,7 @@ void QtGraphNodeAccess::updateStyle()
m_text->setPos(style.textOffset.x + m_accessIconSize + 3, style.textOffset.x + m_accessIconSize + 2 - style.fontSize); m_text->setPos(style.textOffset.x + m_accessIconSize + 3, style.textOffset.x + m_accessIconSize + 2 - style.fontSize);
m_accessIcon->setPos(style.textOffset.x, style.textOffset.y); m_accessIcon->setPos(style.textOffset.x, style.textOffset.y);
m_accessIcon->setPixmap(utility::colorizePixmap(m_accessIcon->pixmap(), style.iconColor.c_str())); m_accessIcon->setPixmap(utility::colorizePixmap(m_accessIcon->pixmap(), style.color.icon.c_str()));
} }
void QtGraphNodeAccess::hideLabel() void QtGraphNodeAccess::hideLabel()
@@ -7,7 +7,6 @@
#include "component/view/GraphViewStyle.h" #include "component/view/GraphViewStyle.h"
#include "qt/graphics/QtCountCircleItem.h" #include "qt/graphics/QtCountCircleItem.h"
#include "settings/ColorScheme.h"
QtGraphNodeBundle::QtGraphNodeBundle(Id tokenId, size_t nodeCount, std::string name) QtGraphNodeBundle::QtGraphNodeBundle(Id tokenId, size_t nodeCount, std::string name)
: QtGraphNode() : QtGraphNode()
@@ -49,11 +48,11 @@ void QtGraphNodeBundle::updateStyle()
m_circle->setPosition(Vec2f(m_rect->rect().right() - 3, m_rect->rect().top() + 3)); m_circle->setPosition(Vec2f(m_rect->rect().right() - 3, m_rect->rect().top() + 3));
ColorScheme* scheme = ColorScheme::getInstance().get(); GraphViewStyle::NodeStyle accessStyle = GraphViewStyle::getStyleOfCountCircle();
m_circle->setStyle( m_circle->setStyle(
scheme->getColor("graph/background").c_str(), accessStyle.color.fill.c_str(),
scheme->getColor("graph/text").c_str(), accessStyle.color.text.c_str(),
scheme->getColor("graph/text").c_str(), accessStyle.color.border.c_str(),
style.borderWidth style.borderWidth
); );
} }
@@ -73,5 +73,5 @@ void QtGraphNodeExpandToggle::updateStyle()
(m_invisibleSubNodeCount == 0 ? m_rect->rect().height() / 2 - 2 : m_rect->rect().height() - 7) (m_invisibleSubNodeCount == 0 ? m_rect->rect().height() / 2 - 2 : m_rect->rect().height() - 7)
); );
m_icon->setPixmap(utility::colorizePixmap(m_icon->pixmap(), style.iconColor.c_str())); m_icon->setPixmap(utility::colorizePixmap(m_icon->pixmap(), style.color.icon.c_str()));
} }
+93 -80
View File
@@ -6,6 +6,21 @@
#include "settings/ApplicationSettings.h" #include "settings/ApplicationSettings.h"
#include "settings/ColorScheme.h" #include "settings/ColorScheme.h"
int GraphViewStyle::s_gridCellSize = 5;
int GraphViewStyle::s_gridCellPadding = 10;
std::map<Node::NodeType, float> GraphViewStyle::s_charWidths;
std::map<Node::NodeType, float> GraphViewStyle::s_charHeights;
std::shared_ptr<GraphViewStyleImpl> GraphViewStyle::s_impl;
int GraphViewStyle::s_fontSize;
std::string GraphViewStyle::s_fontName;
float GraphViewStyle::s_zoomFactor;
std::map<std::string, GraphViewStyle::NodeColor> GraphViewStyle::s_nodeColors;
std::map<std::string, std::string> GraphViewStyle::s_edgeColors;
GraphViewStyle::NodeMargins::NodeMargins() GraphViewStyle::NodeMargins::NodeMargins()
: left(0) : left(0)
, right(0) , right(0)
@@ -27,6 +42,7 @@ GraphViewStyle::NodeStyle::NodeStyle()
, fontSize(0) , fontSize(0)
, fontBold(false) , fontBold(false)
, iconSize(0) , iconSize(0)
, hasHatching(false)
{ {
} }
@@ -67,6 +83,9 @@ void GraphViewStyle::loadStyleSettings()
s_charWidths.clear(); s_charWidths.clear();
s_charHeights.clear(); s_charHeights.clear();
s_nodeColors.clear();
s_edgeColors.clear();
} }
float GraphViewStyle::getCharWidthForNodeType(Node::NodeType type) float GraphViewStyle::getCharWidthForNodeType(Node::NodeType type)
@@ -169,9 +188,9 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
margins.bottom = 15; margins.bottom = 15;
break; break;
case Node::NODE_FILE:
case Node::NODE_ENUM: case Node::NODE_ENUM:
case Node::NODE_TYPEDEF: case Node::NODE_TYPEDEF:
case Node::NODE_FILE:
case Node::NODE_MACRO: case Node::NODE_MACRO:
margins.iconWidth = s_fontSize + 11; margins.iconWidth = s_fontSize + 11;
case Node::NODE_TYPE: case Node::NODE_TYPE:
@@ -255,19 +274,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
){ ){
NodeStyle style; NodeStyle style;
ColorScheme* scheme = ColorScheme::getInstance().get(); style.color = getNodeColor(Node::getTypeString(type), isActive || isFocused);
if (isActive || isFocused)
{
style.color = scheme->getNodeTypeColor(type, "hover");
}
else
{
style.color = scheme->getNodeTypeColor(type);
}
style.textColor = scheme->getColor("graph/text");
style.borderColor = scheme->getColor("graph/border");
style.fontName = getFontNameForNodeType(type); style.fontName = getFontNameForNodeType(type);
style.fontSize = getFontSizeForNodeType(type); style.fontSize = getFontSizeForNodeType(type);
@@ -278,10 +285,6 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
style.borderDashed = true; style.borderDashed = true;
case Node::NODE_NAMESPACE: case Node::NODE_NAMESPACE:
style.borderColor = style.color;
style.color = "#00000000";
style.borderWidth = 1;
style.cornerRadius = 20; style.cornerRadius = 20;
style.textOffset.x = 15; style.textOffset.x = 15;
@@ -294,6 +297,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
case Node::NODE_ENUM: case Node::NODE_ENUM:
case Node::NODE_TYPEDEF: case Node::NODE_TYPEDEF:
case Node::NODE_TEMPLATE_PARAMETER_TYPE: case Node::NODE_TEMPLATE_PARAMETER_TYPE:
case Node::NODE_FILE:
case Node::NODE_MACRO: case Node::NODE_MACRO:
if (hasChildren) if (hasChildren)
{ {
@@ -307,26 +311,6 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
style.textOffset.x = 8; style.textOffset.x = 8;
style.textOffset.y = 8; style.textOffset.y = 8;
} }
if (isActive)
{
style.borderWidth = 2;
}
else if (isFocused)
{
style.borderWidth = 1;
}
else
{
style.borderWidth = 1;
style.borderColor = style.borderColor.replace(0, 1, "#20");
}
break;
case Node::NODE_FILE:
style.cornerRadius = 10;
style.textOffset.x = 6;
style.textOffset.y = 9;
break; break;
case Node::NODE_FUNCTION: case Node::NODE_FUNCTION:
@@ -337,23 +321,24 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
style.cornerRadius = 8; style.cornerRadius = 8;
style.textOffset.x = 5; style.textOffset.x = 5;
style.textOffset.y = 3; style.textOffset.y = 3;
if (isActive)
{
style.borderWidth = 2;
}
break; break;
} }
if (isActive)
{
style.borderWidth = 2;
}
else
{
style.borderWidth = 1;
}
if (isActive || isFocused) if (isActive || isFocused)
{ {
style.fontBold = true; style.fontBold = true;
} }
if (!defined) style.hasHatching = !defined;
{
style.hatchingColor = scheme->getColor("graph/hatching");
}
addIcon(type, hasChildren, &style); addIcon(type, hasChildren, &style);
@@ -364,12 +349,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfAccessNode()
{ {
NodeStyle style; NodeStyle style;
ColorScheme* scheme = ColorScheme::getInstance().get(); style.color = getNodeColor("access", false);
style.color = scheme->getColor("graph/background");
style.textColor = scheme->getColor("graph/text");
style.iconColor = scheme->getColor("graph/icon");
style.borderColor = "#00000000";
style.cornerRadius = 12; style.cornerRadius = 12;
@@ -387,12 +367,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfExpandToggleNode()
{ {
NodeStyle style; NodeStyle style;
ColorScheme* scheme = ColorScheme::getInstance().get(); style.color = getNodeColor("access", false);
style.color = scheme->getColor("graph/background");
style.textColor = scheme->getColor("graph/text");
style.iconColor = scheme->getColor("graph/icon");
style.borderColor = "#00000000";
style.cornerRadius = 100; style.cornerRadius = 100;
@@ -402,10 +377,24 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfExpandToggleNode()
return style; return style;
} }
GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfCountCircle()
{
NodeStyle style;
style.color = getNodeColor("count_number", false);
style.fontName = getFontNameOfExpandToggleNode();
style.fontSize = getFontSizeOfCountCircle();
return style;
}
GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused) GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused)
{ {
NodeStyle style = getStyleForNodeType(Node::NODE_CLASS, true, false, isFocused, false); NodeStyle style = getStyleForNodeType(Node::NODE_CLASS, true, false, isFocused, false);
style.color = getNodeColor("bundle", isFocused);
addIcon(Node::NODE_ENUM, false, &style); addIcon(Node::NODE_ENUM, false, &style);
style.iconPath = "data/gui/graph_view/images/bundle.png"; style.iconPath = "data/gui/graph_view/images/bundle.png";
@@ -431,14 +420,7 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(Edge::EdgeType typ
style.originOffset.y = -1; style.originOffset.y = -1;
style.targetOffset.y = 1; style.targetOffset.y = 1;
if (isActive) style.color = getEdgeColor(Edge::getTypeString(type), isActive || isFocused);
{
style.color = ColorScheme::getInstance()->getEdgeTypeColor(type, "hover");
}
else
{
style.color = ColorScheme::getInstance()->getEdgeTypeColor(type);
}
switch (type) switch (type)
{ {
@@ -512,6 +494,50 @@ float GraphViewStyle::getZoomFactor()
return s_zoomFactor; return s_zoomFactor;
} }
const GraphViewStyle::NodeColor& GraphViewStyle::getNodeColor(const std::string& typeStr, bool focus)
{
std::string type = focus ? typeStr + "focus" : typeStr;
std::map<std::string, NodeColor>::const_iterator it = s_nodeColors.find(type);
if (it != s_nodeColors.end())
{
return it->second;
}
NodeColor color;
ColorScheme* scheme = ColorScheme::getInstance().get();
ColorScheme::ColorState state = focus ? ColorScheme::FOCUS : ColorScheme::NORMAL;
color.fill = scheme->getNodeTypeColor(typeStr, "fill", state);
color.border = scheme->getNodeTypeColor(typeStr, "border", state);
color.text = scheme->getNodeTypeColor(typeStr, "text", state);
color.icon = scheme->getNodeTypeColor(typeStr, "icon", state);
color.hatching = scheme->getNodeTypeColor(typeStr, "hatching", state);
s_nodeColors.emplace(type, color);
return s_nodeColors.find(type)->second;
}
const std::string& GraphViewStyle::getEdgeColor(const std::string& typeStr, bool focus)
{
std::string type = focus ? typeStr + "focus" : typeStr;
std::map<std::string, std::string>::const_iterator it = s_edgeColors.find(type);
if (it != s_edgeColors.end())
{
return it->second;
}
ColorScheme* scheme = ColorScheme::getInstance().get();
ColorScheme::ColorState state = focus ? ColorScheme::FOCUS : ColorScheme::NORMAL;
std::string color = scheme->getEdgeTypeColor(typeStr, state);
s_edgeColors.emplace(type, color);
return s_edgeColors.find(type)->second;
}
void GraphViewStyle::addIcon(Node::NodeType type, bool hasChildren, NodeStyle* style) void GraphViewStyle::addIcon(Node::NodeType type, bool hasChildren, NodeStyle* style)
{ {
switch (type) switch (type)
@@ -545,17 +571,4 @@ void GraphViewStyle::addIcon(Node::NodeType type, bool hasChildren, NodeStyle* s
} }
style->iconOffset.y = 9; style->iconOffset.y = 9;
style->iconColor = ColorScheme::getInstance()->getColor("graph/icon");
} }
int GraphViewStyle::s_gridCellSize = 5;
int GraphViewStyle::s_gridCellPadding = 10;
std::map<Node::NodeType, float> GraphViewStyle::s_charWidths;
std::map<Node::NodeType, float> GraphViewStyle::s_charHeights;
std::shared_ptr<GraphViewStyleImpl> GraphViewStyle::s_impl;
int GraphViewStyle::s_fontSize;
std::string GraphViewStyle::s_fontName;
float GraphViewStyle::s_zoomFactor;
+19 -5
View File
@@ -35,19 +35,24 @@ public:
int iconWidth; int iconWidth;
}; };
struct NodeColor
{
std::string fill;
std::string border;
std::string text;
std::string icon;
std::string hatching;
};
struct NodeStyle struct NodeStyle
{ {
NodeStyle(); NodeStyle();
std::string color; NodeColor color;
std::string textColor;
std::string iconColor;
std::string hatchingColor;
int cornerRadius; int cornerRadius;
int borderWidth; int borderWidth;
std::string borderColor;
bool borderDashed; bool borderDashed;
std::string fontName; std::string fontName;
@@ -59,6 +64,8 @@ public:
std::string iconPath; std::string iconPath;
Vec2i iconOffset; Vec2i iconOffset;
size_t iconSize; size_t iconSize;
bool hasHatching;
}; };
struct EdgeStyle struct EdgeStyle
@@ -108,6 +115,7 @@ public:
static NodeStyle getStyleForNodeType(Node::NodeType type, bool defined, bool isActive, bool isFocused, bool hasChildren); static NodeStyle getStyleForNodeType(Node::NodeType type, bool defined, bool isActive, bool isFocused, bool hasChildren);
static NodeStyle getStyleOfAccessNode(); static NodeStyle getStyleOfAccessNode();
static NodeStyle getStyleOfExpandToggleNode(); static NodeStyle getStyleOfExpandToggleNode();
static NodeStyle getStyleOfCountCircle();
static NodeStyle getStyleOfBundleNode(bool isFocused); static NodeStyle getStyleOfBundleNode(bool isFocused);
static EdgeStyle getStyleForEdgeType(Edge::EdgeType type, bool isActive, bool isFocused); static EdgeStyle getStyleForEdgeType(Edge::EdgeType type, bool isActive, bool isFocused);
@@ -118,6 +126,9 @@ public:
static float getZoomFactor(); static float getZoomFactor();
static const NodeColor& getNodeColor(const std::string& typeStr, bool focus);
static const std::string& getEdgeColor(const std::string& typeStr, bool focus);
static int s_gridCellSize; static int s_gridCellSize;
static int s_gridCellPadding; static int s_gridCellPadding;
@@ -132,6 +143,9 @@ private:
static int s_fontSize; static int s_fontSize;
static std::string s_fontName; static std::string s_fontName;
static float s_zoomFactor; static float s_zoomFactor;
static std::map<std::string, NodeColor> s_nodeColors;
static std::map<std::string, std::string> s_edgeColors;
}; };
#endif // GRAPH_VIEW_STYLE_H #endif // GRAPH_VIEW_STYLE_H
+62 -7
View File
@@ -18,19 +18,63 @@ ColorScheme::~ColorScheme()
std::string ColorScheme::getColor(const std::string& key) const std::string ColorScheme::getColor(const std::string& key) const
{ {
return getValue<std::string>(key, "#FFFFFF"); return getValue<std::string>(key, "");
} }
std::string ColorScheme::getNodeTypeColor(Node::NodeType type, const std::string& state) const std::string ColorScheme::getNodeTypeColor(Node::NodeType type, const std::string& key, ColorState state) const
{ {
std::string path = "graph/node/" + Node::getTypeString(type) + "/" + state; return getNodeTypeColor(Node::getTypeString(type), key, state);
return getValue<std::string>(path, "#FFFFFF");
} }
std::string ColorScheme::getEdgeTypeColor(Edge::EdgeType type, const std::string& state) const std::string ColorScheme::getNodeTypeColor(const std::string& typeStr, const std::string& key, ColorState state) const
{ {
std::string path = "graph/edge/" + Edge::getTypeString(type) + "/" + state; std::string type = getValue<std::string>("graph/node/" + typeStr + "/like", typeStr);
return getValue<std::string>(path, "#FFFFFF"); std::string color = getValue<std::string>("graph/node/" + type + "/" + key + "/" + stateToString(state), "");
if (!color.size() && state != NORMAL)
{
color = getValue<std::string>("graph/node/" + type + "/" + key + "/" + stateToString(NORMAL), "");
}
if (!color.size())
{
color = getValue<std::string>("graph/node/default/" + key + "/" + stateToString(state), "");
}
if (!color.size() && state != NORMAL)
{
color = getValue<std::string>("graph/node/default/" + key + "/" + stateToString(NORMAL), "#FFFFFF");
}
return color;
}
std::string ColorScheme::getEdgeTypeColor(Edge::EdgeType type, ColorState state) const
{
return getEdgeTypeColor(Edge::getTypeString(type), state);
}
std::string ColorScheme::getEdgeTypeColor(const std::string& typeStr, ColorState state) const
{
std::string type = getValue<std::string>("graph/edge/" + typeStr + "/like", typeStr);
std::string color = getValue<std::string>("graph/edge/" + type + "/" + stateToString(state), "");
if (!color.size() && state != NORMAL)
{
color = getValue<std::string>("graph/edge/" + type + "/" + stateToString(NORMAL), "");
}
if (!color.size())
{
color = getValue<std::string>("graph/edge/default/" + stateToString(state), "");
}
if (!color.size() && state != NORMAL)
{
color = getValue<std::string>("graph/edge/default/" + stateToString(NORMAL), "#FFFFFF");
}
return color;
} }
std::string ColorScheme::getSearchTypeColor(const std::string& searchTypeName, const std::string& state) const std::string ColorScheme::getSearchTypeColor(const std::string& searchTypeName, const std::string& state) const
@@ -47,3 +91,14 @@ std::string ColorScheme::getSyntaxColor(const std::string& key) const
ColorScheme::ColorScheme() ColorScheme::ColorScheme()
{ {
} }
std::string ColorScheme::stateToString(ColorState state)
{
switch (state)
{
case NORMAL: return "normal";
case FOCUS: return "focus";
}
return "";
}
+15 -3
View File
@@ -1,21 +1,31 @@
#ifndef COLOR_SCHEME_H #ifndef COLOR_SCHEME_H
#define COLOR_SCHEME_H #define COLOR_SCHEME_H
#include "data/graph/Node.h"
#include "data/graph/Edge.h" #include "data/graph/Edge.h"
#include "data/graph/Node.h"
#include "settings/Settings.h" #include "settings/Settings.h"
class ColorScheme class ColorScheme
: public Settings : public Settings
{ {
public: public:
enum ColorState
{
NORMAL,
FOCUS
};
static std::shared_ptr<ColorScheme> getInstance(); static std::shared_ptr<ColorScheme> getInstance();
virtual ~ColorScheme(); virtual ~ColorScheme();
std::string getColor(const std::string& key) const; std::string getColor(const std::string& key) const;
std::string getNodeTypeColor(Node::NodeType type, const std::string& state = "normal") const; std::string getNodeTypeColor(Node::NodeType type, const std::string& key, ColorState state) const;
std::string getEdgeTypeColor(Edge::EdgeType type, const std::string& state = "normal") const; std::string getNodeTypeColor(const std::string& typeStr, const std::string& key, ColorState state) const;
std::string getEdgeTypeColor(Edge::EdgeType type, ColorState state) const;
std::string getEdgeTypeColor(const std::string& typeStr, ColorState state) const;
std::string getSearchTypeColor(const std::string& searchTypeName, const std::string& state = "normal") const; std::string getSearchTypeColor(const std::string& searchTypeName, const std::string& state = "normal") const;
std::string getSyntaxColor(const std::string& key) const; std::string getSyntaxColor(const std::string& key) const;
@@ -25,6 +35,8 @@ protected:
void operator=(const ColorScheme&); void operator=(const ColorScheme&);
static std::shared_ptr<ColorScheme> s_instance; static std::shared_ptr<ColorScheme> s_instance;
static std::string stateToString(ColorState state);
}; };
#endif // COLOR_SCHEME_H #endif // COLOR_SCHEME_H