Original Post
Im creating an application that basically just displays nodes linked by lines, which the user can perform the following :
- Add a node
- Delete a node
- Move a node
- Join a node to another node
So i figured for this I could use the MVC design pattern, where the model would store the list of nodes, the view would display the nodes on screen, and then the controller would allow for the previously mentioned operations. But I'm having trouble implementing it. I basically have a single win32 window, and I use GDI to draw the nodes and lines, and at the moment I have the operations be performed on windows notifications, as the window has a pointer to the node list.
So when I recieve a message from a drop down menu to add a node, a node is added to the list.
when I recieve a message from a drop down menu to delete a node, a node is deleted, provided one has been selected. Where I store the selected node on mouse click events.
Same with moving, provided a node is selected, and a mouse move event occurs, I move the selected node.
Node joining just works by joined the node on a mouse down event with the node on a mouse up event.
But this doesnt sound like the MVC controller. I seem to have mixed the View and controller into one, and the View modifies the model. How would you go about doing what Im doing?
There is some stuff I can move such as, intstead the model coud register with the view, so that messages such as Add and delete node are instead sent to the model. But what about moving nodes? The view needs access to the nodelist so it can perform the collision detection of the clicking to mark selected nodes. And movement is all really done in the views window dimensions.
- Add a node
- Delete a node
- Move a node
- Join a node to another node
So i figured for this I could use the MVC design pattern, where the model would store the list of nodes, the view would display the nodes on screen, and then the controller would allow for the previously mentioned operations. But I'm having trouble implementing it. I basically have a single win32 window, and I use GDI to draw the nodes and lines, and at the moment I have the operations be performed on windows notifications, as the window has a pointer to the node list.
So when I recieve a message from a drop down menu to add a node, a node is added to the list.
when I recieve a message from a drop down menu to delete a node, a node is deleted, provided one has been selected. Where I store the selected node on mouse click events.
Same with moving, provided a node is selected, and a mouse move event occurs, I move the selected node.
Node joining just works by joined the node on a mouse down event with the node on a mouse up event.
But this doesnt sound like the MVC controller. I seem to have mixed the View and controller into one, and the View modifies the model. How would you go about doing what Im doing?
There is some stuff I can move such as, intstead the model coud register with the view, so that messages such as Add and delete node are instead sent to the model. But what about moving nodes? The view needs access to the nodelist so it can perform the collision detection of the clicking to mark selected nodes. And movement is all really done in the views window dimensions.