Understanding CORE tool class - Printable Version +- Hot Door CORE Forum (http://hotdoorcore.com/forum) +-- Forum: All forums (http://hotdoorcore.com/forum/forumdisplay.php?fid=1) +--- Forum: Getting started (http://hotdoorcore.com/forum/forumdisplay.php?fid=6) +--- Thread: Understanding CORE tool class (/showthread.php?tid=141) |
Understanding CORE tool class - Gaxx - 06-09-2017 Hello. I'm having some difficulties understanding lifecycles of hdi_core Tool class and hope you'll point me in the right direction. For simplicity lets say I'm building a tool that makes a triangle from a base line and a point. Code: Tool = hdi::core::Tool(hdi::core::Tool(), NULL,"Tool","Tool",ID, ID); I've created a tool. I want it to draw a line when dragged and then create a triangle from a point where user made a click. So I make a drag callback Code: void Toolset::DragTool() Code: void Toolset::MouseUpTool() So far so good. What I want is to get a behaviour similar to drag callback inside the track callback - user moves cursor, triangle draft gets drawn until a click is made. However I do not fully understand how to handle undo function in such a scenario. I imagine track function to look something like this Code: void Toolset::TrackTool() RE: Understanding CORE tool class - garrett - 06-09-2017 Illustrator does indeed handle art drawn during tool drags by undoing the art on each drag event. If you coerce Illustrator into not undoing the art created during a tool drag then a nasty mess of thousands of annotated paths (one for each event) will appear on screen. So, during a tool drag event, draw whatever art you wish and then draw the art again during the final mouse-up event — it will not be undone by Illustrator in that context. The "final" mouse up event is determined by your tool's logic, as it might require 1, 2, ..., n clicks for your use-case. While you can create art during other tool events, it is not recommended. Adobe intends you to use annotators for "drawing" during e.g. mouse-track events. Personally, I recommend storing & updating the points/beziers for the desired art during your mouse track and/or drag events in class members, using them to annotate during track events and to create actual art during drag/mouse-up events. |