ui: Show namespace label on left side of graph nodes

* Added arrow indicating namespace and package name on left side of node
* Show namespace label when hovering arrow
* Activate namespace when clicking label
* New design for namespace nodes
This commit is contained in:
Eberhard Graether
2016-11-28 16:28:52 +01:00
parent 1b15933819
commit e9cadbed8d
18 changed files with 397 additions and 73 deletions
@@ -88,16 +88,14 @@ void FeatureController::handleMessage(MessageActivateFile* message)
void FeatureController::handleMessage(MessageActivateNodes* message)
{
std::vector<Id> nodeIds;
if (!message->isReplayed())
for (const MessageActivateNodes::ActiveNode& node : message->nodes)
{
for (const MessageActivateNodes::ActiveNode& node : message->nodes)
if (!message->isReplayed() && node.nodeId)
{
nodeIds.push_back(node.nodeId);
}
}
else
{
for (const MessageActivateNodes::ActiveNode& node : message->nodes)
else
{
Id nodeId = m_storageAccess->getIdForNodeWithNameHierarchy(node.nameHierarchy);
if (nodeId > 0)
@@ -107,7 +105,6 @@ void FeatureController::handleMessage(MessageActivateNodes* message)
}
}
MessageActivateTokens m(message, nodeIds);
for (const MessageActivateNodes::ActiveNode& node : message->nodes)
{
@@ -262,15 +262,26 @@ void GraphController::createDummyGraphForTokenIds(const std::vector<Id>& tokenId
{
node->hasParent = false;
// we remove the name qualifier for java projects.
// TODO: get rid of this distinction once we implemented better namespace/package display in graph.
if (Application::getInstance()->getCurrentProject()->getLanguage() == LANGUAGE_JAVA && !node->data->isType(Node::NODE_PACKAGE))
if (node->data->isType(Node::NODE_UNDEFINED | Node::NODE_NAMESPACE | Node::NODE_PACKAGE))
{
node->name = node->data->getName();
node->name = node->data->getFullName();
}
else
{
node->name = node->data->getFullName();
node->name = node->data->getName();
NameHierarchy qualifier = node->data->getNameHierarchy();
qualifier.pop();
if (qualifier.size())
{
std::shared_ptr<DummyNode> qualifierNode = std::make_shared<DummyNode>();
qualifierNode->visible = true;
qualifierNode->qualifierName = qualifier;
node->subNodes.push_back(qualifierNode);
node->hasQualifier = true;
}
}
}
@@ -516,6 +527,11 @@ bool GraphController::setNodeVisibilityRecursiveBottomUp(DummyNode* node, bool n
node->visible = true;
return true;
}
else if (node->isQualifierNode())
{
node->visible = true;
return false;
}
for (std::shared_ptr<DummyNode> subNode : node->subNodes)
{
@@ -543,8 +559,11 @@ void GraphController::setNodeVisibilityRecursiveTopDown(DummyNode* node, bool pa
{
for (std::shared_ptr<DummyNode> subNode : node->subNodes)
{
node->childVisible = true;
setNodeVisibilityRecursiveTopDown(subNode.get(), node->isExpanded());
if (!subNode->isQualifierNode())
{
node->childVisible = true;
setNodeVisibilityRecursiveTopDown(subNode.get(), node->isExpanded());
}
}
}
}
@@ -985,6 +1004,10 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const
{
margins = GraphViewStyle::getMarginsOfBundleNode();
}
else if (node->isQualifierNode())
{
return;
}
int y = 0;
int x = 0;
@@ -1038,9 +1061,15 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const
{
continue;
}
else if (subNode->isQualifierNode())
{
subNode->position.y = margins.top + margins.charHeight / 2;
width += 5;
continue;
}
subNode->position.x = margins.left + x;
subNode->position.y = margins.top + margins.charHeight + y;
subNode->position.y = margins.top + margins.charHeight + margins.spacingA + y;
if (layoutHorizontal)
{
@@ -1075,7 +1104,7 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const
}
node->size.x = margins.left + width + margins.right;
node->size.y = margins.top + margins.charHeight + y + height + margins.bottom;
node->size.y = margins.top + margins.charHeight + margins.spacingA + y + height + margins.bottom;
for (std::shared_ptr<DummyNode> subNode : node->subNodes)
{
@@ -7,6 +7,7 @@
#include "utility/utilityString.h"
#include "data/graph/token_component/TokenComponentAccess.h"
#include "data/name/NameHierarchy.h"
class Node;
@@ -42,6 +43,7 @@ public:
, expanded(false)
, autoExpanded(false)
, hasParent(true)
, hasQualifier(false)
, accessKind(ACCESS_NONE)
, invisibleSubNodeCount(0)
, layoutBucket(0, 0)
@@ -61,7 +63,7 @@ public:
bool isExpandToggleNode() const
{
return !isGraphNode() && !isAccessNode() && !isBundleNode();
return !isGraphNode() && !isAccessNode() && !isBundleNode() && !isQualifierNode();
}
bool isBundleNode() const
@@ -69,6 +71,11 @@ public:
return bundledNodes.size() > 0;
}
bool isQualifierNode() const
{
return qualifierName.size();
}
bool isExpanded() const
{
return expanded;
@@ -222,6 +229,7 @@ public:
bool expanded;
bool autoExpanded;
bool hasParent;
bool hasQualifier;
// AccessNode
AccessKind accessKind;
@@ -238,6 +246,9 @@ public:
// BundleNode
std::vector<std::shared_ptr<DummyNode>> bundledNodes;
size_t bundledNodeCount;
// QualifierNode
NameHierarchy qualifierName;
};
#endif // DUMMY_NODE_H
+72 -24
View File
@@ -30,6 +30,7 @@ GraphViewStyle::NodeMargins::NodeMargins()
, bottom(0)
, spacingX(0)
, spacingY(0)
, spacingA(0)
, minWidth(0)
, charWidth(0.0f)
, charHeight(0.0f)
@@ -128,9 +129,11 @@ size_t GraphViewStyle::getFontSizeForNodeType(Node::NodeType type)
{
switch (type)
{
case Node::NODE_UNDEFINED:
case Node::NODE_NAMESPACE:
case Node::NODE_PACKAGE:
return s_fontSize - 2;
case Node::NODE_UNDEFINED:
case Node::NODE_TYPE:
case Node::NODE_BUILTIN_TYPE:
case Node::NODE_STRUCT:
@@ -168,6 +171,11 @@ size_t GraphViewStyle::getFontSizeOfCountCircle()
return s_fontSize - 3;
}
size_t GraphViewStyle::getFontSizeOfQualifier()
{
return s_fontSize - 3;
}
std::string GraphViewStyle::getFontNameForNodeType(Node::NodeType type)
{
return s_fontName;
@@ -191,14 +199,19 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
switch (type)
{
case Node::NODE_NAMESPACE:
case Node::NODE_PACKAGE:
margins.left = margins.right = 5;
margins.top = margins.bottom = 3;
margins.iconWidth = s_fontSize - 3;
break;
case Node::NODE_ENUM:
case Node::NODE_TYPEDEF:
case Node::NODE_FILE:
case Node::NODE_MACRO:
margins.iconWidth = s_fontSize + 11;
case Node::NODE_UNDEFINED:
case Node::NODE_NAMESPACE:
case Node::NODE_PACKAGE:
case Node::NODE_TYPE:
case Node::NODE_BUILTIN_TYPE:
case Node::NODE_STRUCT:
@@ -209,8 +222,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
if (hasChildren)
{
margins.left = margins.right = 10;
margins.top = 15;
margins.bottom = 10;
margins.top = margins.bottom = 10;
margins.spacingA = 5;
}
else
{
@@ -226,9 +239,9 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
case Node::NODE_ENUM_CONSTANT:
if (hasChildren)
{
margins.top = 8;
margins.bottom = 5;
margins.top = margins.bottom = 5;
margins.spacingY = 4;
margins.spacingA = 3;
}
else
{
@@ -296,7 +309,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfBundleNode()
}
GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
Node::NodeType type, bool defined, bool isActive, bool isFocused, bool hasChildren
Node::NodeType type, bool defined, bool isActive, bool isFocused, bool hasChildren, bool hasQualifier
){
NodeStyle style;
@@ -305,11 +318,30 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
style.fontName = getFontNameForNodeType(type);
style.fontSize = getFontSizeForNodeType(type);
if (isActive || isFocused)
{
style.fontBold = true;
}
if (isActive)
{
style.borderWidth = 2;
}
else
{
style.borderWidth = 1;
}
switch (type)
{
case Node::NODE_UNDEFINED:
case Node::NODE_NAMESPACE:
case Node::NODE_PACKAGE:
style.cornerRadius = 0;
style.textOffset.x = 5;
style.textOffset.y = 3;
break;
case Node::NODE_UNDEFINED:
case Node::NODE_TYPE:
case Node::NODE_BUILTIN_TYPE:
case Node::NODE_STRUCT:
@@ -346,24 +378,22 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
break;
}
if (isActive)
{
style.borderWidth = 2;
}
else
{
style.borderWidth = 1;
}
if (isActive || isFocused)
{
style.fontBold = true;
}
style.hasHatching = !defined;
addIcon(type, hasChildren, &style);
if (hasQualifier)
{
if (style.iconPath.size())
{
style.iconOffset.x = style.iconOffset.x + 5;
}
else
{
style.textOffset.x = style.textOffset.x + 5;
}
}
return style;
}
@@ -413,7 +443,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfCountCircle()
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, false);
style.color = getNodeColor("bundle", isFocused);
@@ -423,6 +453,16 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused)
return style;
}
GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfQualifier()
{
NodeStyle style;
style.color = getNodeColor("qualifier", false);
style.borderWidth = 2;
return style;
}
GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(Edge::EdgeType type, bool isActive, bool isFocused)
{
EdgeStyle style;
@@ -571,6 +611,14 @@ void GraphViewStyle::addIcon(Node::NodeType type, bool hasChildren, NodeStyle* s
{
switch (type)
{
case Node::NODE_NAMESPACE:
case Node::NODE_PACKAGE:
style->iconPath = ResourcePaths::getGuiPath() + "graph_view/images/namespace.png";
style->iconSize = s_fontSize - 4;
style->iconOffset.x = -1;
style->iconOffset.y = 5;
return;
case Node::NODE_ENUM:
style->iconPath = ResourcePaths::getGuiPath() + "graph_view/images/enum_1.png";
break;
+5 -1
View File
@@ -26,6 +26,7 @@ public:
int spacingX;
int spacingY;
int spacingA;
int minWidth;
@@ -102,6 +103,7 @@ public:
static size_t getFontSizeOfAccessNode();
static size_t getFontSizeOfExpandToggleNode();
static size_t getFontSizeOfCountCircle();
static size_t getFontSizeOfQualifier();
static std::string getFontNameForNodeType(Node::NodeType type);
static std::string getFontNameOfAccessNode();
@@ -112,11 +114,13 @@ public:
static NodeMargins getMarginsOfExpandToggleNode();
static NodeMargins getMarginsOfBundleNode();
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, bool hasQualifier);
static NodeStyle getStyleOfAccessNode();
static NodeStyle getStyleOfExpandToggleNode();
static NodeStyle getStyleOfCountCircle();
static NodeStyle getStyleOfBundleNode(bool isFocused);
static NodeStyle getStyleOfQualifier();
static EdgeStyle getStyleForEdgeType(Edge::EdgeType type, bool isActive, bool isFocused);
@@ -31,6 +31,16 @@ public:
nodes.push_back(node);
}
void addNode(const NameHierarchy& nameHierarchy)
{
ActiveNode node;
node.nodeId = 0;
node.type = Node::NODE_UNDEFINED;
node.nameHierarchy = nameHierarchy;
nodes.push_back(node);
}
static const std::string getStaticType()
{
return "MessageActivateNodes";