This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
Engine-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

WidgetCanvas Class

Interface for widget canvas handling. See also UnigineScript analog.

To use this class, include the UnigineWidgetCanvas.h file.

WidgetCanvas Class

Members


WidgetCanvas (const Ptr<Gui> & gui)

Constructor. Creates a new canvas widget.

Arguments

  • const Ptr<Gui> & gui - GUI, to which the canvas will belong.

int getPolygonOrder (int polygon)

Returns the rendering order of the given polygon (the higher the value, the later the polygon is rendered atop other elements).

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Rendering order.

void setLineOrder (int line, int order)

Updates the rendering order of the given line (the higher the value, the later the line will be rendered atop other elements).

Arguments

  • int line - Canvas element ID of the line.
  • int order - Rendering order.

Ptr<WidgetCanvas> create (const Ptr<Widget> & widget)

WidgetCanvas constructor.

Arguments

  • const Ptr<Widget> & widget - Widget smart pointer.

Return value

int addPolygon (int polygon = 0)

Adds a new polygon to the canvas widget. By default, it is rendered in white color. Texture tiling mode is disabled.

Arguments

  • int polygon - Rendering order (the higher the value, the later the polygon will be rendered atop other elements).

Return value

Canvas element ID for the added polygon.

void setPolygonTransform (int polygon, const Math::mat4 & transform)

Updates the transformation matrix of the specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • const Math::mat4 & transform - Transformation matrix.

int addPolygonPoint (int polygon, const Math::vec3 & point)

Adds a new point to the polygon in the canvas widget.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • const Math::vec3 & point - Polygon point coordinates.

Return value

Number of the added polygon point.

int getNumLinePoints (int line)

Returns the number of the points that create line segments.

Arguments

  • int line - Canvas element ID of the line.

Return value

Number of line segment points.

Math::mat4 getTransform ()

Returns the transformation matrix applied to all primitives on the canvas widget.

Return value

Transformation matrix.

void removePolygonPoint (int polygon, int num)

Removes the point of the polygon from the canvas widget.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • int num - Polygon point coordinates.

void removeLineIndex (int line, int num)

Removes the index with the given number from the array of the line indices.

Arguments

  • int line - Canvas element ID of the line.
  • int num - The number of the index in the array of the line indices.

int getNumLineIndices (int line)

Returns the total number of indices set for the points that form line segments.

Arguments

  • int line - Canvas element ID of the line.

Return value

The number of indices set for the points that form line segments.

int getTextIntersection (int x, int y)

Checks whether the specified point (e.g. the mouse cursor) intersects with a bounding box of the widget text.

Arguments

  • int x - coordinate of the point.
  • int y - coordinate of the point.

Return value

ID of the intersected text lines array; otherwise, -1 is returned if no intersections are found.

Math::vec4 getPolygonColor (int polygon)

Returns the current color of the specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Polygon color.

void setTextPosition (int text, const Math::vec2 & position)

Updates the position of the specified text.

Arguments

  • int text - Canvas element ID of the text string.
  • const Math::vec2 & position - Text position coordinates.

Math::vec4 getColor ()

Returns the background color of the canvas widget.

Return value

Background color.

void setColor (const Math::vec4 & color)

Sets a background color for the canvas widget.

Arguments

  • const Math::vec4 & color - Background color.

void setTextOutline (int text, int outline)

Sets a value indicating if the text should be rendered casting a shadow. Positive or negative values set the distance in pixels to offset the outline. The default is 0 (no outlining).

Arguments

  • int text - Canvas element ID of the text string.
  • int outline - Outline offset:
    • Positive values set offset in the bottom-right corner direction.
    • Negative values set offset in the top-left corner direction (the outline will overlap widget text).
    • 0 is not to use outlining.

void setPolygonTexCoord (int polygon, const Math::vec2 & texcoord)

Updates the texture coordinates for the last added point of the polygon. Before calling this function, the point should be added with addPolygonPoint().

Arguments

  • int polygon - Canvas element ID of the polygon.
  • const Math::vec2 & texcoord - Texture coordinates for the point.

