Hot Door CORE  0.7.0
Adobe® Illustrator® Plug-in Library
Public Member Functions | Static Public Member Functions | List of all members
hdi::core::EyeDropperTool Class Reference

Hidden eye dropper tool, to be used programmatically only, that allows for selection of a color from the current document (the Illustrator eye dropper always sets the toolbar fill/stroke color and does not allow for interception of the selected color, whereas this tool simply provides the color under the cursor to the caller) More...

#include <hdicoreEyeDropperTool.h>

Public Member Functions

virtual AIToolHandle aiToolHandle () const
 Gets the tool handle for the eye dropper tool. More...
 
virtual bool selected () const
 Gets whether the eye dropper tool is the currently selected tool. More...
 
virtual void select ()
 Sets the eye dropper tool as the current tool, storing the previously selected tool for later resuming. More...
 
virtual void deselect ()
 Deselects the eye dropper tool, causing the previously selected tool to become current again. More...
 
virtual std::string title () const
 Gets the eye dropper tool's title. More...
 
virtual std::string tip () const
 Gets the eye dropper tool's tip string. More...
 
virtual ArtboardPoint cursorLoc () const
 Gets the current location of the cursor. More...
 
virtual Callback *const trackCallback () const
 Gets the registered callback for the tool tracking event (mouse move) More...
 
virtual void setTrackCallback (const Callback &cb_)
 Sets the callback for the tool tracking event (mouse move) More...
 
virtual Callback *const dragCallback () const
 Gets the registered callback for the drag event. More...
 
virtual void setDragCallback (const Callback &cb_)
 Sets the callback for the drag event. More...
 
virtual Callback *const mouseUpCallback () const
 Gets the registered callback for the mouse up event. More...
 
virtual void setMouseUpCallback (const Callback &cb_)
 Sets the callback for the mouse up event. More...
 
virtual bool shiftKeyDown () const
 Determines whether the shift key is down. More...
 
virtual bool commandKeyDown () const
 Determines whether the command key is down. More...
 
virtual bool optionKeyDown () const
 Determines whether the option key is down. More...
 
virtual bool controlKeyDown () const
 Determines whether the control key is down. More...
 
virtual PathStyle currentStyle () const
 Gets the current path style for the eye dropper tool. More...
 

Static Public Member Functions

static EyeDropperTool *const create ()
 Creates the singleton instance of the EyeDropperTool class. More...
 
static EyeDropperTool *const instance ()
 Acquires the singleton instance of the EyeDropperTool class. More...
 
static void destroy ()
 Destroys the singleton instance of the EyeDropperTool class. More...
 

Detailed Description

Hidden eye dropper tool, to be used programmatically only, that allows for selection of a color from the current document (the Illustrator eye dropper always sets the toolbar fill/stroke color and does not allow for interception of the selected color, whereas this tool simply provides the color under the cursor to the caller)

Warning
Usage of this class will cause your plugin to "become" a tool plugin, and therefore its file must be placed in the Illustrator Tools folder to function properly.
This tool, like all Illustrator tools, cannot be used from within the context of a modal dialog. If you need this sort of behavior, consider switching to a floating dialog instead.
Note
To use this tool, first create it during plugin startup and set your mouse event callbacks, then select it during e.g. some UI event. The user can then move the cursor around the document and click a desired color, and you can acquire the color in your track, drag, and/or mouse up callbacks. The tool will automatically deselect itself upon the mouse up event, restoring whichever tool was current before the eye dropper was selected. Remember to destroy the tool during plugin shutdown.

Member Function Documentation

virtual AIToolHandle hdi::core::EyeDropperTool::aiToolHandle ( ) const
virtual

Gets the tool handle for the eye dropper tool.

Author
GW
Date
09/2014
Returns
AIToolHandle for this object
Note
Generally, you shouldn't need to call this method. Only use it if you know what you're doing. If a specific piece of functionality provided by Illustrator is not handled by this class (or related classes), then it should probably be added to the hdi_core library.
virtual bool hdi::core::EyeDropperTool::commandKeyDown ( ) const
virtual

Determines whether the command key is down.

Author
GW
Date
09/2014
Returns
true if the command key was down in the last tool event
Note
Windows machines do not have a command key. If this method is called on a Windows machine, it will return the same value as the controlKeyDown() method (because the control key is the closest command key analog on Windows).
The return value is only valid if the last message the plugin received was an eye dropper tool-related event.
virtual bool hdi::core::EyeDropperTool::controlKeyDown ( ) const
virtual

Determines whether the control key is down.

