CanvasFrame

class omni.ui.CanvasFrame

Bases: Frame

CanvasFrame is the widget that allows the user to pan and zoom its children with a mouse. It has the layout that can be infinitely moved in any direction.

Methods

__init__(self, **kwargs)

Constructs CanvasFrame.

screen_to_canvas(self, x, y)

Transforms screen-space coordinates to canvas-space

screen_to_canvas_x(self, x)

Transforms screen-space X to canvas-space X.

screen_to_canvas_y(self, y)

Transforms screen-space Y to canvas-space Y.

set_pan_key_shortcut(self, mouse_button, ...)

Specify the mouse button and key to pan the canvas.

set_pan_x_changed_fn(self, fn)

The horizontal offset of the child item.

set_pan_y_changed_fn(self, fn)

The vertical offset of the child item.

set_zoom_changed_fn(self, fn)

The zoom level of the child item.

set_zoom_key_shortcut(self, mouse_button, ...)

Specify the mouse button and key to zoom the canvas.

Attributes

compatibility

This boolean property controls the behavior of CanvasFrame.

draggable

Provides a convenient way to make the content draggable and zoomable.

pan_x

The horizontal offset of the child item.

pan_y

The vertical offset of the child item.

smooth_zoom

When true, zoom is smooth like in Bifrost even if the user is using mouse wheen that doesn't provide smooth scrolling.

zoom

The zoom level of the child item.

zoom_max

The zoom maximum of the child item.

zoom_min

The zoom minimum of the child item.

__init__(self: omni.ui._ui.CanvasFrame, **kwargs) None

Constructs CanvasFrame.

`kwargsdict`

See below

### Keyword Arguments:

`pan_x`

The horizontal offset of the child item.

`pan_y`

The vertical offset of the child item.

`zoom`

The zoom minimum of the child item.

`zoom_min`

The zoom maximum of the child item.

`zoom_max`

The zoom level of the child item.

`compatibility`

This boolean property controls the behavior of CanvasFrame. When set to true, the widget will function in the old way. When set to false, the widget will use a newer and faster implementation. This variable is included as a transition period to ensure that the update does not break any existing functionality. Please be aware that the old behavior may be deprecated in the future, so it is recommended to set this variable to false once you have thoroughly tested the new implementation.

`pan_x_changed_fn`

The horizontal offset of the child item.

`pan_y_changed_fn`

The vertical offset of the child item.

`zoom_changed_fn`

The zoom level of the child item.

`draggable`

Provides a convenient way to make the content draggable and zoomable.

`horizontal_clipping`

When the content of the frame is bigger than the frame the exceeding part is not drawn if the clipping is on. It only works for horizontal direction.

`vertical_clipping`

When the content of the frame is bigger than the frame the exceeding part is not drawn if the clipping is on. It only works for vertial direction.

`separate_window`

A special mode where the child is placed to the transparent borderless window. We need it to be able to place the UI to the exact stacking order between other windows.

`raster_policy`

Determine how the content of the frame should be rasterized.

`build_fn`

Set the callback that will be called once the frame is visible and the content of the callback will override the frame child. It’s useful for lazy load.

`widthui.Length`

This property holds the width of the widget relative to its parent. Do not use this function to find the width of a screen.

`heightui.Length`

This property holds the height of the widget relative to its parent. Do not use this function to find the height of a screen.

`namestr`

The name of the widget that user can set.

`style_type_name_overridestr`

By default, we use typeName to look up the style. But sometimes it’s necessary to use a custom name. For example, when a widget is a part of another widget. (Label is a part of Button) This property can override the name to use in style.

`identifierstr`

An optional identifier of the widget we can use to refer to it in queries.

`visiblebool`

This property holds whether the widget is visible.

`visibleMinfloat`

If the current zoom factor and DPI is less than this value, the widget is not visible.

`visibleMaxfloat`

If the current zoom factor and DPI is bigger than this value, the widget is not visible.

`tooltipstr`

Set a basic tooltip for the widget, this will simply be a Label, it will follow the Tooltip style

`tooltip_fnCallable`

Set dynamic tooltip that will be created dynamiclly the first time it is needed. the function is called inside a ui.Frame scope that the widget will be parented correctly.

`tooltip_offset_xfloat`

Set the X tooltip offset in points. In a normal state, the tooltip position is linked to the mouse position. If the tooltip offset is non zero, the top left corner of the tooltip is linked to the top left corner of the widget, and this property defines the relative position the tooltip should be shown.

`tooltip_offset_yfloat`

Set the Y tooltip offset in points. In a normal state, the tooltip position is linked to the mouse position. If the tooltip offset is non zero, the top left corner of the tooltip is linked to the top left corner of the widget, and this property defines the relative position the tooltip should be shown.

