ui: GraphView can set active tokenId on node clicked

By now the graph displays the active node, without neighbours or anything, and clicking a node sets the active token id to the clicked nodes id.

fortune cookie message = Be prepared to accept an exciting opportunity in the future.
This commit is contained in:
Manuel Dobusch
2014-07-07 16:53:44 +02:00
parent e38914887d
commit 0f60a9a556
14 changed files with 215 additions and 62 deletions
@@ -1,11 +1,12 @@
#include "component/controller/GraphController.h"
#include "component/view/graphElements/GraphEdge.h"
#include "component/view/graphElements/GraphNode.h"
#include "component/view/GraphView.h"
#include "data/access/GraphAccess.h"
#include "utility/logging/logging.h"
GraphController::GraphController(std::shared_ptr<GraphAccess> graphAccess)
: m_graphAccess(graphAccess)
{
@@ -15,6 +16,24 @@ GraphController::~GraphController()
{
}
void GraphController::handleMessage(MessageActivateToken* message)
{
GraphView* view = getView();
if (view != NULL)
{
std::string name = m_graphAccess->getNameForNodeWithId(message->tokenId);
DummyNode node(name, message->tokenId, Vec2i(0,0));
std::vector<DummyNode> nodes;
nodes.push_back(node);
std::vector<DummyEdge> edges;
view->rebuildGraph(nodes, edges);
}
}
GraphView* GraphController::getView()
{
return Controller::getView<GraphView>();
@@ -1,18 +1,24 @@
#ifndef GRAPH_CONTROLLER_H
#define GRAPH_CONTROLLER_H
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageActivateToken.h"
#include "component/controller/Controller.h"
class GraphView;
class GraphAccess;
class GraphController: public Controller
class GraphController:
public Controller,
public MessageListener<MessageActivateToken>
{
public:
GraphController(std::shared_ptr<GraphAccess> graphAccess);
~GraphController();
private:
virtual void handleMessage(MessageActivateToken* message);
GraphView* getView();
std::shared_ptr<GraphAccess> m_graphAccess;