Author
GW
Date
09/2014
Returns
true if the control key was down in the last tool event
Note
The return value is only valid if the last message the plugin received was an eye dropper tool-related event.
static EyeDropperTool* const hdi::core::EyeDropperTool::create ( )
static

Creates the singleton instance of the EyeDropperTool class.

Author
GW
Date
09/2014
Returns
The EyeDropperTool instance object
virtual PathStyle hdi::core::EyeDropperTool::currentStyle ( ) const
virtual

Gets the current path style for the eye dropper tool.

Author
GW
Date
09/2014
Returns
Either the path style for the art object under the cursor, or a "synthetic" path style for the pixel color under the cursor
Note
The return value of this method is only valid when called from within an EyeDropperTool mouse event callback.
If artwork that can have a path style is under the cursor, then this is acquired and returned. If art that cannot have a path style is under the cursor, then the pixel color is acquired and placed in the fill color of the path style. If no art is under the cursor, then the pixel color is acquired and placed in the fill color of the path style.
virtual ArtboardPoint hdi::core::EyeDropperTool::cursorLoc ( ) const
virtual

Gets the current location of the cursor.

Author
GW
Date
09/2014
Returns
The last known cursor location for the tool
Note
The cursor location is automatically set when a mouse event occurs
virtual void hdi::core::EyeDropperTool::deselect ( )
virtual

Deselects the eye dropper tool, causing the previously selected tool to become current again.

Author
GW
Date
09/2014
static void hdi::core::EyeDropperTool::destroy ( )
static

Destroys the singleton instance of the EyeDropperTool class.

Author
GW
Date
09/2014
virtual Callback* const hdi::core::EyeDropperTool::dragCallback ( ) const
virtual

Gets the registered callback for the drag event.

Author
GW
Date
09/2014
Returns
Callback for dragging, or NULL if none
static EyeDropperTool* const hdi::core::EyeDropperTool::instance ( )
static

Acquires the singleton instance of the EyeDropperTool class.

Author
GW
Date
09/2014
Returns
The EyeDropperTool instance object
Note
This method will always return NULL until create() has been called
virtual Callback* const hdi::core::EyeDropperTool::mouseUpCallback ( ) const
virtual

Gets the registered callback for the mouse up event.

Author
GW
Date
09/2014
Returns
Callback for mouse up, or NULL if none
virtual bool hdi::core::EyeDropperTool::optionKeyDown ( ) const
virtual

Determines whether the option key is down.

Author
GW
Date
09/2014
Returns
true if the option key was down in the last tool event
Note
The option key on Mac is akin to the alt key on Windows.
The return value is only valid if the last message the plugin received was an eye dropper tool-related event.
virtual void hdi::core::EyeDropperTool::select ( )
virtual

Sets the eye dropper tool as the current tool, storing the previously selected tool for later resuming.

Author
GW
Date
09/2014
virtual bool hdi::core::EyeDropperTool::selected ( ) const
virtual

Gets whether the eye dropper tool is the currently selected tool.

Author
GW
Date
09/2014
Returns
true if the tool is selected, false otherwise
virtual void hdi::core::EyeDropperTool::setDragCallback ( const Callback cb_)
virtual

Sets the callback for the drag event.

Author
GW
Date
09/2014
Parameters
cb_The new dragging callback
virtual void hdi::core::EyeDropperTool::setMouseUpCallback ( const Callback cb_)
virtual

Sets the callback for the mouse up event.

Author
GW
Date
09/2014
Parameters
cb_The new mouse up callback
virtual void hdi::core::EyeDropperTool::setTrackCallback ( const Callback cb_)
virtual

Sets the callback for the tool tracking event (mouse move)

Author
GW
Date
09/2014
Parameters
cb_The new tracking callback
virtual bool hdi::core::EyeDropperTool::shiftKeyDown ( ) const
virtual

Determines whether the shift key is down.

Author
GW
Date
09/2014
Returns
true if the shift key was down in the last tool event
Note
The return value is only valid if the last message the plugin received was an eye dropper tool-related event.
virtual std::string hdi::core::EyeDropperTool::tip ( ) const
virtual

Gets the eye dropper tool's tip string.

Author
GW
Date
09/2014
Returns
The rollover tip for the tool, as UTF-8
virtual std::string hdi::core::EyeDropperTool::title ( ) const
virtual

Gets the eye dropper tool's title.

Author
GW
Date
09/2014
Returns
The title for the tool, as UTF-8
virtual Callback* const hdi::core::EyeDropperTool::trackCallback ( ) const
virtual

Gets the registered callback for the tool tracking event (mouse move)

Author
GW
Date
09/2014
Returns
Callback for tracking, or NULL if none