Expand description
⚡ This crate is the core of Zaplib. It contains all the fundamental rendering primitives.
Internally it depends on [zaplib_shader_compiler
] and [zaplib_vector
],
for shader compilation and vector graphics (mostly for fonts) respectively.
If you need to use higher-level widgets, use zaplib_components
.
Re-exports
pub use cast::*;
pub use universal_file::*;
Modules
Read the desired data type in as few instructions as possible. This is technically
unsafe if you’re reading past the end of a buffer, but we’re not going to worry
about that for performance. This saves a relatively expensive boundary
check when using safe functions like from_le_bytes
with try_into().unwrap()
.
Functions for semi-safely casting various things to each other.
Version of rand
that also works in WebAssembly.
Version of std::thread
that also works in WebAssembly.
Macros
Tag a piece of code with filename+line+col. The line+col are done in a hacky way, exploiting the fact that rustfmt usually puts the multiline string start on a newline, with one greater indentation level. This doesn’t always work but it’s close enough!
Generates a crate::hash::LocationHash
based on the current file/line/column.
Logging helper that works both on native and WebAssembly targets.
Define the entry point of your application.
Define state-less entry point
Structs
An actual animation that can be played.
Identifier that represents a particular “component” on the screen, even if it gets moved around or disappears temporarily.
Draw a cube; similar to crate::QuadIns
. Is currently not used much, so mostly
for demonstration purposes.
The main “context” object which contains pretty much everything we need within the framework.
Some font-related stuff gets drawn at the end of each draw cycle.
Flags that can be set that enable debug functionality. See Cx::debug_flags_mut
for an example.
A context object containing everything font releated. This is used in different places to render text and also
This represents an actual call to the GPU, or it can represent a
sub-View
, in case DrawCall::sub_view_id
is set. Note that all of this behaves
completely differently if DrawCall::sub_view_id
is set; all regular drawing fields
are ignored in that case!
A pointer to a [CxFont
] (indexed in CxFontsData::fonts
using Font::font_id
),
Generated geometry data used for instanced rendering, represented as triangles.
A pointer to a [CxGpuGeometry
] (indexed in Cx::gpu_geometries
using GpuGeometry::gpu_geometry_id
),
Pointer to a part of a DrawCall
, e.g. from Cx::add_instances
. This pointer
points to a range of instances, where the first index is indicated by
InstanceRangeArea::instance_offset
, and the size of the
range by InstanceRangeArea::instance_count
.
Data for various kinds of key-based events (Event::KeyDown
, Event::KeyUp
, etc).
Modifiers that were held when a key event was fired.
Determines how a [CxLayoutBox
] should walk. Can be applied to a new [CxLayoutBox
]
through [Layout::layout_size
], or directly to move an existing [CxLayoutBox
] by
using Cx::add_box
.
Represents a particular place in the code. Useful e.g. for shaders; see the
documentation of crate::Shader
.
4x4 matrix; very common in graphics programming.
Inner padding dimensions that should be applied on top of a Rect
or other
object that defines dimensions.
A rendering context e.g. for doing 3d rendering.
QuadIns
is the basis for most draw structs.This renders a rectangle.
There are some default shaders available at QuadIns::SHADER
.
Quaternion; used for rotations.
Represents an (axis-aligned) rectangle. Axis-aligned means that you can’t rotate it.
Contains all information necessary to build a shader. Define a new shader.
For firing and capturing custom events. Can even be fired from different
threads using Cx::post_signal
.
See Event::Signal
.
TODO(JP): Is this a bit too complicated of an API? What about if we just
send pub signal: u64
, or even a Box
? Then you can use it for anything.
Some props for how to render the text.
Style for how to render text.
A persistent reference to a GPU texture.
A pointer to a [CxTexture
] (indexed in Cx::textures
using TextureHandle::texture_id
),
Created using Cx::start_timer
.
A common type of transformation, that includes a rotation (Transform::orientation
)
and translation (Transform::position
).
Version of std::time::Instant
that also works in WebAssembly.
A file that was supplied by a user, as opposed to by the application itself (like font resources and such).
Pointer to a particular view in the draw tree, using a ViewArea::view_id
. Note
that a View::view_id
only gets set when it gets drawn.
Fires when a web worker calls callRustAsync
to trigger a function in Rust.
A pointer to a [CxWindow
] (indexed in Cx::windows
using Window::window_id
),
See Event::WindowDragQuery
.
To respond, set response
field to a variant of WindowDragQueryResponse
.
Information on the geometry and capabilities of a particular native window.
Enums
An Area
can be thought of as a “pointer” into the draw tree. You typically
get one as the result of a draw command, like Cx::add_instances
,
or View::end_view
.
The color to either initialize a Texture
with (when rendering it for the very first time),
or to clear it with on every paint.
The depth to either initialize a Texture
with (when rendering it for the very first time),
or to clear it with on every paint.
Represents a location in a file, and the code string itself. Generate easily
using the zaplib::code_fragment!()
macro.
What kind of debug information should be printed about the draw tree.
The direction in which the [CxLayoutBox
] should walk. It will typically walk
in a straight line in this direction. E.g. when walking to Direction::Right
,
it will only walk horizontally, not vertically, until it hits the [CxLayoutBox::width
],
at which point it will wrap around using LineWrap
, based on the maximum
height of widgets that have been drawn so far, which is registered in
[CxLayoutBox::biggest
].
Describes how output values of a Track
get mapped for fractions in between
keyframes. See these pages for more explanations:
Global event passed into an application’s handle
function. See contained structs for more details.
Different ways in which a LayoutSize
can get a height.
The type of PointerHoverEvent
.
Lowest common denominator keymap between desktop and web.
Represents a single menu, as well as all menus (recursively).
The type of input that was used to trigger a pointer event.
The type of mouse cursor to show. Enjoy the ASCII art here.
Standard types of projection matrices.
Contains information about the platform (operating system) that we’re running on.
The type of input that was used to trigger a pointer event.
Represents a single value that changes during the course of an animation.
Should remain consistent in its type and what it represents between the
different animations that you pass into a single Animator
.
Variable type in shader code.
Different ways in which a LayoutSize
can get a width.
Response to operating system inquiry if a Window
can be dragged.
Determines when to emit a set of glyphs, which has roughly the effect of wrapping at these boundaries.
Constants
Statics
Traits
A bunch of traits that are common between the native platforms and the WebAssembly platform. This trait makes sure that there is consistency in the interface, and provides one place for documentation.
A bunch of traits that are common between the different target platforms. This trait makes sure that there is consistency in the interface, and provides one place for documentation.
Version of std::time::Instant
that also works in WebAssembly.
A trait for the combination of reading and seeking.
Functions
Get the page id for a particular font_id/dpi_factor/font_size combination.
Type Definitions
An alias over LocationHash so we have a semantic type
but can change the underlying implementation whenever.
See Event::Command
.