GIcon class

A display object that renders an icon from the IconData class. It supports customizing the size, color, and font family of the icon.

Inheritance
Available Extensions

Constructors

GIcon(IconData data, [Color color = kColorWhite, double size = 24.0])
Creates a new instance of GIcon with the specified IconData, color, and size.

Properties

$alpha double
(Internal usage) The alpha (transparency) value of this object, a value between 0.0 (fully transparent) and 1.0 (fully opaque).
getter/setter pairinherited
$colorize Color?
(Internal usage) The color to apply to this object.
getter/setter pairinherited
$debugBounds bool
(Internal usage) Whether to show debug bounds for this object.
getter/setter pairinherited
$debugBoundsPaint Paint?
(Internal usage) Defines the debug paint used to show the bounds of this display object when debug mode is enabled. By default, it uses a magenta stroke with a width of 1. Override this property to use a custom debug paint.
getter/setter pairinherited
$debugLastLayerBounds GRect?
(Internal usage) Tracks the last layer bounds used for rendering this display object using getBounds($parent).
getter/setter pairinherited
$filters List<GBaseFilter>?
(Internal usage) The filters applied to this object.
getter/setter pairinherited
$hasColorize bool
(Internal usage) Whether this object has a color applied to it.
no setterinherited
$hasTouchableArea bool
(Internal usage) Optimization flag indicating whether this object has a touchable area.
getter/setter pairinherited
$hasVisibleArea bool
(Internal usage) Optimization flag indicating whether this object has a visible area.
getter/setter pairinherited
$lastClickTime double
(Internal usage) The time of the last mouse click.
getter/setter pairinherited
$mask GShape?
(Internal usage) The mask of this object, used for masking.
getter/setter pairinherited
$maskee GDisplayObject?
(Internal usage) The display object that acts as a mask of this object.
getter/setter pairinherited
$matrixDirty bool
(Internal usage) Indicates whether the matrix of this object needs to be recalculated.
getter/setter pairinherited
$mouseDownObj GDisplayObject?
(Internal usage) The object that the mouse was last pressed on.
getter/setter pairinherited
$mouseOverObj GDisplayObject?
(Internal usage) The object that the mouse is currently over.
getter/setter pairinherited
$onAdded Signal?
(Internal)
getter/setter pairinherited
$onAddedToStage Signal?
(Internal)
getter/setter pairinherited
$onMouseClick EventSignal<MouseInputData>?
(Internal)
getter/setter pairinherited
$onMouseDoubleClick EventSignal<MouseInputData>?
(Internal)
getter/setter pairinherited
$onMouseDown EventSignal<MouseInputData>?
(Internal)
getter/setter pairinherited
$onMouseMove EventSignal<MouseInputData>?
(Internal)
getter/setter pairinherited
$onMouseOut EventSignal<MouseInputData>?
(Internal)
getter/setter pairinherited
$onMouseOver EventSignal<MouseInputData>?
(Internal)
getter/setter pairinherited
$onMouseUp EventSignal<MouseInputData>?
(Internal)
getter/setter pairinherited
$onMouseWheel EventSignal<MouseInputData>?
(Internal)
getter/setter pairinherited
$onPostPaint EventSignal<Canvas>?
(Internal)
getter/setter pairinherited
$onPrePaint EventSignal<Canvas>?
(Internal)
getter/setter pairinherited
$onPreTransform EventSignal<Canvas>?
(Internal)
getter/setter pairinherited
$onRemoved Signal?
(Internal)
getter/setter pairinherited
$onRemovedFromStage Signal?
(Internal)
getter/setter pairinherited
$onRightMouseDown EventSignal<MouseInputData>?
(Internal)
getter/setter pairinherited
$onZoomPan EventSignal<MouseInputData>?
(Internal)
getter/setter pairinherited
$parent GDisplayObjectContainer?
(Internal usage) The parent display object container that this object is a child of.
getter/setter pairinherited
$useSaveLayerBounds bool
(Internal usage) When enabled, a rectangle is created to save the layer for better rendering performance.
getter/setter pairinherited
allowSaveLayer bool
When enabled, the saveLayer() feature is used for better rendering performance. Disabling it may provide better performance for certain display objects. Childless DisplayObjects, like GShape and GBitmap, have their own Paint() so no need to use an expensive saveLayer().
getter/setter pairinherited
alpha double
Returns the alpha (transparency) value of this object.
getter/setter pairinherited-getteroverride-setter
base GDisplayObject
Returns the base object, i.e. the topmost parent in the display hierarchy.
no setterinherited
bounds GRect?
TODO: should be cached. Returns the bounds of this object in its local coordinate space.
no setterinherited
color Color
Gets the current color of the icon.
getter/setter pair
colorize Color?
Gets the color applied to this object.
getter/setter pairinherited
data IconData?
Gets the IconData object that represents the icon to be displayed.
getter/setter pair
fill double?
  • See GlyphVariations.fill.
  • getter/setter pair
    filterPaint Paint
    The paint to use for filters that require a paint.
    getter/setter pairinherited
    filters List<GBaseFilter>?
    Gets the filters applied to this object.
    getter/setter pairinherited
    grade double?
  • See GlyphVariations.grade.
  • getter/setter pair
    hasFilters bool
    Returns true if this object has any filters applied.
    no setterinherited
    hashCode int
    The hash code for this object.
    no setterinherited
    height double
    Indicates the height of the display object, in dp. The height is calculated based on the bounds of the content of the display object. When you set the height property, the scaleX property is adjusted accordingly, as shown in the following code:
    getter/setter pairinherited
    inStage bool
    Returns true if this object is on the stage.
    no setterinherited
    isMask bool
    Returns whether this object is currently being used as a mask for another object.
    no setterinherited
    isRotated bool
    Returns whether this object has any rotation or skew transformation.
    no setterinherited
    mask GShape?
    Returns the mask of this object.
    getter/setter pairinherited
    maskInverted bool
    Whether the object should apply an inverted mask. can be set on the Shape mask, or the maskee DisplayObject.
    getter/setter pairinherited
    maskRect GRect?
    The rectangular area of the mask.
    getter/setter pairinherited
    maskRectCornerRadius double?
    The corner radius of the mask.
    getter/setter pairinherited
    maskRectInverted bool
    Whether the mask is inverted or not.
    getter/setter pairinherited
    mouseEnabled bool
    Indicates whether this object can receive mouse and touch input events.
    getter/setter pairinherited
    mousePosition GPoint
    Returns the position of the mouse in the local coordinate system of this object. The mouse position is updated every frame, so this method returns the current mouse position relative to the top-left corner of this object.
    no setterinherited
    mouseUseShape bool
    Whether to use the shape of the object for mouse event detection.
    getter/setter pairinherited
    mouseX double
    The x-coordinate of the mouse or touch position in the local coordinate system of this object.
    no setterinherited
    mouseY double
    The y-coordinate of the mouse or touch position in the local coordinate system of this object.
    no setterinherited
    name String?
    Name to reference this object.
    getter/setter pairinherited
    onAdded Signal
    Returns the Signal that is triggered when an object is added to the display list.
    no setterinherited
    onAddedToStage Signal
    Returns the Signal that is triggered when an object is added to the stage.
    no setterinherited
    onMouseClick EventSignal<MouseInputData>
    A signal that is dispatched when the mouse is clicked.
    no setterinherited
    onMouseDoubleClick EventSignal<MouseInputData>
    A signal that is dispatched when the mouse is double clicked.
    no setterinherited
    onMouseDown EventSignal<MouseInputData>
    A signal that is dispatched when the mouse button is pressed down.
    no setterinherited
    onMouseMove EventSignal<MouseInputData>
    A signal that is dispatched when the mouse is moved.
    no setterinherited
    onMouseOut EventSignal<MouseInputData>
    A signal that is dispatched when the mouse leaves a component.
    no setterinherited
    onMouseOver EventSignal<MouseInputData>
    A signal that is dispatched when the mouse is over a component.
    no setterinherited
    onMouseScroll EventSignal<MouseInputData>
    A signal that is dispatched when the mouse wheel is scrolled.
    no setterinherited
    onMouseUp EventSignal<MouseInputData>
    A signal that is dispatched when the mouse button is released.
    no setterinherited
    onPostPaint EventSignal<Canvas>
    A signal that runs right after GDisplayObject.$applyPaint is called.
    no setterinherited
    onPrePaint EventSignal<Canvas>
    A signal that runs before GDisplayObject.$applyPaint, which is the render method to subclass.
    no setterinherited
    onPreTransform EventSignal<Canvas>
    A signal that runs right away when GDisplayObject.paint is called, before any mask or filters are applied. This is the first signal to run on rendering.
    no setterinherited
    onRemoved Signal
    Returns the Signal that is triggered when an object is removed from the display list.
    no setterinherited
    onRemovedFromStage Signal
    Returns the Signal that is triggered when an object is removed from the stage.
    no setterinherited
    onRightMouseDown EventSignal<MouseInputData>
    A signal that is dispatched when the right mouse button is pressed down.
    no setterinherited
    onZoomPan EventSignal<MouseInputData>
    A signal that is dispatched when a zoom/pan gesture is performed.
    no setterinherited
    opticalSize double?
  • See GlyphVariations.opticalSize.
  • getter/setter pair
    parent GDisplayObjectContainer?
    Returns the parent container.
    no setterinherited
    pivotX double
    Returns the x coordinate of the pivot point, the center of scaling and rotation.
    getter/setter pairinherited
    pivotY double
    Returns the y coordinate of the pivot point, the center of scaling and rotation.
    getter/setter pairinherited
    root GDisplayObject?
    Returns the root GDisplayObject that is the ancestor of this object (either a Stage or a null).
    no setterinherited
    rotation double
    Returns the angle of rotation in radians.
    getter/setter pairinherited
    rotationX double
    The rotation angle in radians about the x-axis for 3d transformation.
    getter/setter pairinherited
    rotationY double
    The rotation angle in radians about the y-axis for 3d transformation.
    getter/setter pairinherited
    runtimeType Type
    A representation of the runtime type of the object.
    no setterinherited
    scale double
    Shortcut for setting proportional X and Y scale values.
    getter/setter pairinherited
    scaleX double
    Returns the horizontal scale of the object.
    getter/setter pairinherited
    scaleY double
    Returns the vertical scale of the object.
    getter/setter pairinherited
    size double
    Gets the current size of the icon.
    getter/setter pair
    skewX double
    Returns the angle of skew on the x-axis in radians.
    getter/setter pairinherited
    skewY double
    Returns the angle of skew on the y-axis in radians.
    getter/setter pairinherited
    stage Stage?
    Returns the stage this object is on or null if it's not on a stage.
    no setterinherited
    textStyle TextStyle?
    Gets the TextStyle object used for customizing the icon's text style.
    getter/setter pair
    transformationMatrix GMatrix
    Gets the transformation matrix that represents the object's position, scale, rotation and skew.
    getter/setter pairinherited
    useCursor bool
    Whether to use a custom cursor for this object.
    getter/setter pairinherited
    userData Object?
    You can store any user defined data in this property for easy access.
    getter/setter pairinherited
    variations → GlyphVariations
    Returns the GlyphVariations instance for this GIcon.
    no setter
    visible bool
    Returns whether the display object is visible or not.
    getter/setter pairinherited
    weight double?
  • See GlyphVariations.weight.
  • getter/setter pair
    width double
    Indicates the width of the display object, in dp. The width is calculated based on the bounds of the content of the display object. When you set the width property, the scaleX property is adjusted accordingly, as shown in the following code:
    getter/setter pairinherited
    worldAlpha double
    Returns the alpha value of the object relative to its parent and all its ancestors.
    no setterinherited
    worldScaleX double
    Returns the horizontal scaling factor of the object relative to its parent and all its ancestors.
    no setterinherited
    worldScaleY double
    Returns the vertical scaling factor of the object relative to its parent and all its ancestors.
    no setterinherited
    worldX double
    Returns the x coordinate of the object relative to the stage and all its ancestors.
    no setterinherited
    worldY double
    Returns the y coordinate of the object relative to the stage and all its ancestors.
    no setterinherited
    x double
    The x coordinate of the display object relative to its parent's coordinate system.
    getter/setter pairinherited
    y double
    The y coordinate of the display object relative to its parent's coordinate system.
    getter/setter pairinherited
    z double
    (Experimental) The z-coordinate of this object in 3D space.
    getter/setter pairinherited

    Methods

    $applyMaskRect(Canvas? canvas) → void
    Applies the current mask to the provided Canvas.
    inherited
    $applyPaint(Canvas? canvas) → void
    (Internal usage) Applies the current paint to the canvas, drawing the glyph using a ui.Paint object, updating it if necessary.
    override
    $dispatchMouseCallback(MouseInputType type, GDisplayObject object, MouseInputData input) → void
    (Internal usage) Dispatches a mouse event to the appropriate callback functions.
    inherited
    $disposeDisplayListSignals() → void
    Removes all registered listeners and frees all display list signals.
    inherited
    $disposePointerSignals() → void
    Disposes all mouse signals to free up memory.
    inherited
    $disposeRenderSignals() → void
    Disposes all render-related signals and clears all callbacks for this instance. This method should be called when the instance is no longer needed, to prevent memory leaks.
    inherited
    $setParent(GDisplayObjectContainer? value) → void
    (Internal usage) Sets the GDisplayObjectContainer that contains this GDisplayObject.
    inherited
    $setTransformationChanged() → void
    (Internal usage) Sets the transformationChanged flag and updates the 3D flag based on whether the object has 3D properties set.
    inherited
    $updateTransformationMatrices(double? x, double? y, double pivotX, double pivotY, double scaleX, double scaleY, double skewX, double skewY, double rotation, GMatrix out) → void
    (Internal usage) Updates the transformation matrices of a display object based on the given parameters.
    inherited
    addedToStage() → void
    Called when the object is added to the stage. Should be overridden by subclasses as entry point.
    inherited
    alignPivot([Alignment alignment = painting.Alignment.center]) → void
    Adjusts the pivot point of this display object to a new location defined by the given alignment parameter, which defaults to Alignment.center. This method calculates the bounds of the object and aligns the pivot point based on the provided alignment parameter. The alignment is represented by an Alignment object, where the x and y values range from -1.0 to 1.0. For example, an Alignment of (-1.0, -1.0) represents the top left corner, while an Alignment of (1.0, 1.0) represents the bottom right corner. The pivot point represents the center point for rotations and scaling, and by default it is set to (0,0), which means that the object is rotated and scaled around the top-left corner. This method is useful to adjust the pivot point to a more suitable location before performing rotations or scaling operations. If the bounds of the object are empty, no adjustment is made to the pivot point. The resulting pivot point is stored in the pivotX and pivotY properties of this display object.
    inherited
    captureMouseInput(MouseInputData input) → void
    Captures mouse input and dispatches corresponding mouse events to this display object if it has a touchable area and mouseEnabled is set to true.
    inherited
    createImage([bool adjustOffset = true, double resolution = 1, GRect? rect]) Future<Image>
    Creates an image representation of the current state of the GDisplayObject. If adjustOffset is true, the resulting image will be offset so that its top-left corner corresponds to the top-left corner of the current bounds. If resolution is provided and is different than 1, the image will be scaled by this factor before being returned. If rect is provided, it defines a rectangle that will be used as the bounds for the image instead of the getFilterBounds of the GDisplayObject. Returns a Future that resolves to a ui.Image representing the current state of the GDisplayObject in the form of an image.
    inherited
    createImageSync([bool adjustOffset = true, double resolution = 1, GRect? rect]) Image
    Creates a synchronous image from this display object.
    inherited
    createImageTexture([bool adjustOffset = true, double resolution = 1, GRect? rect]) Future<GTexture>
    Creates a new GTexture asynchronously from the display object's image. The image is retrieved using the createImage method, and a new texture is created from the image with the specified resolution. If a rect is specified, only the portion of the image within the bounds of the rectangle will be used to create the texture. If adjustOffset is true, the image will be adjusted to remove any offsets from the top left corner.
    inherited
    createImageTextureSync([bool adjustOffset = true, double resolution = 1, GRect? rect]) GTexture
    Creates a texture from the synchronous image generated from this display object.
    inherited
    createPicture([void prePaintCallback(Canvas)?, void postPaintCallback(Canvas)?]) Picture
    Creates a picture of the current state of the DisplayObject. To ensure the "original" form, call before applying any transformations (x, y, scale, etc).
    inherited
    dispose() → void
    Dispose of the GDisplayObject instance and its resources.
    inherited
    getBounds(GDisplayObject? targetSpace, [GRect? out]) GRect
    Returns the axis-aligned bounding rectangle of the object relative to the targetSpace object. If targetSpace is null, the bounds will be relative to this object's parent.
    override
    getFilterBounds([GRect? layerBounds, Paint? alphaPaint]) GRect?
    Returns the bounds of this object after applying all its filters.
    inherited
    getTransformationMatrix(GDisplayObject? targetSpace, [GMatrix? out]) GMatrix
    Returns the transformation matrix that transforms coordinates from the local coordinate system to the coordinate system of the targetSpace.
    inherited
    globalToLocal(GPoint globalPoint, [GPoint? out]) GPoint
    Converts the given point from global coordinates to local coordinates.
    inherited
    hitTest(GPoint localPoint, [bool useShape = false]) GDisplayObject?
    Determines whether the specified localPoint is within the bounds of this icon.
    override
    hitTestMask(GPoint localPoint) bool
    Determines whether the localPoint specified in the local coordinates of this object lies inside its mask.
    inherited
    hitTouch(GPoint localPoint, [bool useShape = false]) bool
    Determines whether the localPoint specified in the local coordinates of this object lies inside its bounds.
    inherited
    localToGlobal(GPoint localPoint, [GPoint? out]) GPoint
    Transforms the given localPoint from the local coordinate system to the global coordinate system.
    inherited
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a nonexistent method or property is accessed.
    inherited
    paint(Canvas canvas) → void
    Do not override this method as it applies the basic transformations. Override $applyPaint if you want to use Canvas directly.
    inherited
    removedFromStage() → void
    Called when the object is removed to the stage.
    inherited
    removeFromParent([bool dispose = false]) → void
    Removes this GDisplayObject from its parent GDisplayObjectContainer.
    inherited
    requiresRedraw() → void
    Notifies the parent that the current state of this GDisplayObject has changed and it requires a redraw.
    inherited
    setPaint(Paint paint) → void
    Sets the ui.Paint paint for the icon.
    setPosition(double x, double y) GDisplayObject
    Sets the x and y transformation of the DisplayObject and returns it.
    inherited
    setScale(double scaleX, [double? scaleY]) GDisplayObject
    Sets the scaleX and scaleY transformation of the DisplayObject and returns it. If only one argument is provided, both scaleX and scaleY are set to the same value.
    inherited
    setShadow(Shadow shadow) → void
    Sets the ui.Shadow value for the icon.
    startDrag([bool lockCenter = false, GRect? bounds]) → void
    Makes this object draggable. When this object is dragged, its x and y properties will be updated to match the mouse position. The lockCenter parameter, if set to true, will cause the object to be dragged from its center point. The bounds parameter can be used to restrict the movement of the object to a certain area. Throws an error if the object is not visible or touchable.
    inherited
    stopDrag() → void
    Stops the current drag operation, if this DisplayObject is currently being dragged. Removes the mouse move event listener and sets the current drag object to null. Does nothing if this DisplayObject is not currently being dragged.
    inherited
    toString() String
    Returns a string representation of this object.
    inherited
    update(double delta) → void
    Called once per frame on each display object being rendered.
    inherited

    Operators

    operator ==(Object other) bool
    The equality operator.
    inherited