`enabledbool`

This property holds whether the widget is enabled. In general an enabled widget handles keyboard and mouse events; a disabled widget does not. And widgets display themselves differently when they are disabled.

`selectedbool`

This property holds a flag that specifies the widget has to use eSelected state of the style.

`checkedbool`

This property holds a flag that specifies the widget has to use eChecked state of the style. It’s on the Widget level because the button can have sub-widgets that are also should be checked.

`draggingbool`

This property holds if the widget is being dragged.

`opaque_for_mouse_eventsbool`

If the widgets has callback functions it will by default not capture the events if it is the top most widget and setup this option to true, so they don’t get routed to the child widgets either

`skip_draw_when_clippedbool`

The flag that specifies if it’s necessary to bypass the whole draw cycle if the bounding box is clipped with a scrolling frame. It’s needed to avoid the limitation of 65535 primitives in a single draw list.

`mouse_moved_fnCallable`

Sets the function that will be called when the user moves the mouse inside the widget. Mouse move events only occur if a mouse button is pressed while the mouse is being moved. void onMouseMoved(float x, float y, int32_t modifier)

`mouse_pressed_fnCallable`

Sets the function that will be called when the user presses the mouse button inside the widget. The function should be like this: void onMousePressed(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier) Where ‘button’ is the number of the mouse button pressed. ‘modifier’ is the flag for the keyboard modifier key.

`mouse_released_fnCallable`

Sets the function that will be called when the user releases the mouse button if this button was pressed inside the widget. void onMouseReleased(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)

`mouse_double_clicked_fnCallable`

Sets the function that will be called when the user presses the mouse button twice inside the widget. The function specification is the same as in setMousePressedFn. void onMouseDoubleClicked(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)

`mouse_wheel_fnCallable`

Sets the function that will be called when the user uses mouse wheel on the focused window. The function specification is the same as in setMousePressedFn. void onMouseWheel(float x, float y, carb::input::KeyboardModifierFlags modifier)

`mouse_hovered_fnCallable`

Sets the function that will be called when the user use mouse enter/leave on the focused window. function specification is the same as in setMouseHovedFn. void onMouseHovered(bool hovered)

`drag_fnCallable`

Specify that this Widget is draggable, and set the callback that is attached to the drag operation.

`accept_drop_fnCallable`

Specify that this Widget can accept specific drops and set the callback that is called to check if the drop can be accepted.

`drop_fnCallable`

Specify that this Widget accepts drops and set the callback to the drop operation.

`computed_content_size_changed_fnCallable`

Called when the size of the widget is changed.

screen_to_canvas(self: omni.ui._ui.CanvasFrame, x: float, y: float) Tuple[float, float]

Transforms screen-space coordinates to canvas-space

screen_to_canvas_x(self: omni.ui._ui.CanvasFrame, x: float) float

Transforms screen-space X to canvas-space X.

screen_to_canvas_y(self: omni.ui._ui.CanvasFrame, y: float) float

Transforms screen-space Y to canvas-space Y.

set_pan_key_shortcut(self: omni.ui._ui.CanvasFrame, mouse_button: int, key_flag: int) None

Specify the mouse button and key to pan the canvas.

set_pan_x_changed_fn(self: omni.ui._ui.CanvasFrame, fn: Callable[[float], None]) None

The horizontal offset of the child item.

set_pan_y_changed_fn(self: omni.ui._ui.CanvasFrame, fn: Callable[[float], None]) None

The vertical offset of the child item.

set_zoom_changed_fn(self: omni.ui._ui.CanvasFrame, fn: Callable[[float], None]) None

The zoom level of the child item.

set_zoom_key_shortcut(self: omni.ui._ui.CanvasFrame, mouse_button: int, key_flag: int) None

Specify the mouse button and key to zoom the canvas.

property compatibility

This boolean property controls the behavior of CanvasFrame. When set to true, the widget will function in the old way. When set to false, the widget will use a newer and faster implementation. This variable is included as a transition period to ensure that the update does not break any existing functionality. Please be aware that the old behavior may be deprecated in the future, so it is recommended to set this variable to false once you have thoroughly tested the new implementation.

property draggable

Provides a convenient way to make the content draggable and zoomable.

property pan_x

The horizontal offset of the child item.

property pan_y

The vertical offset of the child item.

property smooth_zoom

When true, zoom is smooth like in Bifrost even if the user is using mouse wheen that doesn’t provide smooth scrolling.

property zoom

The zoom level of the child item.

property zoom_max

The zoom maximum of the child item.

property zoom_min

The zoom minimum of the child item.