I'm working on drawing application and I want to provide grid with snap to grid functionality. I'm trying to find the right way how to do that (ideally some design pattern), but I'm quite confused about the right class which should be responsible for that.
I have editor class which has an active tool object. Editor is listening to all user actions (mouse click, mouse move and so on..) and passes them to the active tool object. Active tool object then handles those events and renders shape based on its state (first click activates the tool, then it listens to mouse move and draws preview of the shape and second click creates the shape in my model class).
I'm thinking about using the Intercepting Filter pattern - every event will go through filter first and the result will be passed to active tool then. I guess that could work for object creation, but what to do with move and resize actions? Those depend on actual object which is being moved/resized.