ui: moved subnode layouting from GraphView to GraphController
This change moves nested layouting of the Graph to GraphController. The DummyNodes get the correct size assigned, as well as a visible flag. Mouse interaction with the Graph is now handled via the GraphController, which makes it easier to undo them or reuse the changed state after graph updates.
This commit is contained in:
@@ -6,14 +6,16 @@
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateToken.h"
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeExpand.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeMove.h"
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
#include "component/controller/GraphLayouter.h"
|
||||
#include "component/view/GraphView.h"
|
||||
|
||||
struct DummyNode;
|
||||
struct DummyEdge;
|
||||
class Graph;
|
||||
class GraphView;
|
||||
class GraphAccess;
|
||||
class Node;
|
||||
|
||||
@@ -21,21 +23,59 @@ class GraphController
|
||||
: public Controller
|
||||
, public MessageListener<MessageActivateToken>
|
||||
, public MessageListener<MessageActivateTokens>
|
||||
, public MessageListener<MessageGraphNodeExpand>
|
||||
, public MessageListener<MessageGraphNodeMove>
|
||||
{
|
||||
public:
|
||||
struct Margins
|
||||
{
|
||||
Margins();
|
||||
|
||||
int left;
|
||||
int right;
|
||||
|
||||
int top;
|
||||
int bottom;
|
||||
|
||||
int betweenX;
|
||||
int betweenY;
|
||||
|
||||
int minWidth;
|
||||
float charWidth;
|
||||
};
|
||||
|
||||
GraphController(GraphAccess* graphAccess);
|
||||
~GraphController();
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageActivateToken* message);
|
||||
virtual void handleMessage(MessageActivateTokens* message);
|
||||
virtual void handleMessage(MessageGraphNodeExpand* message);
|
||||
virtual void handleMessage(MessageGraphNodeMove* message);
|
||||
|
||||
GraphView* getView();
|
||||
GraphView* getView() const;
|
||||
|
||||
void createDummyGraphForTokenIds(const std::vector<Id>& tokenIds);
|
||||
DummyNode createDummyNodeTopDown(Node* node, std::vector<DummyEdge>* dummyEdges) const;
|
||||
DummyNode createDummyNodeTopDown(Node* node);
|
||||
|
||||
void setActiveAndVisibility(const std::vector<Id>& activeTokenIds);
|
||||
bool setNodeActiveAndVisibilityRecursiveBottomUp(DummyNode& node, const std::vector<Id>& activeTokenIds) const;
|
||||
void setNodeVisibilityRecursiveTopDown(DummyNode& node) const;
|
||||
|
||||
void layoutNesting();
|
||||
void layoutNestingRecursive(DummyNode& node) const;
|
||||
|
||||
Margins getMarginsForDummyNode(DummyNode& node) const;
|
||||
DummyNode* findDummyNodeRecursive(std::vector<DummyNode>& nodes, Id tokenId);
|
||||
DummyNode* findDummyNodeAccessRecursive(std::vector<DummyNode>& nodes, Id parentId, TokenComponentAccess::AccessType type);
|
||||
|
||||
GraphAccess* m_graphAccess;
|
||||
GraphView::Metrics m_viewMetrics;
|
||||
|
||||
std::vector<DummyNode> m_dummyNodes;
|
||||
std::vector<DummyEdge> m_dummyEdges;
|
||||
|
||||
std::vector<Id> m_activeTokenIds;
|
||||
};
|
||||
|
||||
#endif // GRAPH_CONTROLLER_H
|
||||
|
||||
Reference in New Issue
Block a user