Math::vec4 getLineColor (int line)

Returns the current color of the specified line.

Arguments

  • int line - Canvas element ID of the line.

Return value

Line color.

void clearLineIndices (int line)

Clears the array of indices set for points that form the given line.

Arguments

  • int line - Canvas element ID of the line.

void setImage (const Ptr<Image> & image)

Updates the texture image for the canvas widget.

Arguments

  • const Ptr<Image> & image - Texture image.

void setTransform (const Math::mat4 & transform)

Sets a transformation matrix applied to all primitives on the canvas widget.

Arguments

  • const Math::mat4 & transform - Transformation matrix.

void removeLine (int line)

Removes the line from the canvas widget.

Arguments

  • int line - Canvas element ID of the line.

int getTextOutline (int text)

Returns a value indicating if the text is rendered casting a shadow. Positive or negative values determine the distance in pixels used to offset the outline.

Arguments

  • int text - Canvas element ID of the text string.

Return value

Positive value if the outline is offset in the bottom-right corner direction. Negative value if the outline is offset in the top-left corner direction. 0 if font is not outlined.

Math::vec4 getTextColor (int text)

Returns the current color of the specified text.

Arguments

  • int text - Canvas element ID of the text string.

Return value

Font color.

Math::vec2 getTextPosition (int text)

Returns the current position of the specified text.

Arguments

  • int text - Canvas element ID of the text string.

Return value

Text position coordinates.

int getLine (int num)

Returns the canvas element ID of the line by its number.

Arguments

  • int num - Line number in range from 0 to the total number lines.

Return value

Canvas element ID of the line.

void setLineTransform (int line, const Math::mat4 & transform)

Updates the transformation matrix of the specified line.

Arguments

  • int line - Canvas element ID of the line.
  • const Math::mat4 & transform - Transformation matrix.

void setTextTransform (int text, const Math::mat4 & transform)

Updates the transformation matrix of the specified text.

Arguments

  • int text - Canvas element ID of the text string.
  • const Math::mat4 & transform - Transformation matrix.

void setTextOrder (int text, int order)

Updates the rendering order of the given text element (the higher the value, the later the text will be rendered atop other elements).

Arguments

  • int text - Canvas element ID of the text string.
  • int order - Rendering order.

int getText (int num)

Returns the canvas element ID of the text string by its number.

Arguments

  • int num - Number of the text element.

Return value

Canvas element ID of the text string.

void setPolygonTwoSided (int polygon, int two_sided)

Sets polygon two sided option.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • int two_sided - two sided option.

void setTexture (const char * texture)

Sets the texture for the canvas widget.

Arguments

  • const char * texture - Path to the texture.

int getNumPolygonIndices (int polygon)

Returns the total number of indices set for points of the specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

The number of indices set for points that form polygons.

void clearPolygonPoints (int polygon)

Deletes all points that make up a given polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

int getPolygonIntersection (int x, int y)

Checks whether the specified point (e.g. the mouse cursor) intersects with widget polygons.

Arguments

  • int x - X coordinate of the point.
  • int y - Y coordinate of the point.

Return value

Number of the first intersected polygon with the highest rendering order in the array of polygons. If no intersections are found, -1 will be returned.

int type ()

WidgetWindow type.

Return value

WidgetWindow type identifier.

int getPolygon (int num)

Returns the canvas element ID of the polygon by its index.

Arguments

  • int num - Polygon number in range from 0 to the total number of polygons.

Return value

Canvas element ID of the polygon.

int getTextWidth (int text)

Returns the width of the given text element on the canvas widget.

Arguments

  • int text - Canvas element ID of the text string.

Return value

Text width in pixels.

void setPolygonOrder (int polygon, int order)

Updates the rendering order of the given polygon (the higher the value, the later the polygon will be rendered atop other elements).

Arguments

  • int polygon - Canvas element ID of the polygon.
  • int order - Rendering order.

void setLineColor (int line, const Math::vec4 & color)

Updates the color of the specified line.

