This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии 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 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 index.

Arguments

  • int num - Text element index number.

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 vec3 & position) const =0

Updates the position of the specified text.

Arguments

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

virtual vec3 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 index.

Arguments

  • int num - Line index 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

Index number of intersected lines array; otherwise, -1 is returned if no intersections are found.

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 point) const =0

Removes the segment of the line from the canvas widget.

Arguments

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

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

Index number of the added line segment point.

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

Returns the coordinates of the specified line segment point.

Arguments

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

Return value

Segment point coordinates.

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 index 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

ID of intersected polygons array; if no intersections are found, -1 is 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 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 vertices for the specified polygon.

Arguments

  • int polygon - Canvas element ID of the polygon.

Return value

Number of polygon vertices.

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

Removes the vertex of the polygon from the canvas widget.

Arguments

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

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

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

Arguments

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

Return value

Index number of the added polygon vertex.

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

Returns the coordinates of the specified polygon vertex.

Arguments

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

Return value

Polygon vertex 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 point) const =0

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

Arguments

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

Return value

Texture coordinates of the point.
Last update: 03.07.2017
Build: ()