Class Views.MinimapIcon
MinimapIcon is responsible for handling all visual components of this kind of icon that's one of the most important parts of any addon.
It aims to provide a simple way to create and manage the icon that will be displayed on the minimap, allowing players to interact with it and providing callbacks for clicks.
Local Functions
views.minimapicon.config (...) | Decides whether this instance should proxy to the player's or the global configuration instance. |
views.minimapicon.createIconFrame () | Creates and sets up a minimap icon frame. |
views.minimapicon.createIconOverlay () | Creates an icon overlay for the minimap icon. |
views.minimapicon.createIconTexture () | Creates and sets up the minimap icon texture, which is equivalent to saying that it creates the minimap icon itself. |
views.minimapicon.getMinimapRadius () | Gets the minimap icon radius based on the minimap width. |
views.minimapicon.getProperty (key) | Gets a minimap icon property using the library configuration instance. |
views.minimapicon.getPropertyKey (key) | Gets the property key used by the minimap icon instance to persist its state using the library configuration instance. |
views.minimapicon.getTooltipLines () | Gets the minimap icon tooltip lines set on creation or by the developer or a list of default lines if none is provided. |
views.minimapicon.hide () | Hides the minimap icon. |
views.minimapicon.isPersistingState () | Determines if the minimap icon is persisting its state. |
views.minimapicon.maybeInvokeCallbacks (button) | May invoke the minimap icon callbacks if the cursor is over the icon. |
views.minimapicon.onDrag () | Executes when the minimap icon is being dragged for repositioning. |
views.minimapicon.onEnter () | Executes when the mouse enters the minimap icon. |
views.minimapicon.onLeave () | Executes when the mouse leaves the minimap icon. |
views.minimapicon.onMouseDown (button) | Executes when the mouse is pressed down on the minimap icon. |
views.minimapicon.onMouseUp (button) | Executes when the mouse is released on the minimap icon. |
views.minimapicon.onUpdate () | Executes when the minimap icon frame is updated. |
views.minimapicon.setAnglePositionOnCreation () | Sets the minimap icon angle position on creation. |
views.minimapicon.setProperty (key, any) | Sets a minimap icon property using the library configuration instance. |
views.minimapicon.setPropertyIfPersistingState (key, any) | Sets a minimap icon state property if it's persisting its state. |
views.minimapicon.setVisibilityOnCreation () | Sets the minimap icon visibility on creation. |
views.minimapicon.shouldMove () | Determines whether the minimap icon should move instead of being clicked. |
views.minimapicon.show () | Shows the minimap icon. |
views.minimapicon.updatePosition (angleInDegrees) | Calculates the minimap icon position based on the angle in degrees. |
Methods
views.minimapicon:create () | Creates the minimap icon visual components. |
views.minimapicon:setCallbackOnLeftClick (value) | Sets the minimap icon callback for left clicks. |
views.minimapicon:setCallbackOnRightClick (value) | Sets the minimap icon callback for right clicks. |
views.minimapicon:setFirstAnglePosition (value) | Sets the minimap icon first angle position in degrees. |
views.minimapicon:setIcon (value) | Sets the minimap icon image, which will be passed to the icon texture. |
views.minimapicon:setPersistStateByPlayer (value) | Sets the minimap icon instance to have its stated persisted in the player's configuration instead of the global one. |
views.minimapicon:setTooltipLines (value) | Sets the minimap tooltip lines. |
views.minimapicon:setVisibility (visible) | Sets the minimap icon visibility. |
Metamethods
views.minimapicon:__construct (id) | MinimapIcon constructor. |
Local Functions
Methods- views.minimapicon.config (...)
-
Decides whether this instance should proxy to the player's or the global
configuration instance.
By default, the minimap icon will proxy to the global configuration instance.
Parameters:
- ...
- views.minimapicon.createIconFrame ()
-
Creates and sets up a minimap icon frame.
Returns:
-
table
The minimap icon frame created by CreateFrame
- views.minimapicon.createIconOverlay ()
-
Creates an icon overlay for the minimap icon.
Returns:
-
table
The minimap icon overlay texture created by CreateTexture
- views.minimapicon.createIconTexture ()
-
Creates and sets up the minimap icon texture, which is equivalent to saying that
it creates the minimap icon itself.
Returns:
-
table
The minimap icon texture created by CreateTexture
- views.minimapicon.getMinimapRadius ()
-
Gets the minimap icon radius based on the minimap width.
Returns:
-
number
The minimap icon radius
- views.minimapicon.getProperty (key)
-
Gets a minimap icon property using the library configuration instance.
This method is used internally by the library to persist state. It's not meant to be called by addons.
Parameters:
- key string The property key
Returns:
-
any
The property value
- views.minimapicon.getPropertyKey (key)
-
Gets the property key used by the minimap icon instance to persist its state
using the library configuration instance.
A property key is a result of the concatenation of a static prefix, this instance's id, and the key parameter.
This method is used internally by the library to persist state. It's not meant to be called by addons.
Parameters:
- key string The property key
Returns:
-
string
The property key used by the minimap icon instance to persist
its state using the library configuration instance
- views.minimapicon.getTooltipLines ()
- Gets the minimap icon tooltip lines set on creation or by the developer or a list of default lines if none is provided.
- views.minimapicon.hide ()
-
Hides the minimap icon.
This is just a facade method to call Hide() on the minimap icon frame. However, it shouldn't be used by addons as an internal method. Use setVisibility(false) instead.
See also:
- views.minimapicon.isPersistingState ()
-
Determines if the minimap icon is persisting its state.
A minimap icon is considered to be persisting its state if the library is created with a configuration set.
Returns:
-
boolean
true if the minimap icon is persisting its state, false otherwise
- views.minimapicon.maybeInvokeCallbacks (button)
-
May invoke the minimap icon callbacks if the cursor is over the icon.
Parameters:
- button
- views.minimapicon.onDrag ()
- Executes when the minimap icon is being dragged for repositioning.
- views.minimapicon.onEnter ()
- Executes when the mouse enters the minimap icon.
- views.minimapicon.onLeave ()
- Executes when the mouse leaves the minimap icon.
- views.minimapicon.onMouseDown (button)
-
Executes when the mouse is pressed down on the minimap icon.
Parameters:
- button
- views.minimapicon.onMouseUp (button)
-
Executes when the mouse is released on the minimap icon.
Parameters:
- button
- views.minimapicon.onUpdate ()
- Executes when the minimap icon frame is updated.
- views.minimapicon.setAnglePositionOnCreation ()
-
Sets the minimap icon angle position on creation.
This method is called when the minimap icon is created, and it sets the angle position to the first position set by the developer or the persisted position if it's found.
This method shouldn't be called directly. It's considered a complement to the create() method.
- views.minimapicon.setProperty (key, any)
-
Sets a minimap icon property using the library configuration instance.
This method is used internally by the library to persist state. It's not meant to be called by addons.
Parameters:
- key string The property key
- any value The property value
- views.minimapicon.setPropertyIfPersistingState (key, any)
-
Sets a minimap icon state property if it's persisting its state.
This method is used internally by the library to persist state. It's not meant to be called by addons.
Parameters:
- key string The property key
- any value The property value
- views.minimapicon.setVisibilityOnCreation ()
-
Sets the minimap icon visibility on creation.
This method is called when the minimap icon is created, and it sets the visibility to true (default) or the persisted state if it's found.
This method shouldn't be called directly. It's considered a complement to the create() method.
- views.minimapicon.shouldMove ()
-
Determines whether the minimap icon should move instead of being clicked.
Returns:
-
boolean
Whether the minimap icon should move
- views.minimapicon.show ()
-
Shows the minimap icon.
This is just a facade method to call Show() on the minimap icon frame. However, it shouldn't be used by addons as an internal method. Use setVisibility(true) instead.
See also:
- views.minimapicon.updatePosition (angleInDegrees)
-
Calculates the minimap icon position based on the angle in degrees.
When updating the position, the angle position will also be persisted if this instance is persisting its state. That guarantees that the icon will be in the same position when the player logs in again.
Parameters:
- angleInDegrees number The angle in degrees
Returns:
-
Views.MinimapIcon
The minimap icon instance, for method chaining
Methods
- views.minimapicon:create ()
- Creates the minimap icon visual components.
- views.minimapicon:setCallbackOnLeftClick (value)
-
Sets the minimap icon callback for left clicks.
Parameters:
- value function The callback function
Returns:
-
Views.MinimapIcon
The minimap icon instance, for method chaining
Usage:
icon:setCallbackOnLeftClick(function() print('Left click!') end)
- views.minimapicon:setCallbackOnRightClick (value)
-
Sets the minimap icon callback for right clicks.
Parameters:
- value function The callback function
Returns:
-
Views.MinimapIcon
The minimap icon instance, for method chaining
Usage:
icon:setCallbackOnRightClick(function() print('Right click!') end)
- views.minimapicon:setFirstAnglePosition (value)
-
Sets the minimap icon first angle position in degrees.
The first angle position is the position that the minimap icon will have when it's first created. If the player moves the icon and this instance is persisting its state, this property will be ignored.
It's important to mention that the angle represented by 0.0 is the right side (or 3 o'clock, east) of the minimap, and the angle increases counterclockwise, which means that 90.0 is the top side (or 12 o'clock, north), 180.0 is the left side (or 9 o'clock, west), and 270.0 is the bottom side (or 6 o'clock, south).
Parameters:
- value number The first angle position in degrees
Returns:
-
Views.MinimapIcon
The minimap icon instance, for method chaining
Usage:
icon:setFirstAnglePosition(225.0)
- views.minimapicon:setIcon (value)
-
Sets the minimap icon image, which will be passed to the icon texture.
Parameters:
- value string The image path
Returns:
-
Views.MinimapIcon
The minimap icon instance, for method chaining
Usage:
icon:setImage('Interface\\Icons\\INV_Misc_QuestionMark')
- views.minimapicon:setPersistStateByPlayer (value)
-
Sets the minimap icon instance to have its stated persisted in the player's
configuration instead of the global one.
Parameters:
- value boolean Whether the minimap icon should persist its state by player
Returns:
-
Views.MinimapIcon
The minimap icon instance, for method chaining
Usage:
icon:setPersistStateByPlayer(true)
- views.minimapicon:setTooltipLines (value)
-
Sets the minimap tooltip lines.
If no lines are provided, the tooltip will be displayed with default information.
Parameters:
- value string[] The tooltip lines
Returns:
-
Views.MinimapIcon
The minimap icon instance, for method chaining
Usage:
icon:setTooltipLines({ 'Click to open settings', 'Right click to show a panel', 'Drag this icon to move', })
- views.minimapicon:setVisibility (visible)
-
Sets the minimap icon visibility.
This is the method to be called by addons to show or hide the minimap icon, instead of the local show() and hide(), considering that it not only controls the minimap icon visibility but also persists the state if persistence is enabled.
Parameters:
- visible boolean The visibility state
Returns:
-
Views.MinimapIcon
The minimap icon instance, for method chaining
Metamethods
- views.minimapicon:__construct (id)
-
MinimapIcon constructor.
Parameters:
- id string The unique identifier for this icon, or 'default' if none is provided