Arguments

  • int line - Canvas element ID of the line.
  • const Math::vec4 & color - Line color.

int addText (int order = 0)

Adds a new text string to the canvas widget. By default, it is rendered in white color. If a font size is not set for the canvas widget, a default one is used. No shadow is cast from a text (no outlining). Text width and height on the canvas widget are equal to 0.

Arguments

  • int order - Rendering order (the higher the value, the later the text will be rendered atop other elements).

Return value

Canvas element ID of the added text string.

int getLineOrder (int line)

Returns the rendering order of the given line (the higher the value, the later the line is rendered atop other elements).

Arguments

  • int line - Canvas element ID of the line.

Return value

Rendering order.

void setPolygonTexture (int polygon, const char * name)

Sets a texture from a file for the given polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • const char * name - Path to the texture.

void setPolygonWrapRepeat (int polygon, int repeat)

Sets texture tiling for a given polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • int repeat - Positive number to enable texture tiling; 0 to disable it.

int addLinePoint (int line, const Math::vec3 & point)

Adds a new segment to the line in the canvas widget.

Arguments

  • int line - Canvas element ID of the line.
  • const Math::vec3 & point - Segment point coordinates.

Return value

Number of the added line segment point.

int getPolygonTwoSided (int polygon)

Gets polygon two sided option.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Returns two sided option.

int getPolygonBlendDestFunc (int polygon)

Returns the blending mode of the destination color for the specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Blending mode of the destination color (one of the BLEND_*).

void removeText (int text)

Removes the text from the canvas widget.

Arguments

  • int text - Canvas element ID of the text string.

Math::mat4 getTextTransform (int text)

Returns the current transformation matrix of the specified text.

Arguments

  • int text - Canvas element ID of the text string.

Return value

Transformation matrix.

void removeLinePoint (int line, int num)

Removes the segment of the line from the canvas widget.

Arguments

  • int line - Canvas element ID of the line.
  • int num - Number of the point to remove.

void setPolygonImage (int polygon, const Ptr<Image> & image)

Sets an image for a given polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • const Ptr<Image> & image - Image to set.

const char * getPolygonTexture (int polygon)

Returns the current texture set for a given polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Path to the texture.

void getImage (const Ptr<Image> & image)

Returns the current texture image set for the canvas widget.

Arguments

  • const Ptr<Image> & image

Math::mat4 getLineTransform (int line)

Returns the current transformation matrix of the specified line.

Arguments

  • int line - Canvas element ID of the line.

Return value

Transformation matrix.

int getNumPolygonPoints (int polygon)

Returns the number of points that form the specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Number of polygon points.

int addLine (int order = 0)

Adds a new line to the canvas widget. By default, it is rendered in white color.

Arguments

  • int order - Rendering order (the higher the value, the later the line will be rendered atop other elements).

Return value

Canvas element ID for the added line.

Math::vec3 getLinePoint (int line, int num)

Returns the coordinates of the specified line segment point.

Arguments

  • int line - Canvas element ID of the line.
  • int num - Number of the line segment point.

Return value

Segment point coordinates.

int getLineIntersection (int x, int y, float distance)

Checks whether the specified point (e.g. the mouse cursor) intersects with lines drawn in the canvas widget.

Arguments

  • int x - X coordinate of the point.
  • int y - Y coordinate of the point.
  • float distance - Point radius acceptable for detecting intersection.

Return value

Number of the first intersected line with the highest rendering order in the array of lines. If no intersections are found, -1 will be returned.

Math::vec2 getPolygonTexCoord (int polygon, int num)

Returns the texture coordinates of the specified point of the polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • int num - Number of the polygon point.

Return value

Texture coordinates of the point.

int addPolygonIndex (int polygon, int index)

Adds an index for the point of the polygon in the canvas widget. Notice that before adding indices, you should add all points that form the polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • int index - Index of the point of the polygon.

Return value

The number of the added index in the array of polygon indices.

void setTextSize (int text, int size)

Updates the font size of the specified text.

Arguments

  • int text - Canvas element ID of the text string.
  • int size - Font size.

