Azul API docs for version 1.0.0-alpha1
App
construction and configurationmod app:
Main application class
struct App
fn add_window:
fn add_image:
fn get_monitors:
List of currently attached monitors, note that this
Vec
will be empty on wasm32-> MonitorVec
fn run:
Spawn a new window on the screen when the app is run.
Adds a new image identified by an ID to the image cache
Returns a list of monitors - useful for setting the monitor that a window should spawn on.
Runs the application. Due to platform restrictions (specifically
WinMain
on Windows), this function never returns.Configuration for optional features, such as whether to enable logging or panic hooks
struct AppConfig
External system callbacks to get the system time or create / manage threads
struct SystemCallbacks
constructor library_internal:
Use the default, library-internal callbacks instead of providing your own
Window creation / startup configuration
mod window:
Options on how to initially create the window
struct WindowCreateOptions
constructor new:
Creates a new window configuration with a custom layout callback
Logical position (can differ based on HiDPI settings). Usually this is what you'd want for hit-testing and positioning elements.
struct LogicalPosition
A size in "logical" (non-HiDPI-adjusted) pixels in floating-point units
struct LogicalSize
fn to_physical:
Minimum / maximum / current size of the window in logical dimensions
struct WindowSize
fn get_hidpi_factor:
-> f32
Returns the hidpi factor of the bounds
Current keyboard state, stores what keys / characters have been pressed
struct KeyboardState
fn shift_down:
-> bool
fn ctrl_down:
-> bool
fn alt_down:
-> bool
fn super_down:
-> bool
fn is_key_down:
-> bool
Returns if the
SHIFT
key is held down (left OR right shift)Returns if the
CTRL
key is held downReturns if the
ALT
key is held downReturns if the
SUPER
("Windows") key is held downReturns if a key is held down
Current position of the mouse cursor, relative to the window. Set to
Uninitialized
on startup (gets initialized on the first frame).struct CursorPosition
struct WindowState
constructor new:
-> WindowState
constructor default:
-> WindowState
Creates a new WindowState with default settings and a custom layout callback
Creates a default WindowState with an empty layout callback - useful only if you use the Rust
WindowState { .. WindowState::default() }
intialization syntax.
Callback type definitions + struct definitions of
CallbackInfo
smod callbacks:
struct CallbackInfo
fn get_hit_node:
-> DomNodeId
-> WindowState
-> MouseState
fn get_gl_context:
-> OptionGl
fn get_dataset:
-> OptionRefAny
-> OptionString
fn get_inline_text:
fn get_font_ref:
fn shape_text:
-> usize
fn get_parent:
fn get_next_sibling:
fn get_first_child:
fn get_last_child:
fn get_node_size:
fn set_window_state:
fn set_focus:
fn set_css_property:
fn add_image:
fn has_image:
-> bool
fn get_image:
fn update_image:
fn delete_image:
fn stop_propagation:
fn create_window:
fn start_timer:
-> TimerId
fn start_animation:
fn stop_timer:
Returns true if the timer was successfully stopped / removed.
-> bool
fn start_thread:
fn send_thread_msg:
Returns
true
if the ThreadId is valid and the message could be sent, false otherwise-> bool
fn stop_thread:
Returns
true
if the ThreadId is valid, false otherwise-> bool
Returns the
DomNodeId
of the element that the callback was attached to.Returns the function pointer necessary to query the current time.
Returns the
LayoutPoint
of the cursor in the viewport (relative to the origin of theDom
). Set toNone
if the cursor is not in the current window.Returns the
LayoutPoint
of the cursor in the viewport (relative to the origin of theDom
). Set toNone
if the cursor is not hovering over the current node.Returns a copy of the current windows
WindowState
.Returns a copy of the internal
KeyboardState
. Same asself.get_window_state().keyboard_state
Returns a copy of the internal
MouseState
. Same asself.get_window_state().mouse_state
Returns a copy of the current windows
WindowState
.Returns a copy of the internal
KeyboardState
. Same asself.get_window_state().keyboard_state
Returns a copy of the internal
MouseState
. Same asself.get_window_state().mouse_state
Returns a copy of the current windows
RawWindowHandle
.Returns a reference-counted copy of the current windows'
Gl
(context). You can use this to render OpenGL textures.Returns the x / y offset that this node has been scrolled to by the user or
None
if the node has not been scrolled.Returns the
dataset
property of the given Node orNone
if the node doesn't have adataset
property.Given a dataset, returns the node ID of the "root"
RefAny
, i.e. theRefAny
with the lowestinstance
count that is set as adataset
on any node.If the node is a
Text
node, returns a copy of the internal string contents.If the node is a
Text
node, returns the layouted inline glyphs of the text currently rendered on the screenIf the node is a
Text
node, returns theFontRef
that was used to render this node. Useful for getting font metrics for a text stringSimilar to
get_inline_text()
: If the node is aText
node, shape thetext
string with the same parameters as the current text and return the calculated InlineTextLayout. Necessary to calculate text cursor offsets and to detect when a line overflows content.Returns the index of the node relative to the parent node.
Returns the parent
DomNodeId
of the givenDomNodeId
. ReturnsNone
on an invalid NodeId.Returns the previous siblings
DomNodeId
of the givenDomNodeId
. ReturnsNone
on an invalid NodeId.Returns the next siblings
DomNodeId
of the givenDomNodeId
. ReturnsNone
on an invalid NodeId.Returns the next siblings
DomNodeId
of the givenDomNodeId
. ReturnsNone
on an invalid NodeId.Returns the next siblings
DomNodeId
of the givenDomNodeId
. ReturnsNone
on an invalid NodeId.Returns the position of a given DOM node in the UI
Returns the size of a given DOM node in the UI
Returns the current computed CSS property of a given DOM node in the UI
Sets the new
WindowState
for the next frame. The window is updated after all callbacks are run.Sets the new
FocusTarget
for the next frame. Note that this will emit aOn::FocusLost
andOn::FocusReceived
event, if the focused node has changed.Sets a
CssProperty
on a given node to its new value. If this property change affects the layout, this will automatically trigger a relayout and redraw of the screen.Sets the scroll position of the node
If the node is a
Text
node, overwrites theText
content with the new string, without requiring the entire UI to be rebuilt.Adds a new image identified by an ID to the image cache
Returns whether an image with a given CSS ID already exists
Returns the image with a given CSS ID
If the node is an
Image
, exchanges the current image with a new sourceDeletes an image identified by a CSS ID from the image cache
If the node has an
ImageMask
, exchanges the current mask for the new maskStops the propagation of the current callback event type to the parent. Events are bubbled from the inside out (children first, then parents), this event stops the propagation of the event to the parent.
Spawns a new window with the given
WindowCreateOptions
.Adds a new
Timer
to the runtime. See the documentation forTimer
for more information.Starts an animation timer on a give NodeId - same as a
Timer
, but uses a pre-configured interpolation function to drive the animation timerStops / cancels a
Timer
. See the documentation forTimer
for more information.Starts a new
Thread
to the runtime. See the documentation forThread
for more information.Sends a message to a background thread
Stops a thread at the nearest possible opportunity. Sends a
ThreadSendMsg::TerminateThread
message to the thread and joins the thread.struct PositionInfo
fn is_positioned:
-> bool
struct HidpiAdjustedBounds
fn get_logical_size:
-> LogicalSize
fn get_hidpi_factor:
-> f32
Returns the size of the bounds in logical units
Returns the size of the bounds in physical units
Returns the hidpi factor of the bounds
struct InlineText
fn hit_test:
Hit-tests the inline text, returns detailed information about which glyph / word / line, etc. the position (usually the mouse cursor) is currently over. Result may be empty (no hits) or contain more than one result (cursor is hovering over multiple overlapping glyphs at once).
struct ResolvedTextLayoutOptions
constructor default:
struct RenderImageCallbackInfo
fn get_gl_context:
-> OptionGl
fn get_bounds:
-> DomNodeId
fn get_inline_text:
-> usize
fn get_parent:
fn get_next_sibling:
fn get_first_child:
fn get_last_child:
Returns a copy of the internal
Gl
Returns a copy of the internal
HidpiAdjustedBounds
Returns the
DomNodeId
that this callback was called onIf the node is a
Text
node, returns the layouted inline glyphsReturns the index of the node relative to the parent node.
Returns the parent
DomNodeId
of the givenDomNodeId
. ReturnsNone
on an invalid NodeId.Returns the previous siblings
DomNodeId
of the givenDomNodeId
. ReturnsNone
on an invalid NodeId.Returns the next siblings
DomNodeId
of the givenDomNodeId
. ReturnsNone
on an invalid NodeId.Returns the next siblings
DomNodeId
of the givenDomNodeId
. ReturnsNone
on an invalid NodeId.Returns the next siblings
DomNodeId
of the givenDomNodeId
. ReturnsNone
on an invalid NodeId.struct RefCount
fn increase_ref:
fn decrease_ref:
fn increase_refmut:
fn decrease_refmut:
RefAny is a reference-counted, opaque pointer, which stores a reference to a struct.
RefAny
can be up- and downcasted (this usually done via generics and can't be expressed in the Rust API)struct RefAny
fn get_type_id:
-> u64
fn get_type_name:
-> String
struct LayoutCallbackInfo
fn get_gl_context:
-> OptionGl
fn get_system_fonts:
fn get_image:
Returns a copy of the OpenGL context
Returns all system-native fonts with their respective file paths as values
Returns an
ImageRef
referenced by a CSS ID
Dom
construction and configurationmod dom:
struct Dom
constructor new:
-> Dom
constructor body:
-> Dom
constructor div:
-> Dom
constructor br:
-> Dom
constructor text:
-> Dom
constructor image:
-> Dom
constructor iframe:
-> Dom
fn set_node_type:
fn with_node_type:
-> Dom
fn set_dataset:
fn with_dataset:
-> Dom
-> Dom
fn set_callbacks:
fn with_callbacks:
-> Dom
-> Dom
fn add_callback:
fn with_callback:
-> Dom
fn add_child:
fn with_child:
-> Dom
fn set_children:
fn with_children:
-> Dom
fn add_id:
fn with_id:
-> Dom
fn add_class:
fn with_class:
-> Dom
fn add_css_property:
-> Dom
-> Dom
-> Dom
-> Dom
fn set_inline_style:
-> Dom
-> Dom
-> Dom
-> Dom
fn set_clip_mask:
fn with_clip_mask:
-> Dom
fn set_tab_index:
fn with_tab_index:
-> Dom
-> Dom
fn hash:
-> u64
fn node_count:
-> usize
fn get_html_string:
-> String
-> String
fn style:
-> StyledDom
Adds a child node to this DOM (potentially heap-allocates in Rust code). Swaps
self
with a defaultDom
in order to prevent accidental copies.Same as add_child, but as a builder method.
Adds a child node to this DOM (potentially heap-allocates in Rust code). Swaps
self
with a defaultDom
in order to prevent accidental copies.Same as add_child, but as a builder method.
Adds a child node to this DOM (potentially heap-allocates in Rust code). Swaps
self
with a defaultDom
in order to prevent accidental copies.Same as set_children, but as a builder method.
Adds an CSS ID to the DOM root node.
Same as add_id, but as a builder method
Adds a CSS class to the DOM root node.
Same as add_class, but as a builder method
Adds an inline (normal) CSS property to the DOM root node.
Same as add_class, but as a builder method
Adds an inline (hover) CSS property to the DOM root node.
Same as add_class, but as a builder method
Adds an inline (hover) CSS property to the DOM root node.
Same as add_class, but as a builder method
Adds an inline (hover) CSS property to the DOM root node.
Same as add_class, but as a builder method
Sets the clip mask for the DOM root node.
Same as set_clip_mask, but as a builder method
Sets the tab index for the DOM root node.
Same as set_tab_index, but as a builder method
Sets accessibility attributes for the DOM root node.
Same as set_accessibility_info, but as a builder method
Sets the menu bar for the DOM root node. See
NodeData::set_menu_bar
for more information.Same as set_accessibility_info, but as a builder method
Sets the context menu for the DOM root node. See
NodeData::set_context_menu
for more information.Same as set_context_menu, but as a builder method
Calculates the hash of this node (note: in order to be truly unique, you also have to hash the DOM and Node ID).
Returns the number of nodes in the DOM, including all child DOM trees. Result is equal to
self.total_children + 1
(count of all child trees + the root node)Returns a HTML string that you can write to a file in order to debug the UI structure and debug potential cascading issues
Returns a HTML for unit testing
Same as
StyledDom::new(dom, css)
: NOTE - replaces self with an empty DOM, in order to prevent cloning the DOM entirelyRepresents one single DOM node (node type, classes, ids and callbacks are stored here)
struct NodeData
constructor new:
-> NodeData
constructor body:
-> NodeData
constructor div:
-> NodeData
constructor br:
-> NodeData
constructor text:
-> NodeData
constructor image:
-> NodeData
constructor iframe:
-> NodeData
Creates an new, empty
NodeData
structfn set_node_type:
fn with_node_type:
-> NodeData
fn set_dataset:
fn with_dataset:
-> NodeData
-> NodeData
fn add_callback:
fn with_callback:
-> NodeData
fn set_callbacks:
fn with_callbacks:
-> NodeData
-> NodeData
fn set_inline_style:
-> NodeData
-> NodeData
-> NodeData
-> NodeData
fn set_clip_mask:
fn set_tab_index:
fn hash:
-> u64
Adds a callback this DOM (potentially heap-allocates in Rust code)
Same as add_child, but as a builder method.
Sets the
extra.clip_mask
field for this nodeSets the tab index for this node
Sets accessibility attributes for this node
Adds a (native) menu bar: If this node is the root node the menu bar will be added to the window, else it will be displayed using the width and position of the bounding rectangle
Signalizes that this node has a (native) context-aware menu. If set, the user can left-click the node to open the menu
Calculates the hash of this node (note: in order to be truly unique, you also have to hash the DOM and Node ID).
When to call a callback action -
On::MouseOver
,On::MouseOut
, etc.struct On
-> EventFilter
Converts the
On
shorthand into aEventFilter
Css
parsing modulemod css:
struct Css
constructor empty:
-> Css
constructor from_string:
-> Css
Returns an empty CSS style
Returns a CSS style parsed from a
String
struct ColorU
struct AngleValue
fn get_degrees:
-> f32
Parsed CSS key-value pair
struct CssProperty
fn get_key_string:
-> String
fn get_value_string:
-> String
-> String
fn interpolate:
-> CssProperty
Returns the key of the CSS property as a string, i.e.
background
Returns the value of the CSS property as a string, i.e.
linear-gradient(red, blue)
Returns the CSS key-value pair as a string, i.e.
background: linear-gradient(red, blue)
Interpolates two CSS properties given a value
t
ranging from 0.0 to 1.0. The interpolation function can be set on thecontext
(Ease
,Linear
, etc.).
Default, built-in widgets (button, label, textinput, etc.)
mod widgets:
struct Ribbon
struct Button
fn set_on_click:
fn with_on_click:
-> Button
fn dom:
-> Dom
struct FileInput
fn set_default_text:
-> FileInput
-> FileInput
fn dom:
-> Dom
struct CheckBox
fn set_on_toggle:
fn with_on_toggle:
-> CheckBox
fn dom:
-> Dom
struct Label
struct ColorInput
constructor new:
-> ColorInput
-> ColorInput
fn dom:
-> Dom
struct TextInput
fn set_text:
fn with_text:
-> TextInput
fn set_placeholder:
fn with_placeholder:
-> TextInput
-> TextInput
-> TextInput
-> TextInput
-> TextInput
-> TextInput
fn set_label_style:
fn with_label_style:
-> TextInput
fn dom:
-> Dom
struct TextInputState
struct NumberInput
constructor new:
-> NumberInput
-> NumberInput
-> NumberInput
-> NumberInput
-> NumberInput
-> NumberInput
fn set_label_style:
fn with_label_style:
-> NumberInput
-> NumberInput
fn dom:
-> Dom
struct ProgressBar
constructor new:
-> ProgressBar
fn set_height:
fn with_height:
-> ProgressBar
-> ProgressBar
-> ProgressBar
fn dom:
-> Dom
struct TabHeader
fn set_active_tab:
fn with_active_tab:
-> TabHeader
fn set_on_click:
fn with_on_click:
-> TabHeader
fn dom:
-> Dom
struct TabContent
constructor new:
-> TabContent
fn set_padding:
fn with_padding:
-> TabContent
fn dom:
-> Dom
struct Frame
fn set_flex_grow:
fn with_flex_grow:
-> Frame
fn dom:
-> Dom
struct NodeGraph
struct ListView
struct TreeView
struct DropDown
DOM to CSS cascading and styling module
mod style:
struct StyledDom
constructor new:
-> StyledDom
constructor default:
-> StyledDom
constructor from_xml:
-> StyledDom
constructor from_file:
-> StyledDom
Styles a
Dom
with the givenCss
, returning theStyledDom
- complexityO(count(dom_nodes) * count(css_blocks))
: make sure that theDom
and theCss
are as small as possible, use inline CSS if the performance isn't good enoughReturns a default, empty
Dom
, usually returned if you don't want to crash in an error case.Returns a DOM loaded from an XML file
Same as
from_xml
, but loads the file relative to the current directoryfn append_child:
fn with_child:
-> StyledDom
fn restyle:
fn node_count:
-> usize
fn get_html_string:
-> String
-> String
Appends an already styled list of DOM nodes to the current
dom.root
- complexityO(count(dom.dom_nodes))
Same as
append_child()
, but as a builder methodRestyles an already styled DOM with a new CSS - overwrites old styles, but does not replace them, useful for implementing user styles that are applied on top of the existing application style
Returns the number of nodes in the styled DOM
Returns a HTML string that you can write to a file in order to debug the UI structure and debug potential cascading issues
Returns a HTML for unit testing
Adds a menu to the root node
Adds a menu to the root node (builder method)
Adds a context menu to the root node
Adds a context menu to the root node (builder method)
OpenGl helper types (
Texture
,Gl
, etc.)mod gl:
struct Texture
constructor new:
-> Texture
constructor allocate_rgba8:
-> Texture
constructor allocate_clip_mask:
-> Texture
Allocates an OpenGL texture of a given size with a single red channel (used for image masks)
Allocates an OpenGL texture of a given size with a single red channel (used for image masks)
fn clear:
fn draw_clip_mask:
-> bool
fn draw_tesselated_svg_gpu_node:
-> bool
fn draw_tesselated_colored_svg_gpu_node:
-> bool
fn apply_fxaa:
-> bool
Clears the texture with the currently set background color
Draws a vertex / index buffer (aka.
&TessellatedSvgNode
) to the textureDraws a
&TessellatedGPUSvgNode
with the given color to the textureDraws a
&TessellatedColoredGPUSvgNode
with the given color to the textureApplies an FXAA filter to the texture
struct Gl
fn get_type:
-> GlType
fn map_buffer:
-> GlVoidPtrMut
fn map_buffer_range:
-> GlVoidPtrMut
fn unmap_buffer:
-> u8
fn tex_buffer:
fn shader_source:
fn read_buffer:
fn read_pixels:
-> U8Vec
fn sample_coverage:
fn polygon_offset:
fn pixel_store_i:
fn gen_buffers:
-> GLuintVec
-> GLuintVec
fn gen_framebuffers:
-> GLuintVec
fn gen_textures:
-> GLuintVec
-> GLuintVec
fn gen_queries:
-> GLuintVec
fn begin_query:
fn end_query:
fn query_counter:
-> i32
-> u32
-> i64
-> u64
fn delete_queries:
fn delete_buffers:
fn delete_textures:
fn depth_func:
fn active_texture:
fn attach_shader:
fn get_uniform_iv:
fn get_uniform_fv:
-> u32
-> GLuintVec
fn bind_buffer_base:
fn bind_buffer:
fn bind_framebuffer:
fn bind_texture:
fn draw_buffers:
fn tex_image_2d:
fn compressed_tex_sub_image_2d:
fn tex_image_3d:
fn tex_sub_image_2d:
fn tex_sub_image_3d:
fn tex_storage_2d:
fn tex_storage_3d:
fn invalidate_sub_framebuffer:
fn get_integer_v:
fn get_integer_64v:
fn get_integer_iv:
fn get_integer_64iv:
fn get_boolean_v:
fn get_float_v:
fn get_framebuffer_attachment_parameter_iv:
-> i32
fn get_renderbuffer_parameter_iv:
-> i32
-> i32
-> f32
fn tex_parameter_i:
fn tex_parameter_f:
fn blit_framebuffer:
fn vertex_attrib_4f:
fn viewport:
fn scissor:
fn line_width:
fn use_program:
fn validate_program:
fn draw_arrays:
fn draw_elements:
fn blend_color:
fn blend_func:
fn blend_equation:
fn color_mask:
fn cull_face:
fn front_face:
fn enable:
fn disable:
fn hint:
fn is_enabled:
-> u8
fn is_shader:
-> u8
fn is_texture:
-> u8
fn is_framebuffer:
-> u8
fn is_renderbuffer:
-> u8
-> u32
fn enable_vertex_attrib_array:
fn disable_vertex_attrib_array:
fn uniform_1f:
fn uniform_1fv:
fn uniform_1i:
fn uniform_1iv:
fn uniform_1ui:
fn uniform_2f:
fn uniform_2fv:
fn uniform_2i:
fn uniform_2iv:
fn uniform_2ui:
fn uniform_3f:
fn uniform_3fv:
fn uniform_3i:
fn uniform_3iv:
fn uniform_3ui:
fn uniform_4f:
fn uniform_4i:
fn uniform_4iv:
fn uniform_4ui:
fn uniform_4fv:
fn depth_mask:
fn depth_range:
-> GLintVec
fn get_active_uniform_block_i:
-> i32
fn get_active_uniform_block_iv:
-> GLintVec
fn get_active_uniform_block_name:
-> String
-> i32
-> i32
-> i32
-> String
fn get_program_iv:
fn program_binary:
fn get_vertex_attrib_pointer_v:
-> isize
-> i32
-> String
fn get_string:
-> String
fn get_string_i:
-> String
fn get_shader_iv:
fn compile_shader:
fn create_program:
-> u32
fn delete_program:
fn create_shader:
-> u32
fn delete_shader:
fn detach_shader:
fn link_program:
fn clear_color:
fn clear:
fn clear_depth:
fn clear_stencil:
fn flush:
fn finish:
fn get_error:
-> u32
fn stencil_mask:
fn stencil_func:
fn stencil_op:
fn egl_image_target_texture2d_oes:
fn generate_mipmap:
fn fence_sync:
-> GLsyncPtr
fn client_wait_sync:
-> u32
fn wait_sync:
fn delete_sync:
fn gen_fences_apple:
-> GLuintVec
fn set_fence_apple:
fn test_fence_apple:
-> u8
-> i32
fn bind_frag_data_location_indexed:
-> GLuintVec
fn delete_vertex_arrays_apple:
fn egl_image_target_renderbuffer_storage_oes:
fn buffer_storage:
struct VertexArrayObject
constructor new:
struct VertexBuffer
constructor new:
-> VertexBuffer
struct TextureFlags
constructor default:
-> TextureFlags
Default texture flags (not opaque, not a video texture)
Struct definitions for image loading
mod image:
struct ImageRef
constructor null_image:
-> ImageRef
constructor raw_image:
constructor gl_texture:
-> ImageRef
constructor callback:
-> ImageRef
Creates an "invalid" image with a width and height that reserves an image key, but does not render anything
Creates an image reference from a CPU-backed buffer
Creates an image reference from an OpenGL texture
Creates an image reference from a callback that is going to be rendered with the given nodes computed size
fn clone_bytes:
-> ImageRef
fn is_invalid:
-> bool
fn is_gl_texture:
-> bool
fn is_raw_image:
-> bool
fn is_callback:
-> bool
fn get_raw_image:
fn get_hash:
-> u64
Creates a new copy of the image bytes instead of shallow-copying the reference
Returns whether the image is a null (invalid) image
Returns whether the image is a GL texture
Returns whether the image is a raw (CPU-decoded) image
Returns whether the image is a
RenderImageCallback
If the image is a RawImage, returns a COPY of the internal image bytes (useful for encoding the RawImage / exporting the ImageRef to a file)
Returns the hash of the ImageRef (fast)
struct RawImage
constructor empty:
-> RawImage
constructor allocate_clip_mask:
-> RawImage
constructor decode_image_bytes_any:
Returns a zero-sized image
Allocates a width * height, single-channel image with zeroed bytes
Decodes a RawImage from any supported image format - automatically guesses the format based on magic header
fn draw_clip_mask:
-> bool
fn encode_bmp:
fn encode_png:
fn encode_jpeg:
fn encode_tga:
fn encode_pnm:
fn encode_gif:
fn encode_tiff:
Encodes the RawImage in the BMP image format
Encodes the RawImage in the PNG image format
Encodes the RawImage in the JPG image format
Encodes the RawImage in the TGA image format
Encodes the RawImage in the PNM image format
Encodes the RawImage in the GIF image format
Encodes the RawImage in the TIFF image format
Font decoding / parsing module
mod font:
struct FontMetrics
constructor zero:
-> FontMetrics
Returns a FontMetrics struct with all fields set to 0
fn use_typo_metrics:
-> bool
fn get_ascender:
-> f32
fn get_descender:
-> f32
fn get_line_gap:
-> f32
fn get_x_min:
-> f32
fn get_y_min:
-> f32
fn get_x_max:
-> f32
fn get_y_max:
-> f32
-> f32
-> f32
fn get_min_right_side_bearing:
-> f32
fn get_x_max_extent:
-> f32
-> f32
-> f32
-> f32
-> f32
-> f32
-> f32
-> f32
fn get_y_superscript_x_offset:
-> f32
fn get_y_superscript_y_offset:
-> f32
-> f32
-> f32
If set, use
OS/2.sTypoAscender - OS/2.sTypoDescender + OS/2.sTypoLineGap
to calculate the height.Atomically reference-counted parsed font data
struct FontRef
constructor parse:
Parses a new font from bytes. Returns
None
if the font could not be parsed correctly.fn get_bytes:
-> U8Vec
fn get_font_metrics:
-> FontMetrics
fn shape_text:
-> InlineText
fn get_hash:
-> u64
Returns the font bytes of the underlying font source
Returns the font metrics of the parsed font
Returns the text layout of the shaped text
Returns the hash of the FontRef (fast)
SVG parsing and rendering functions
mod svg:
struct Svg
constructor from_string:
constructor from_bytes:
fn get_root:
-> SvgXmlNode
fn render:
fn to_string:
-> String
struct SvgXmlNode
constructor parse_from:
struct SvgMultiPolygon
fn get_bounds:
-> SvgRect
fn contains_point:
-> bool
fn union:
fn intersection:
fn difference:
fn xor:
fn tessellate_fill:
Returns the bounds of the polygon
Returns whether the polygon contains a point
Unions two MultiPolygons, returns the unioned MultiPolygon
Intersects two MultiPolygons, returns the intersected MultiPolygon
Calculates the difference two MultiPolygons, returns a MultiPolygon
Xors two MultiPolygons, returns a MultiPolygon
struct SvgNode
fn tessellate_fill:
fn is_closed:
-> bool
fn contains_point:
-> bool
fn get_bounds:
-> SvgRect
Returns whether the shape is closed
Returns the bounds of the polygon
struct SvgSimpleNode
fn get_bounds:
-> SvgRect
struct SvgStyledNode
fn tessellate:
struct SvgCircle
struct SvgPath
fn is_closed:
-> bool
fn reverse:
fn get_start:
fn get_end:
fn get_bounds:
-> SvgRect
fn join_with:
fn offset:
-> SvgPath
fn bevel:
-> SvgPath
fn tessellate_fill:
Returns whether the path is closed
Reverses the order of points in the path so that the path runs in the opposite direction afterwards
Returns the first point of the path (or None if path has no items)
Returns the first point of the path (or None if path has no items)
Returns the axis-aligned bounding rect of this path
Adds a path to the end of the current path
Offset the path by a certain distance. Will create bezier curves around the edges when the path is closed
Round the edges with a cubic curve
struct SvgPathElement
fn reverse:
fn get_start:
-> SvgPoint
fn get_end:
-> SvgPoint
fn get_bounds:
-> SvgRect
fn get_length:
-> f64
fn get_t_at_offset:
-> f64
fn get_x_at_t:
-> f64
fn get_y_at_t:
-> f64
-> SvgVector
Reverses the order of points in the path so that the path runs in the opposite direction afterwards
Returns the starting point of this item
Returns the ending point of this item
Returns the bounding box of this item
Returns the length of the line or curve
Returns the interpolation value t (between 0 and 1) at the given offset from the line or curve start
Returns the point on the line or curve at t (t = interpolation value between 0 and 1)
Returns the y position of the line or curve at t
Returns the angle in DEGREES of the line or curve at t (t = interpolation value between 0 and 1)
struct SvgPoint
fn distance:
-> f64
Returns the euclidean distance to some other point
struct SvgVector
fn angle_degrees:
-> f64
fn normalize:
-> SvgVector
fn rotate_90deg_ccw:
-> SvgVector
Returns the angle of this vector in degrees
Normalizes the vector, returning the normalized vector
Rotates the vector 90 degrees counter clockwise, returning the rotated vector
struct SvgLine
fn reverse:
fn get_start:
-> SvgPoint
fn get_end:
-> SvgPoint
fn get_bounds:
-> SvgRect
fn get_length:
-> f64
fn get_t_at_offset:
-> f64
fn get_x_at_t:
-> f64
fn get_y_at_t:
-> f64
-> SvgVector
fn intersect:
Reverses the order of points in the path so that the path runs in the opposite direction afterwards
Returns the starting point of this item
Returns the ending point of this item
Returns the bounding box of this item
Returns the length of the line or curve
Returns the interpolation value t (between 0 and 1) at the given offset from the line or curve start
Returns the point on the line or curve at t (t = interpolation value between 0 and 1)
Returns the y position of the line or curve at t
Returns the angle in DEGREES of the line or curve at t (t = interpolation value between 0 and 1)
Intersect two lines EVEN IF THEY ARE DISTINCT. Only returns None on parallel lines (never intersect)
struct SvgQuadraticCurve
fn reverse:
fn get_start:
-> SvgPoint
fn get_end:
-> SvgPoint
fn get_bounds:
-> SvgRect
fn get_length:
-> f64
fn get_t_at_offset:
-> f64
fn get_x_at_t:
-> f64
fn get_y_at_t:
-> f64
-> SvgVector
Reverses the order of points in the curve so that the curve runs in the opposite direction afterwards
Returns the starting point of this item
Returns the ending point of this item
Returns the bounding box of this item
Returns the length of the line or curve
Returns the interpolation value t (between 0 and 1) at the given offset from the line or curve start
Returns the point on the line or curve at t (t = interpolation value between 0 and 1)
Returns the y position of the line or curve at t
Returns the angle in DEGREES of the line or curve at t (t = interpolation value between 0 and 1)
struct SvgCubicCurve
fn reverse:
fn get_start:
-> SvgPoint
fn get_end:
-> SvgPoint
fn get_bounds:
-> SvgRect
fn get_length:
-> f64
fn get_t_at_offset:
-> f64
fn get_x_at_t:
-> f64
fn get_y_at_t:
-> f64
-> SvgVector
Reverses the order of points in the curve so that the curve runs in the opposite direction afterwards
Returns the starting point of this item
Returns the ending point of this item
Returns the bounding box of this item
Returns the length of the line or curve
Returns the interpolation value t (between 0 and 1) at the given offset from the line or curve start
Returns the point on the line or curve at t (t = interpolation value between 0 and 1)
Returns the y position of the line or curve at t
Returns the angle in DEGREES of the line or curve at t (t = interpolation value between 0 and 1)
struct SvgRect
fn get_center:
-> SvgPoint
fn contains_point:
-> bool
fn expand:
-> SvgRect
fn tessellate_fill:
struct TessellatedColoredSvgNode
constructor empty:
constructor from_nodes:
Returns an empty buffer vertices / indices
Creates a new TessellatedColoredSvgNode by joining all the given nodes together into one array and inserting a
GL_RESTART_INDEX
(u32::MAX
) into the indices (so that the resulting buffer can be drawn in one draw call).struct TessellatedColoredGPUSvgNode
constructor new:
struct TessellatedSvgNode
constructor empty:
constructor from_nodes:
Returns an empty buffer vertices / indices
Creates a new TessellatedSvgNode by joining all the given nodes together into one array and inserting a
GL_RESTART_INDEX
(u32::MAX
) into the indices (so that the resulting buffer can be drawn in one draw call).struct TessellatedGPUSvgNode
constructor new:
struct SvgParseOptions
constructor default:
struct SvgRenderOptions
constructor default:
struct SvgFillStyle
constructor default:
-> SvgFillStyle
struct SvgStrokeStyle
constructor default:
XML parsing / decoding module
mod xml:
Filesystem / file input and output module
mod fs:
Reference-counted file handle
struct File
constructor open:
-> OptionFile
constructor create:
-> OptionFile
Opens a file at the given path. If the file exists, replaces it with a new file
Creates a file at the given path. If the file exists, replaces it with a new file
fn read_to_string:
-> OptionString
fn read_to_bytes:
-> OptionU8Vec
fn write_string:
-> bool
fn write_bytes:
-> bool
fn close:
Reads the file to a UTF8-encoded String, returns None if the file can't be decoded correctly
Reads the file as bytes, returns None if the file can't be decoded correctly
Writes a string to the file, synchronizes the results before returning
Writes some bytes to the file, synchronizes the results before returning
Destructor, closes the file handle
Interface for system file selection dialogs / popup message boxes, etc.
mod dialog:
struct MsgBox
constructor ok:
-> bool
constructor info:
-> bool
constructor warning:
-> bool
constructor error:
-> bool
constructor question:
-> bool
constructor ok_cancel:
constructor yes_no:
-> MsgBoxYesNo
Opens an informational message box with only an "OK" button
Shorthand for
MsgBox::ok("Info", $message, Icon::Info)
Shorthand for
MsgBox::ok("Warning", $message, Icon::Warning)
Shorthand for
MsgBox::ok("Error", $message, Icon::Error)
Shorthand for
MsgBox::ok("Question", $message, Icon::Question)
Opens a ok / cancel message box. Blocks the current thread.
Opens a yes / no message box. Blocks the current thread.
File picker dialog
struct FileDialog
constructor select_file:
The path that the user wants to open,
None
if the user has cancelled or closed the dialog-> OptionString
constructor select_multiple_files:
The path(s) that the user wants to open,
None
if the user has cancelled or closed the dialog
constructor select_folder:
The folder that the user wants to open,
None
if the user has cancelled or closed the dialog-> OptionString
constructor save_file:
The path that the user wants to save the file to,
None
if the user has cancelled or closed the dialog-> OptionString
Select a single file using the system-native file picker. Blocks the current thread.
Select multiple files using the system-native file picker. Blocks the current thread.
Open a dialog prompting the user to select a directory to open. Blocks the current thread.
Open a dialog prompting the user to save a file. Blocks the current thread.
struct ColorPickerDialog
constructor open:
-> OptionColorU
Opens a system-native color picker dialog
Classes to talk to the system clipboard manager
mod clipboard:
Connection to the system clipboard, on some systems this connection can be cached
struct SystemClipboard
constructor new:
Creates a new connection to the system clipboard manager
-> OptionString
-> bool
Returns the system clipboard contents or
None
if the clipboard is empty or there was an errorSets the system clipboard contents to the new string, returns true if the system clipboard was updated
Rust wrappers for
Instant
/Duration
classesmod time:
struct Instant
fn duration_since:
fn add_duration:
The new
Instant
with the added duration-> Instant
Interpolation value clamped to the 0.0 - 1.0 range
-> f32
Returns the duration since and earlier instant or None if the earlier instant is later than self
Adds a duration to the current time instant, returning the new
Instant
Linearly interpolates between [start, end] if the
self
Instant lies between start and end. Returns values between 0.0 and 1.0
Asyncronous timers / task / thread handlers for easy async loading
mod task:
struct Timer
fn with_delay:
-> Timer
fn with_interval:
-> Timer
fn with_timeout:
-> Timer
struct ThreadSender
fn send:
-> bool
struct ThreadReceiver
fn receive:
Definition of azuls internal
String
wrappersmod str:
struct String
constructor format:
-> String
constructor copy_from_bytes:
-> String
Creates a dynamically formatted String from a fomat string + named arguments
Creates a new String from an arbitary pointer, a start offset (bytes from the start pointer, usually 0) and a length (in bytes). The bytes are expected to point to a UTF-8 encoded string, no error checking is performed.
Definition of azuls internal
Vec<*>
wrappersmod vec:
Wrapper over a Rust-allocated
Vec<TessellatedSvgNode>
struct TessellatedSvgNodeVec
fn as_ref_vec:
Returns the
TessellatedSvgNodeVec
as a non-owning slice, NOTE: TheU8Vec
that this slice was borrowed from MUST NOT be deleted before theU8VecRef
Wrapper over a Rust-allocated
Vec<TessellatedColoredSvgNode>
struct TessellatedColoredSvgNodeVec
fn as_ref_vec:
Returns the
TessellatedColoredSvgNodeVec
as a non-owning slice, NOTE: TheTessellatedColoredSvgNodeVec
that this slice was borrowed from MUST NOT be deleted before theU8VecRef
Wrapper over a Rust-allocated
U8Vec
struct U8Vec
constructor copy_from_bytes:
-> U8Vec
Creates a new, heap-allocated U8Vec by copying the memory into Rust (heap allocation)
fn as_ref_vec:
-> U8VecRef
Returns the
U8Vec
as a non-owning slice, NOTE: TheU8Vec
that this slice was borrowed from MUST NOT be deleted before theU8VecRef
Definition of azuls internal
Option<*>
wrappersmod option:
Definition of error and
Result<T, E>
typesmod error: