This page has been translated automatically.
Getting Started
Migrating to UNIGINE 2.0
C++ API Migration
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::WidgetCanvas Class

Interface for widget canvas handling. See also UnigineScript analog.

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

Unigine::WidgetCanvas Class

Members


static int type ()

WidgetWindow type.

Return value

WidgetWindow type identifier.

static Ptr< WidgetCanvas > create (const WidgetPtr & widget)

WidgetCanvas constructor.

Arguments

  • const WidgetPtr & widget - Widget smart pointer.

static Ptr< WidgetCanvas > create (const Ptr< Gui > & gui)

WidgetCanvas constructor.

Arguments

  • const Ptr< Gui > & gui - Gui pointer.

virtual void setImage (const ImagePtr & image) const =0

Updates the texture image for the canvas widget.

Arguments

  • const ImagePtr & image - Texture image.

virtual void getImage () const =0

Returns the current texture image set for the canvas widget.

Return value

image Image.

virtual void setTexture (const char * name) const =0

Sets the texture for the canvas widget.

Arguments

  • const char * name - Path to the texture.

virtual const char * getTexture () const =0

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

Return value

Path to the texture.

virtual void setColor (const vec4 & color) const =0

Sets a background color for the canvas widget.

Arguments

  • const vec4 & color - Background color.

virtual vec4 getColor () const =0

Returns the background color of the canvas widget.

Return value

Background color.

virtual void setTransform (const mat4 & transform) const =0

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

Arguments

  • const mat4 & transform - Transformation matrix.

virtual mat4 getTransform () const =0

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

Return value

Transformation matrix.

virtual void clear () const =0

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

virtual int addText (int order) const =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.

virtual void removeText (int text) const =0

Removes the text from the canvas widget.

Arguments

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

virtual int getNumTexts () const =0

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

Return value

Number of text strings.

virtual int getText (int num) const =0

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.

virtual int getTextIntersection (int X, int Y) const =0

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.

virtual void setTextOrder (int text, int order) const =0

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.

virtual int getTextOrder (int text) const =0

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.

virtual void setTextSize (int text, int size) const =0

Updates the font size of the specified text.

Arguments

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

virtual int getTextSize (int text) const =0

Returns the current font size of the specified text.

Arguments

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

Return value

Font size.

virtual void setTextColor (int text, const vec4 & color) const =0

Updates the color of the specified text.

Arguments

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

virtual vec4 getTextColor (int text) const =0

Returns the current color of the specified text.

Arguments

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

Return value

Font color.

virtual void setTextOutline (int text, int outline) const =0

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.

virtual int getTextOutline (int text) const =0

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.

virtual void setTextPosition (int text, const vec2 & position) const =0

Updates the position of the specified text.

Arguments

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

virtual vec2 getTextPosition (int text) const =0

Returns the current position of the specified text.

Arguments

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

Return value

Text position coordinates.

virtual void setTextTransform (int text, const mat4 & transform) const =0

Updates the transformation matrix of the specified text.

Arguments

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

virtual mat4 getTextTransform (int text) const =0

Returns the current transformation matrix of the specified text.

Arguments

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

Return value

Transformation matrix.

virtual void setTextText (int text, const char * str) const =0

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.

virtual const char * getTextText (int text) const =0

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.

virtual int getTextWidth (int text) const =0

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.

virtual int getTextHeight (int text) const =0

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.

virtual int addLine (int order) const =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.

virtual void removeLine (int line) const =0

Removes the line from the canvas widget.

Arguments

  • int line - Canvas element ID of the line.

virtual int getNumLines () const =0

Returns the number of lines drawn in the canvas widget.

Return value

Number of lines.

virtual int getLine (int num) const =0

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.

virtual int getLineIntersection (int x, int y, float distance) const =0

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.

virtual void setLineOrder (int line, int order) const =0

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.

virtual int getLineOrder (int line) const =0

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.

virtual void setLineColor (int line, const vec4 & color) const =0

Updates the color of the specified line.

Arguments

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

virtual vec4 getLineColor (int line) const =0

Returns the current color of the specified line.

Arguments

  • int line - Canvas element ID of the line.

Return value

Line color.

virtual void setLineTransform (int line, const mat4 & transform) const =0

Updates the transformation matrix of the specified line.

Arguments

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

virtual mat4 getLineTransform (int line) const =0

Returns the current transformation matrix of the specified line.

Arguments

  • int line - Canvas element ID of the line.

Return value

Transformation matrix.

virtual void clearLinePoints (int line) const =0

Deletes all points that make up a given line.

Arguments

  • int line - Canvas element ID of the line.

virtual int getNumLinePoints (int line) const =0

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.

virtual void removeLinePoint (int line, int num) const =0

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.

virtual int addLinePoint (int line, const vec3 & point) const =0

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

Arguments

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

Return value

Number of the added line segment point.

virtual vec3 getLinePoint (int line, int num) const =0

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.

virtual void clearLineIndices (int line) const =0

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

Arguments

  • int line - Canvas element ID of the line.

virtual int getNumLineIndices (int line) const =0

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.

virtual void removeLineIndex (int line, int num) const =0

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.

virtual int addLineIndex (int line, int index) const =0

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.

virtual int getLineIndex (int line, int num) const =0

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.

virtual int addPolygon (int order) const =0

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

Arguments

  • int order - 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.

virtual void removePolygon (int polygon) const =0

Removes the polygon from the canvas widget.

Arguments

  • int polygon - Canvas element ID of the polygon.

virtual int getNumPolygons () const =0

Returns the number of polygons drawn in the canvas widget.

Return value

Number of polygons.

virtual int getPolygon (int num) const =0

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.

virtual int getPolygonIntersection (int x, int y) const =0

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.

virtual void setPolygonOrder (int polygon, int order) const =0

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.

virtual int getPolygonOrder (int polygon) const =0

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.

virtual void setPolygonTwoSided (int polygon, int enable) const =0

Sets polygon two sided option.

Arguments

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

virtual int getPolygonTwoSided (int polygon) const =0

Gets polygon two sided option.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Returns two sided option.

virtual void setPolygonColor (int polygon, const vec4 & color) const =0

Updates the color of the specified polygon.

Arguments

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

virtual vec4 getPolygonColor (int polygon) const =0

Returns the current color of the specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Polygon color.

virtual void setPolygonWrapRepeat (int polygon, int repeat) const =0

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.

virtual int getPolygonWrapRepeat (int polygon) const =0

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.

virtual void setPolygonBlendFunc (int polygon, int src, int dest) const =0

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_*).

virtual int getPolygonBlendSrcFunc (int polygon) const =0

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_*).

virtual int getPolygonBlendDestFunc (int polygon) const =0

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_*).

virtual void setPolygonTransform (int polygon, const mat4 & transform) const =0

Updates the transformation matrix of the specified polygon.

Arguments

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

virtual mat4 getPolygonTransform (int polygon) const =0

Returns the current transformation matrix of the specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Transformation matrix.

virtual void setPolygonImage (int polygon, const ImagePtr & image) const =0

Sets an image for a given polygon.

Arguments

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

virtual void getPolygonImage (int polygon, const ImagePtr & image) const =0

Returns the current image set for a given polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.
  • const ImagePtr & image - Current image.

virtual void setPolygonTexture (int polygon, const char * name) const =0

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.

virtual const char * getPolygonTexture (int polygon) const =0

Returns the current texture set for a given polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Path to the texture.

virtual void clearPolygonPoints (int polygon) const =0

Deletes all points that make up a given polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

virtual int getNumPolygonPoints (int polygon) const =0

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.

virtual void removePolygonPoint (int polygon, int num) const =0

Removes the point of the polygon from the canvas widget.

Arguments

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

virtual int addPolygonPoint (int polygon, const vec3 & point) const =0

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

Arguments

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

Return value

Number of the added polygon point.

virtual vec3 getPolygonPoint (int polygon, int num) const =0

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.

virtual void setPolygonTexCoord (int polygon, const vec2 & texcoord) const =0

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 vec2 & texcoord - Texture coordinates for the point.

virtual vec2 getPolygonTexCoord (int polygon, int num) const =0

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.

virtual void clearPolygonIndices (int polygon) const =0

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

Arguments

  • int polygon - Canvas element ID of the polygon.

virtual int getNumPolygonIndices (int polygon) const =0

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.

virtual void removePolygonIndex (int polygon, int num) const =0

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.

virtual int addPolygonIndex (int polygon, int index) const =0

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.

virtual int getPolygonIndex (int polygon, int num) const =0

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.
Last update: 2017-07-03
Build: ()