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:
@@ -3,6 +3,7 @@
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "settings/ApplicationSettings.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());
|
||||
if (type.size())
|
||||
{
|
||||
color = QColor(scheme->getNodeTypeColor(nodeType).c_str());
|
||||
color = QColor(GraphViewStyle::getNodeColor(Node::getTypeString(nodeType), false).fill.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "qt/element/QtAutocompletionList.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
@@ -603,8 +604,7 @@ void QtSmartSearchBox::updateElements()
|
||||
m_elements.clear();
|
||||
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
|
||||
std::string textColor = scheme->getColor("search/field/text");
|
||||
std::string searchTextColor = scheme->getColor("search/field/text");
|
||||
|
||||
for (const SearchMatch& match : m_matches)
|
||||
{
|
||||
@@ -616,12 +616,16 @@ void QtSmartSearchBox::updateElements()
|
||||
|
||||
std::string color;
|
||||
std::string hoverColor;
|
||||
std::string textColor = searchTextColor;
|
||||
std::string textHoverColor = searchTextColor;
|
||||
|
||||
if (match.searchType == SearchMatch::SEARCH_TOKEN)
|
||||
{
|
||||
element->setObjectName(QString::fromStdString("search_element_" + match.getNodeTypeAsString()));
|
||||
color = scheme->getNodeTypeColor(match.nodeType);
|
||||
hoverColor = scheme->getNodeTypeColor(match.nodeType, "hover");
|
||||
color = GraphViewStyle::getNodeColor(Node::getTypeString(match.nodeType), false).fill;
|
||||
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
|
||||
{
|
||||
@@ -633,8 +637,8 @@ void QtSmartSearchBox::updateElements()
|
||||
}
|
||||
|
||||
std::stringstream css;
|
||||
css << "QPushButton {border: none; padding: 0px 4px; background-color:" << color << "; color:" << textColor << ";} ";
|
||||
css << "QPushButton:hover { background-color:" << hoverColor << ";} ";
|
||||
css << "QPushButton { border: none; padding: 0px 4px; background-color:" << color << "; color:" << textColor << ";} ";
|
||||
css << "QPushButton:hover { background-color:" << hoverColor << "; color:" << textHoverColor << ";} ";
|
||||
|
||||
element->setStyleSheet(css.str().c_str());
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "utility/utility.h"
|
||||
|
||||
#include "qt/graphics/QtCountCircleItem.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtStraightLineItem::QtStraightLineItem(QGraphicsItem* parent)
|
||||
: QGraphicsLineItem(parent)
|
||||
@@ -25,7 +24,8 @@ QtStraightLineItem::~QtStraightLineItem()
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@@ -101,15 +101,10 @@ void QtStraightLineItem::updateLine(
|
||||
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);
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ public:
|
||||
QtStraightLineItem(QGraphicsItem* parent);
|
||||
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:
|
||||
QtCountCircleItem* m_circle;
|
||||
|
||||
@@ -91,8 +91,10 @@ void QtGraphEdge::updateLine()
|
||||
owner.swap(target);
|
||||
}
|
||||
|
||||
GraphViewStyle::NodeStyle countStyle = GraphViewStyle::getStyleOfCountCircle();
|
||||
|
||||
dynamic_cast<QtStraightLineItem*>(m_child)->updateLine(
|
||||
owner->getBoundingRect(), target->getBoundingRect(), m_weight, style, showArrow);
|
||||
owner->getBoundingRect(), target->getBoundingRect(), m_weight, style, countStyle, showArrow);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -345,7 +345,7 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
|
||||
QPen pen(Qt::transparent);
|
||||
if (style.borderWidth > 0)
|
||||
{
|
||||
pen.setColor(style.borderColor.c_str());
|
||||
pen.setColor(style.color.border.c_str());
|
||||
pen.setWidthF(style.borderWidth);
|
||||
if (style.borderDashed)
|
||||
{
|
||||
@@ -354,16 +354,16 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
|
||||
}
|
||||
|
||||
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;
|
||||
m_rect->setRadius(radius);
|
||||
|
||||
if (style.hatchingColor.size())
|
||||
if (style.hasHatching)
|
||||
{
|
||||
QtDeviceScaledPixmap pattern("data/gui/graph_view/images/pattern.png");
|
||||
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)
|
||||
{
|
||||
@@ -384,7 +384,7 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
|
||||
QtDeviceScaledPixmap pixmap(QString::fromStdString(style.iconPath));
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -396,6 +396,6 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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_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()
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "qt/graphics/QtCountCircleItem.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtGraphNodeBundle::QtGraphNodeBundle(Id tokenId, size_t nodeCount, std::string name)
|
||||
: QtGraphNode()
|
||||
@@ -49,11 +48,11 @@ void QtGraphNodeBundle::updateStyle()
|
||||
|
||||
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(
|
||||
scheme->getColor("graph/background").c_str(),
|
||||
scheme->getColor("graph/text").c_str(),
|
||||
scheme->getColor("graph/text").c_str(),
|
||||
accessStyle.color.fill.c_str(),
|
||||
accessStyle.color.text.c_str(),
|
||||
accessStyle.color.border.c_str(),
|
||||
style.borderWidth
|
||||
);
|
||||
}
|
||||
|
||||
@@ -73,5 +73,5 @@ void QtGraphNodeExpandToggle::updateStyle()
|
||||
(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()));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,21 @@
|
||||
#include "settings/ApplicationSettings.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()
|
||||
: left(0)
|
||||
, right(0)
|
||||
@@ -27,6 +42,7 @@ GraphViewStyle::NodeStyle::NodeStyle()
|
||||
, fontSize(0)
|
||||
, fontBold(false)
|
||||
, iconSize(0)
|
||||
, hasHatching(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -67,6 +83,9 @@ void GraphViewStyle::loadStyleSettings()
|
||||
|
||||
s_charWidths.clear();
|
||||
s_charHeights.clear();
|
||||
|
||||
s_nodeColors.clear();
|
||||
s_edgeColors.clear();
|
||||
}
|
||||
|
||||
float GraphViewStyle::getCharWidthForNodeType(Node::NodeType type)
|
||||
@@ -169,9 +188,9 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
|
||||
margins.bottom = 15;
|
||||
break;
|
||||
|
||||
case Node::NODE_FILE:
|
||||
case Node::NODE_ENUM:
|
||||
case Node::NODE_TYPEDEF:
|
||||
case Node::NODE_FILE:
|
||||
case Node::NODE_MACRO:
|
||||
margins.iconWidth = s_fontSize + 11;
|
||||
case Node::NODE_TYPE:
|
||||
@@ -255,19 +274,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
){
|
||||
NodeStyle style;
|
||||
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
|
||||
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.color = getNodeColor(Node::getTypeString(type), isActive || isFocused);
|
||||
|
||||
style.fontName = getFontNameForNodeType(type);
|
||||
style.fontSize = getFontSizeForNodeType(type);
|
||||
@@ -278,10 +285,6 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
style.borderDashed = true;
|
||||
|
||||
case Node::NODE_NAMESPACE:
|
||||
style.borderColor = style.color;
|
||||
style.color = "#00000000";
|
||||
style.borderWidth = 1;
|
||||
|
||||
style.cornerRadius = 20;
|
||||
|
||||
style.textOffset.x = 15;
|
||||
@@ -294,6 +297,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
case Node::NODE_ENUM:
|
||||
case Node::NODE_TYPEDEF:
|
||||
case Node::NODE_TEMPLATE_PARAMETER_TYPE:
|
||||
case Node::NODE_FILE:
|
||||
case Node::NODE_MACRO:
|
||||
if (hasChildren)
|
||||
{
|
||||
@@ -307,26 +311,6 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
style.textOffset.x = 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;
|
||||
|
||||
case Node::NODE_FUNCTION:
|
||||
@@ -337,23 +321,24 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
style.cornerRadius = 8;
|
||||
style.textOffset.x = 5;
|
||||
style.textOffset.y = 3;
|
||||
|
||||
if (isActive)
|
||||
{
|
||||
style.borderWidth = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (isActive)
|
||||
{
|
||||
style.borderWidth = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
style.borderWidth = 1;
|
||||
}
|
||||
|
||||
if (isActive || isFocused)
|
||||
{
|
||||
style.fontBold = true;
|
||||
}
|
||||
|
||||
if (!defined)
|
||||
{
|
||||
style.hatchingColor = scheme->getColor("graph/hatching");
|
||||
}
|
||||
style.hasHatching = !defined;
|
||||
|
||||
addIcon(type, hasChildren, &style);
|
||||
|
||||
@@ -364,12 +349,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfAccessNode()
|
||||
{
|
||||
NodeStyle style;
|
||||
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
|
||||
style.color = scheme->getColor("graph/background");
|
||||
style.textColor = scheme->getColor("graph/text");
|
||||
style.iconColor = scheme->getColor("graph/icon");
|
||||
style.borderColor = "#00000000";
|
||||
style.color = getNodeColor("access", false);
|
||||
|
||||
style.cornerRadius = 12;
|
||||
|
||||
@@ -387,12 +367,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfExpandToggleNode()
|
||||
{
|
||||
NodeStyle style;
|
||||
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
|
||||
style.color = scheme->getColor("graph/background");
|
||||
style.textColor = scheme->getColor("graph/text");
|
||||
style.iconColor = scheme->getColor("graph/icon");
|
||||
style.borderColor = "#00000000";
|
||||
style.color = getNodeColor("access", false);
|
||||
|
||||
style.cornerRadius = 100;
|
||||
|
||||
@@ -402,10 +377,24 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfExpandToggleNode()
|
||||
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)
|
||||
{
|
||||
NodeStyle style = getStyleForNodeType(Node::NODE_CLASS, true, false, isFocused, false);
|
||||
|
||||
style.color = getNodeColor("bundle", isFocused);
|
||||
|
||||
addIcon(Node::NODE_ENUM, false, &style);
|
||||
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.targetOffset.y = 1;
|
||||
|
||||
if (isActive)
|
||||
{
|
||||
style.color = ColorScheme::getInstance()->getEdgeTypeColor(type, "hover");
|
||||
}
|
||||
else
|
||||
{
|
||||
style.color = ColorScheme::getInstance()->getEdgeTypeColor(type);
|
||||
}
|
||||
style.color = getEdgeColor(Edge::getTypeString(type), isActive || isFocused);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@@ -512,6 +494,50 @@ float GraphViewStyle::getZoomFactor()
|
||||
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)
|
||||
{
|
||||
switch (type)
|
||||
@@ -545,17 +571,4 @@ void GraphViewStyle::addIcon(Node::NodeType type, bool hasChildren, NodeStyle* s
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -35,19 +35,24 @@ public:
|
||||
int iconWidth;
|
||||
};
|
||||
|
||||
struct NodeColor
|
||||
{
|
||||
std::string fill;
|
||||
std::string border;
|
||||
std::string text;
|
||||
std::string icon;
|
||||
std::string hatching;
|
||||
};
|
||||
|
||||
struct NodeStyle
|
||||
{
|
||||
NodeStyle();
|
||||
|
||||
std::string color;
|
||||
std::string textColor;
|
||||
std::string iconColor;
|
||||
std::string hatchingColor;
|
||||
NodeColor color;
|
||||
|
||||
int cornerRadius;
|
||||
|
||||
int borderWidth;
|
||||
std::string borderColor;
|
||||
bool borderDashed;
|
||||
|
||||
std::string fontName;
|
||||
@@ -59,6 +64,8 @@ public:
|
||||
std::string iconPath;
|
||||
Vec2i iconOffset;
|
||||
size_t iconSize;
|
||||
|
||||
bool hasHatching;
|
||||
};
|
||||
|
||||
struct EdgeStyle
|
||||
@@ -108,6 +115,7 @@ public:
|
||||
static NodeStyle getStyleForNodeType(Node::NodeType type, bool defined, bool isActive, bool isFocused, bool hasChildren);
|
||||
static NodeStyle getStyleOfAccessNode();
|
||||
static NodeStyle getStyleOfExpandToggleNode();
|
||||
static NodeStyle getStyleOfCountCircle();
|
||||
static NodeStyle getStyleOfBundleNode(bool isFocused);
|
||||
|
||||
static EdgeStyle getStyleForEdgeType(Edge::EdgeType type, bool isActive, bool isFocused);
|
||||
@@ -118,6 +126,9 @@ public:
|
||||
|
||||
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_gridCellPadding;
|
||||
|
||||
@@ -132,6 +143,9 @@ private:
|
||||
static int s_fontSize;
|
||||
static std::string s_fontName;
|
||||
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
|
||||
|
||||
@@ -18,19 +18,63 @@ ColorScheme::~ColorScheme()
|
||||
|
||||
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 getValue<std::string>(path, "#FFFFFF");
|
||||
return getNodeTypeColor(Node::getTypeString(type), key, state);
|
||||
}
|
||||
|
||||
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;
|
||||
return getValue<std::string>(path, "#FFFFFF");
|
||||
std::string type = getValue<std::string>("graph/node/" + typeStr + "/like", typeStr);
|
||||
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
|
||||
@@ -47,3 +91,14 @@ std::string ColorScheme::getSyntaxColor(const std::string& key) const
|
||||
ColorScheme::ColorScheme()
|
||||
{
|
||||
}
|
||||
|
||||
std::string ColorScheme::stateToString(ColorState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case NORMAL: return "normal";
|
||||
case FOCUS: return "focus";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -1,21 +1,31 @@
|
||||
#ifndef COLOR_SCHEME_H
|
||||
#define COLOR_SCHEME_H
|
||||
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/graph/Edge.h"
|
||||
#include "data/graph/Node.h"
|
||||
#include "settings/Settings.h"
|
||||
|
||||
class ColorScheme
|
||||
: public Settings
|
||||
{
|
||||
public:
|
||||
enum ColorState
|
||||
{
|
||||
NORMAL,
|
||||
FOCUS
|
||||
};
|
||||
|
||||
static std::shared_ptr<ColorScheme> getInstance();
|
||||
virtual ~ColorScheme();
|
||||
|
||||
std::string getColor(const std::string& key) const;
|
||||
|
||||
std::string getNodeTypeColor(Node::NodeType type, const std::string& state = "normal") const;
|
||||
std::string getEdgeTypeColor(Edge::EdgeType type, const std::string& state = "normal") const;
|
||||
std::string getNodeTypeColor(Node::NodeType type, const std::string& key, ColorState state) 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 getSyntaxColor(const std::string& key) const;
|
||||
|
||||
@@ -25,6 +35,8 @@ protected:
|
||||
void operator=(const ColorScheme&);
|
||||
|
||||
static std::shared_ptr<ColorScheme> s_instance;
|
||||
|
||||
static std::string stateToString(ColorState state);
|
||||
};
|
||||
|
||||
#endif // COLOR_SCHEME_H
|
||||
|
||||
Reference in New Issue
Block a user