ui: new features for the Graph UI
* removed node shadows * made enums collapsible * added icons to nodes: enum, typedef, macro, bundle
|
After Width: | Height: | Size: 748 B |
|
After Width: | Height: | Size: 584 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 337 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 656 B |
|
After Width: | Height: | Size: 546 B |
|
After Width: | Height: | Size: 684 B |
|
After Width: | Height: | Size: 805 B |
@@ -22,6 +22,18 @@ int calculate(int i)
|
||||
}
|
||||
|
||||
|
||||
#define CALL_CALCULATE() \
|
||||
do \
|
||||
{ \
|
||||
calculate(); \
|
||||
} \
|
||||
while(0) \
|
||||
|
||||
int main()
|
||||
{
|
||||
CALL_CALCULATE();
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
|
||||
void countUp()
|
||||
@@ -173,3 +185,13 @@ class Tower : public Building {};
|
||||
class SkyScrapper : public Building {};
|
||||
class Mansion : public Building {};
|
||||
class Shard : public House, public Tower, public SkyScrapper, public Mansion {};
|
||||
|
||||
typedef unsigned int uint;
|
||||
uint a = 1 + 2;
|
||||
|
||||
enum Size
|
||||
{
|
||||
SMALL,
|
||||
MEDIUM,
|
||||
LARGE
|
||||
};
|
||||
|
||||
@@ -108,11 +108,6 @@ void QtGraphView::centerScrollBars()
|
||||
|
||||
void QtGraphView::finishedTransition()
|
||||
{
|
||||
for (const std::shared_ptr<QtGraphNode>& node : m_nodes)
|
||||
{
|
||||
node->setShadowEnabledRecursive(true);
|
||||
}
|
||||
|
||||
QGraphicsView* view = getView();
|
||||
view->setInteractive(true);
|
||||
|
||||
@@ -434,16 +429,6 @@ void QtGraphView::createTransition()
|
||||
}
|
||||
}
|
||||
|
||||
for (const std::shared_ptr<QtGraphNode>& node : m_nodes)
|
||||
{
|
||||
node->setShadowEnabledRecursive(false);
|
||||
}
|
||||
|
||||
for (const std::shared_ptr<QtGraphNode>& node : m_oldNodes)
|
||||
{
|
||||
node->setShadowEnabledRecursive(false);
|
||||
}
|
||||
|
||||
QGraphicsView* view = getView();
|
||||
view->setInteractive(false);
|
||||
|
||||
|
||||
@@ -199,16 +199,6 @@ void QtGraphNode::addComponent(const std::shared_ptr<QtGraphNodeComponent>& comp
|
||||
m_components.push_back(component);
|
||||
}
|
||||
|
||||
void QtGraphNode::setShadowEnabledRecursive(bool enabled)
|
||||
{
|
||||
m_rect->setShadowEnabled(enabled);
|
||||
|
||||
for (const std::shared_ptr<QtGraphNode>& node : m_subNodes)
|
||||
{
|
||||
node->setShadowEnabledRecursive(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void QtGraphNode::hoverEnter()
|
||||
{
|
||||
hoverEnterEvent(nullptr);
|
||||
@@ -352,30 +342,21 @@ void QtGraphNode::notifyEdgesAfterMove()
|
||||
|
||||
void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
|
||||
{
|
||||
QColor color = style.color.c_str();
|
||||
QPen pen(Qt::transparent);
|
||||
if (style.borderWidth > 0)
|
||||
{
|
||||
pen.setColor(style.borderColor.c_str());
|
||||
pen.setWidthF(style.borderWidth);
|
||||
if (style.borderDashed)
|
||||
{
|
||||
pen.setStyle(Qt::DashLine);
|
||||
}
|
||||
}
|
||||
|
||||
m_rect->setPen(pen);
|
||||
m_rect->setBrush(QBrush(style.color.c_str()));
|
||||
|
||||
qreal radius = style.cornerRadius;
|
||||
|
||||
QPen p(style.borderColor.c_str());
|
||||
p.setWidthF(style.borderWidth);
|
||||
if (style.borderDashed)
|
||||
{
|
||||
p.setStyle(Qt::DashLine);
|
||||
}
|
||||
|
||||
QFont font(style.fontName.c_str());
|
||||
font.setPixelSize(style.fontSize);
|
||||
if (style.fontBold)
|
||||
{
|
||||
font.setWeight(QFont::Bold);
|
||||
}
|
||||
|
||||
if (style.shadowColor.size())
|
||||
{
|
||||
m_rect->setShadow(style.shadowColor.c_str(), style.shadowBlurRadius);
|
||||
}
|
||||
|
||||
m_rect->setPen(p);
|
||||
m_rect->setBrush(QBrush(color));
|
||||
m_rect->setRadius(radius);
|
||||
|
||||
if (style.hatchingColor.size())
|
||||
@@ -390,10 +371,10 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
|
||||
setSize(getSize());
|
||||
}
|
||||
|
||||
p.setWidth(0);
|
||||
p.setColor(Qt::transparent);
|
||||
pen.setWidth(0);
|
||||
pen.setColor(Qt::transparent);
|
||||
|
||||
m_undefinedRect->setPen(p);
|
||||
m_undefinedRect->setPen(pen);
|
||||
m_undefinedRect->setBrush(pixmap);
|
||||
m_undefinedRect->setRadius(radius);
|
||||
}
|
||||
@@ -407,6 +388,13 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
|
||||
m_icon->setPos(style.iconOffset.x, style.iconOffset.y);
|
||||
}
|
||||
|
||||
QFont font(style.fontName.c_str());
|
||||
font.setPixelSize(style.fontSize);
|
||||
if (style.fontBold)
|
||||
{
|
||||
font.setWeight(QFont::Bold);
|
||||
}
|
||||
|
||||
m_text->setFont(font);
|
||||
m_text->setBrush(QBrush(style.textColor.c_str()));
|
||||
m_text->setPos(style.iconOffset.x + style.iconSize + style.textOffset.x, style.textOffset.y);
|
||||
|
||||
@@ -66,8 +66,6 @@ public:
|
||||
|
||||
void addComponent(const std::shared_ptr<QtGraphNodeComponent>& component);
|
||||
|
||||
void setShadowEnabledRecursive(bool enabled);
|
||||
|
||||
void hoverEnter();
|
||||
|
||||
void focusIn();
|
||||
|
||||
@@ -282,7 +282,7 @@ void GraphController::autoExpandActiveNode(const std::vector<Id>& activeTokenIds
|
||||
node = findDummyNodeRecursive(m_dummyNodes, activeTokenIds[0]);
|
||||
}
|
||||
|
||||
if (node && node->data->isType(Node::NODE_CLASS | Node::NODE_STRUCT))
|
||||
if (node && node->data->isType(Node::NODE_CLASS | Node::NODE_STRUCT | Node::NODE_ENUM))
|
||||
{
|
||||
node->expanded = true;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ void GraphController::setNodeVisibilityRecursiveTopDown(DummyNode& node, bool pa
|
||||
|
||||
if ((node.isGraphNode() && node.isExpanded()) ||
|
||||
(node.isAccessNode() && parentExpanded) ||
|
||||
(node.isGraphNode() && node.data->isType(Node::NODE_ENUM)))
|
||||
(node.isGraphNode() && parentExpanded && node.data->isType(Node::NODE_ENUM_CONSTANT)))
|
||||
{
|
||||
for (DummyNode& subNode : node.subNodes)
|
||||
{
|
||||
@@ -441,7 +441,7 @@ void GraphController::bundleNodes()
|
||||
return false;
|
||||
},
|
||||
3,
|
||||
"Undefined Nodes"
|
||||
"Undefined Symbols"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -652,9 +652,7 @@ void GraphController::layoutNestingRecursive(DummyNode& node) const
|
||||
width = margins.charWidth * node.data->getName().size();
|
||||
}
|
||||
|
||||
width += margins.iconWidth;
|
||||
|
||||
if (node.data->isType(Node::NODE_CLASS | Node::NODE_STRUCT) && node.subNodes.size())
|
||||
if (node.data->isType(Node::NODE_CLASS | Node::NODE_STRUCT | Node::NODE_ENUM) && node.subNodes.size())
|
||||
{
|
||||
addExpandToggleNode(node);
|
||||
}
|
||||
@@ -664,6 +662,8 @@ void GraphController::layoutNestingRecursive(DummyNode& node) const
|
||||
width = margins.charWidth * node.name.size();
|
||||
}
|
||||
|
||||
width += margins.iconWidth;
|
||||
|
||||
// Horizontal layouting is currently not used, but left in place for experimentation.
|
||||
bool layoutHorizontal = false;
|
||||
|
||||
@@ -762,6 +762,11 @@ void GraphController::addExpandToggleNode(DummyNode& node) const
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
else if (subNode.isGraphNode() && subNode.data->isType(Node::NODE_ENUM_CONSTANT) && !subNode.visible)
|
||||
{
|
||||
expandNode.invisibleSubNodeCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (DummyNode& subSubNode : subNode.subNodes)
|
||||
{
|
||||
|
||||
@@ -21,8 +21,7 @@ GraphViewStyle::NodeMargins::NodeMargins()
|
||||
}
|
||||
|
||||
GraphViewStyle::NodeStyle::NodeStyle()
|
||||
: shadowBlurRadius(0)
|
||||
, cornerRadius(0)
|
||||
: cornerRadius(0)
|
||||
, borderWidth(0)
|
||||
, borderDashed(false)
|
||||
, fontSize(0)
|
||||
@@ -172,12 +171,14 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
|
||||
break;
|
||||
|
||||
case Node::NODE_FILE:
|
||||
case Node::NODE_ENUM:
|
||||
case Node::NODE_TYPEDEF:
|
||||
case Node::NODE_UNDEFINED_MACRO:
|
||||
case Node::NODE_MACRO:
|
||||
margins.iconWidth = s_fontSize + 11;
|
||||
case Node::NODE_UNDEFINED_TYPE:
|
||||
case Node::NODE_STRUCT:
|
||||
case Node::NODE_CLASS:
|
||||
case Node::NODE_ENUM:
|
||||
case Node::NODE_TYPEDEF:
|
||||
case Node::NODE_TEMPLATE_PARAMETER_TYPE:
|
||||
if (hasChildren)
|
||||
{
|
||||
@@ -199,8 +200,6 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
|
||||
case Node::NODE_GLOBAL_VARIABLE:
|
||||
case Node::NODE_FIELD:
|
||||
case Node::NODE_ENUM_CONSTANT:
|
||||
case Node::NODE_UNDEFINED_MACRO:
|
||||
case Node::NODE_MACRO:
|
||||
margins.left = margins.right = 5;
|
||||
margins.top = margins.bottom = 3;
|
||||
break;
|
||||
@@ -252,7 +251,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfExpandToggleNode()
|
||||
|
||||
GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfBundleNode()
|
||||
{
|
||||
return getMarginsForNodeType(Node::NODE_CLASS, false);
|
||||
return getMarginsForNodeType(Node::NODE_ENUM, false);
|
||||
}
|
||||
|
||||
GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
@@ -272,7 +271,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
}
|
||||
|
||||
style.textColor = scheme->getColor("graph/text");
|
||||
style.borderColor = isActive ? scheme->getColor("graph/border") : "#00000000";
|
||||
style.borderColor = scheme->getColor("graph/border");
|
||||
|
||||
style.fontName = getFontNameForNodeType(type);
|
||||
style.fontSize = getFontSizeForNodeType(type);
|
||||
@@ -294,6 +293,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
break;
|
||||
|
||||
case Node::NODE_UNDEFINED_TYPE:
|
||||
case Node::NODE_UNDEFINED_MACRO:
|
||||
style.hatchingColor = scheme->getColor("graph/hatching");
|
||||
|
||||
case Node::NODE_STRUCT:
|
||||
@@ -301,22 +301,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
case Node::NODE_ENUM:
|
||||
case Node::NODE_TYPEDEF:
|
||||
case Node::NODE_TEMPLATE_PARAMETER_TYPE:
|
||||
if (isActive)
|
||||
{
|
||||
style.fontBold = true;
|
||||
}
|
||||
|
||||
style.shadowColor = scheme->getColor("graph/border");
|
||||
if (isFocused)
|
||||
{
|
||||
style.shadowColor.insert(1, "FF");
|
||||
}
|
||||
else
|
||||
{
|
||||
style.shadowColor.insert(1, "80");
|
||||
}
|
||||
style.shadowBlurRadius = 5;
|
||||
|
||||
case Node::NODE_MACRO:
|
||||
if (hasChildren)
|
||||
{
|
||||
style.cornerRadius = 20;
|
||||
@@ -329,27 +314,30 @@ 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:
|
||||
if (isActive)
|
||||
{
|
||||
style.fontBold = true;
|
||||
}
|
||||
|
||||
style.cornerRadius = 10;
|
||||
style.textOffset.x = 6;
|
||||
style.textOffset.y = 9;
|
||||
style.iconPath = "data/gui/graph_view/images/file.png";
|
||||
style.iconSize = s_fontSize + 2;
|
||||
style.iconOffset.x = 9;
|
||||
style.iconOffset.y = 9;
|
||||
style.iconColor = scheme->getColor("graph/icon");
|
||||
break;
|
||||
|
||||
case Node::NODE_UNDEFINED_FUNCTION:
|
||||
case Node::NODE_UNDEFINED_VARIABLE:
|
||||
case Node::NODE_UNDEFINED_MACRO:
|
||||
style.hatchingColor = scheme->getColor("graph/hatching");
|
||||
|
||||
case Node::NODE_FUNCTION:
|
||||
@@ -357,23 +345,24 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
case Node::NODE_GLOBAL_VARIABLE:
|
||||
case Node::NODE_FIELD:
|
||||
case Node::NODE_ENUM_CONSTANT:
|
||||
case Node::NODE_MACRO:
|
||||
if (isActive || isFocused)
|
||||
{
|
||||
style.fontBold = true;
|
||||
}
|
||||
|
||||
style.cornerRadius = 8;
|
||||
style.textOffset.x = 5;
|
||||
style.textOffset.y = 3;
|
||||
|
||||
if (isActive)
|
||||
{
|
||||
style.borderWidth = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (isActive)
|
||||
if (isActive || isFocused)
|
||||
{
|
||||
style.borderWidth = 1.5f;
|
||||
style.fontBold = true;
|
||||
}
|
||||
|
||||
addIcon(type, hasChildren, &style);
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
@@ -423,11 +412,8 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused)
|
||||
{
|
||||
NodeStyle style = getStyleForNodeType(Node::NODE_CLASS, false, isFocused, false);
|
||||
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
|
||||
style.shadowColor = "";
|
||||
style.borderColor = scheme->getColor("graph/border");
|
||||
style.borderWidth = isFocused ? 2 : 1;
|
||||
addIcon(Node::NODE_ENUM, false, &style);
|
||||
style.iconPath = "data/gui/graph_view/images/bundle.png";
|
||||
|
||||
return style;
|
||||
}
|
||||
@@ -527,6 +513,43 @@ int GraphViewStyle::toGridGap(int x)
|
||||
return s_gridCellPadding + toGridOffset(x - s_gridCellPadding);
|
||||
}
|
||||
|
||||
void GraphViewStyle::addIcon(Node::NodeType type, bool hasChildren, NodeStyle* style)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Node::NODE_ENUM:
|
||||
style->iconPath = "data/gui/graph_view/images/enum_1.png";
|
||||
break;
|
||||
case Node::NODE_TYPEDEF:
|
||||
style->iconPath = "data/gui/graph_view/images/typedef_2.png";
|
||||
break;
|
||||
case Node::NODE_UNDEFINED_MACRO:
|
||||
case Node::NODE_MACRO:
|
||||
style->iconPath = "data/gui/graph_view/images/macro_3.png";
|
||||
break;
|
||||
case Node::NODE_FILE:
|
||||
style->iconPath = "data/gui/graph_view/images/file.png";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
style->iconSize = s_fontSize + 2;
|
||||
|
||||
if (hasChildren)
|
||||
{
|
||||
style->iconOffset.x = 11;
|
||||
style->textOffset.x = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
style->iconOffset.x = 9;
|
||||
}
|
||||
|
||||
style->iconOffset.y = 9;
|
||||
style->iconColor = ColorScheme::getInstance()->getColor("graph/icon");
|
||||
}
|
||||
|
||||
int GraphViewStyle::s_gridCellSize = 5;
|
||||
int GraphViewStyle::s_gridCellPadding = 10;
|
||||
|
||||
|
||||
@@ -44,12 +44,9 @@ public:
|
||||
std::string iconColor;
|
||||
std::string hatchingColor;
|
||||
|
||||
std::string shadowColor;
|
||||
int shadowBlurRadius;
|
||||
|
||||
int cornerRadius;
|
||||
|
||||
float borderWidth;
|
||||
int borderWidth;
|
||||
std::string borderColor;
|
||||
bool borderDashed;
|
||||
|
||||
@@ -123,6 +120,8 @@ public:
|
||||
static int s_gridCellPadding;
|
||||
|
||||
private:
|
||||
static void addIcon(Node::NodeType type, bool hasChildren, NodeStyle* style);
|
||||
|
||||
static std::map<Node::NodeType, float> s_charWidths;
|
||||
static std::map<Node::NodeType, float> s_charHeights;
|
||||
|
||||
|
||||