Expand description
š¢ā” This crate is the core of Wrf. It contains all the fundamental rendering primitives.
Internally it depends on wrflib_shader_compiler
and wrflib_vector
,
for shader compilation and vector graphics (mostly for fonts) respectively.
If you need to use higher-level widgets, use wrflib_widget
.
Re-exports
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()
.
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.
This is an application-level event intended for platforms that can register a file type to an application. Fires:
Represents a location in a file, and the code string itself. Generate easily
using the wrflib::code_fragment!()
macro.
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!
When a file is being dragged and the mouse position changes
A conceptual āfingerā (mouse, actual finger, etc) was pressed down.
A conceptual āfingerā (mouse, actual finger, etc) was hovered over the screen.
A conceptual āfingerā (mouse, actual finger, etc) was moved.
A conceptual āfingerā (mouse, actual finger, etc) triggered a scroll.
A conceptual āfingerā (mouse, actual finger, etc) was released.
A pointer to a [CxFont
] (indexed in CxFontsData::fonts
using Font::font_id
),
Generated geometry data, used for instanced rendering.
A pointer to a [CxGpuGeometry
] (indexed in Cx::gpu_geometries
using GpuGeometry::gpu_geometry_id
),
Modify the behavior of Event::hits
.
Represents an āinstanceā GPU input in a Shader
.
Represents all āinstanceā GPU inputs in a Shader
.
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).
Called when Cx::key_focus
changes.
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
.
A margin around the area that is checked for event hits
4x4 matrix; very common in graphics programming.
A generic representation of a list of Shader
inputs (instance/uniform/geometry).
Inner padding dimensions that should be applied on top of the width/height
from the parent [CxLayoutBox
].
TODO(JP): these values can be negative, which can be quite confusing, but we
seem to actually honor that in the layout boxes code. Might be good to look into that
and see if we should forbid that or not (we seem to never actually do that yet).
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 information about the special ārect_posā and ārect_sizeā fields.
These fields describe the typical rectangles drawn in crate::QuadIns
. It is
useful to have generalized access to them, so we can e.g. move a whole bunch
of rectangles at the same time, e.g. for alignment in [CxLayoutBox
].
TODO(JP): We might want to consider instead doing bulk moves using [DrawCall
-
or View
-level uniforms.
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
.
Represents a signal that was fired from Cx::send_signal
. Can be captured
with Signal
.
Some text was inputted. Rely on this for text input instead of KeyEvent
s.
Some props for how to render the text.
Style for how to render text. TODO(hernan): Should we include color and font scaling as part of the text style?
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 Timer
that was requested using Cx::start_timer
has fired.
A common type of transformation, that includes a rotation (Transform::orientation
)
and translation (Transform::position
).
Represents a āuniformā GPU input in a Shader
.
Represents all āuniformā GPU inputs in a Shader
.
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 callRust
to trigger a function in Rust.
A websocket message was received.
A pointer to a [CxWindow
] (indexed in Cx::windows
using Window::window_id
),
The user requested to close the Window
.
The Window
actually closed.
The operating system inquired if a Window
can be dragged.
Information on the geometry and capabilities of a particular native window.
Geometry of a Window
changed (position, size, etc).
The user started or ended resizing the 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.
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 that gets passed into handle
, and which you can pass down to your own widgets.
The type of input that was used to trigger a finger event.
Different ways in which a LayoutSize
can get a height.
The type of FingerHoverEvent
.
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 finger 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.
Events that are handled internally and are not propagated to an application handle
method.
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.