void clearPolygonIndices (int polygon)

Clears the array of indices set for points that form the given polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

void setPolygonColor (int polygon, const Math::vec4 & color)

Updates the color of the specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • const Math::vec4 & color - Polygon color.

int getPolygonBlendSrcFunc (int polygon)

Returns the blending mode of the source screen buffer color for the specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Blending mode of the source screen buffer color (one of the BLEND_*).

int getLineIndex (int line, int num)

Returns the index of the point of the line segment by its number.

Arguments

  • int line - Canvas element ID of the line.
  • int num - The number of the index of the point of the line segment.

Return value

Index of the point of the line segment.

int getTextSize (int text)

Returns the current font size of the specified text.

Arguments

  • int text - Canvas element ID of the text string.

Return value

Font size.

int getTextOrder (int text)

Returns the rendering order of the given text element (the higher the value, the later the text is rendered atop other elements).

Arguments

  • int text - Canvas element ID of the text string.

Return value

Rendering order.

void clearLinePoints (int line)

Deletes all points that make up a given line.

Arguments

  • int line - Canvas element ID of the line.

Math::vec3 getPolygonPoint (int polygon, int num)

Returns the coordinates of the specified polygon point.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • int num - Number of the polygon point.

Return value

Polygon point coordinates.

int getNumPolygons ()

Returns the number of polygons drawn in the canvas widget.

Return value

Number of polygons.

int getTextHeight (int text)

Returns the height of the given text element on the canvas widget.

Arguments

  • int text - Canvas element ID of the text string.

Return value

Text height in pixels.

void removePolygon (int polygon)

Removes the polygon from the canvas widget.

Arguments

  • int polygon - Canvas element ID of the polygon.

void clear ()

Clears the canvas widget: deletes all drawn lines, polygons and text.

int getPolygonIndex (int polygon, int num)

Returns the index of the point of the polygon by its number.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • int num - The number of the index of the point of the polygon.

Return value

Index of the point of the polygon.

void setPolygonBlendFunc (int polygon, int src, int dest)

Updates the blending coefficients for specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • int src - Blending mode for the source screen buffer color (one of the BLEND_*).
  • int dest - Blending mode for the destination polygon color (one of the BLEND_*).

int addLineIndex (int line, int index)

Adds an index for the point of the line segment in the canvas widget. Notice that before adding indices, you should add all points that form the line.

Arguments

  • int line - Canvas element ID of the line.
  • int index - Index of the point of the line segment.

Return value

The number of the added index in the array of line indices.

void setTextText (int text, const char * str)

Updates the text to be drawn in the given text element on the canvas widget.

Arguments

  • int text - Canvas element ID of the text string.
  • const char * str - Text string.

void removePolygonIndex (int polygon, int num)

Removes the index with the given number from the array of the polygon indices.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • int num - The number of the index in the array of the polygon indices.

int getNumLines ()

Returns the number of lines drawn in the canvas widget.

Return value

Number of lines.

int getPolygonWrapRepeat (int polygon)

Returns a value indicating if texture tiling is enabled for the given polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

1 if texture tiling is enabled; 0 if disabled.

int getNumTexts ()

Returns the number of text strings drawn in the canvas widget.

Return value

Number of text strings.

void getPolygonImage (int polygon, const Ptr<Image> & image)

Returns the current image set for a given polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • const Ptr<Image> & image - Current image.

void setTextColor (int text, const Math::vec4 & color)

Updates the color of the specified text.

Arguments

  • int text - Canvas element ID of the text string.
  • const Math::vec4 & color - Font color.

Math::mat4 getPolygonTransform (int polygon)

Returns the current transformation matrix of the specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Transformation matrix.

const char * getTextText (int text)

Returns the current text drawn in the given text element on the canvas widget.

Arguments

  • int text - Canvas element ID of the text string.

Return value

Text string.

const char * getTexture ()

Returns the path to the current texture set for the canvas widget.

Return value

Path to the texture.
Last update: 03.07.2017
Build: ()