Skip to main content

Module prelude

Module prelude 

Source
Expand description

Common imports to build Freya apps, use it with use freya::prelude::*;.

Re-exports§

pub use freya_router;router
pub use crate::components::*;
pub use crate::markdown::*;markdown

Modules§

data
emittable
executor
measurer
modifiers
name
platform

Structs§

AccentColoraccent-color
The user’s current system wide accent color preference.
AccessibilityActionEventData
AccessibilityData
AccessibilityId
The stable identity of a Node, unique within the node’s tree.
AccessibilityState
AnimationClock
Controls the animation speed of this window.
Border
An outline drawn around an element, with a fill color, a width per side and an alignment.
BorderWidth
Width of each side of a Border, in pixels.
Bytes
A cheaply cloneable and sliceable chunk of contiguous memory.
Callback
Clipboard
App clipboard.
Color
Represents one color. You may create Colors using
ConicGradient
A gradient that transitions colors by sweeping around the element’s center.
CornerRadius
Radius applied to each corner of an element to round it, plus an optional smoothing factor (0.0..=1.0) that turns sharp rounding into a squircle.
CurrentWindowId
The ID of the window whose component context is currently executing.
CursorStyleData
Effect
Creates side effect callback that is rerun when reactive values read on it, change.
EffectData
EffectState
Event
EventHandler
EventsCombos
Turns consecutive presses into double, triple and quadruple presses.
FileEventData
FillRenderContext
Context for drawing a background or configuring text paint.
FontFeature
An OpenType feature of the font, enabled with a value.
FontSize
Defaults to 16.
FontWeight
Thickness of a font, from 100 (thin) to 1000. Defaults to FontWeight::NORMAL (400).
FontWidth
Horizontal width (condensed to expanded) of a font. Defaults to FontWidth::NORMAL.
FutureTask
Gaps
Spacing applied around the four sides of an element, used for padding and margin.
GlobalContexts
Stores values by type, shared across windows and global tasks. See the module guide for setup and usage.
GlobalTasks
Tasks owned by the event loop rather than a window runner.
GradientStop
A single color stop within a gradient, placed at an offset percentage (0.0..=100.0).
ImePreeditEventData
KeyboardEventData
Data of a Keyboard event.
Label
LaunchConfigwinit
Configuration for the initial state of the application.
LaunchProxywinit
Proxy wrapper provided to launch tasks so they can post callbacks executed inside the renderer.
LayerState
LayoutData
LetterSpacing
Space between letters, in pixels. Defaults to 0.0.
LinearGradient
A gradient that transitions colors along a straight line at a given angle.
Memo
Modifiers
Pressed modifier keys.
MouseEventData
NoArgCallback
OwnedTaskHandle
An owning handle that cancels its task when the last clone is dropped. Created with TaskHandle::owned.
Paragraph
ParagraphHolder
A shared slot that receives the laid-out paragraph, so callers can hit-test and measure text after layout. Pass it to a paragraph() with Paragraph::holder.
Platform
Application-wide platform api.
PlatformWindow
State and APIs for a given window.
RadialGradient
A gradient that transitions colors outward in a circle from the element’s center.
ReactiveContext
Readable
A type-erased readable state that only exposes the value type T.
Rect
RenderCallback
RenderContext
RendererContextwinit
RenderingTicker
Receives frame notifications.
Scale
A scale factor applied to an element on each axis, where 1.0 is the original size.
ScopeId
ScreenReader
ShaderFill
A custom paint source backed by an SkSL shader.
Shadow
A shadow cast by an element.
SizedEventData
Data of a Sized event.
Span
A run of text with its own style, used to build a paragraph().
Srgbaaccent-color
A color in the sRGB color space. Each component is in the range [0, 1].
State
A reactive state container that holds a value of type T and manages subscriptions to changes.
StyleState
StyledEventData
Data of a Styled event.
Task
A component or window task scheduled by the runner.
TaskHandle
A non-owning task handle whose drop does not cancel the task. Use TaskHandle::owned for cancellation on drop.
TaskId
The opaque identifier of a task scheduled by Freya’s async runtime.
TaskWaker
Wakes a Freya task by asking the runner to poll it again.
TextShadow
A shadow cast behind text, with a Color, an (x, y) offset and a blur sigma.
TextStyleData
TextStyleState
TouchEventData
Data of a Touch event.
TransformOrigin
Reference point that the scale and rotation effects of an element pivot around.
UseId
VisibleEventData
Data of a Visible event.
WheelEventData
Data of a Wheel event.
WindowConfigwinit
Configuration for a Window.
Writable
A writable reactive value that hides its backing storage type.
WritableSetter
A writable value whose updates go through a setter callback.

Enums§

AccessibilityAction
An action to be taken on an accessibility node.
AccessibilityFocusMovement
Strategy focusing an Accessibility Node.
AccessibilityFocusStrategy
Strategy focusing an Accessibility Node.
AccessibilityRole
The type of an accessibility node.
Alignment
AspectRatio
How an image is scaled to fit its bounds while preserving its aspect ratio.
BorderAlignment
Where a Border is drawn relative to the element’s edge.
BorderShape
Brightness
A color’s classification for choosing black or white foreground text.
ClipboardError
CloseDecisionwinit
Decision returned by the on_close hook to determine whether a window should close.
Code
Code is the physical position of a key.
Content
Controls how a parent’s children are laid out.
CursorIcon
Describes the appearance of the (usually mouse) cursor icon.
CursorMode
Determines how the cursor and highlights are positioned within a Paragraph.
CursorStyle
Shape of the text cursor drawn in a paragraph.
DiffKey
Direction
Element
EventType
Fill
A paint source for backgrounds and text: a solid Color, a gradient or a custom shader.
Focus
Focus state for an AccessibilityId, distinguishing keyboard vs pointer focus.
FocusPressEventData
Data delivered to on_focus_press, which can originate from a mouse or a touch.
Focusable
Whether an element can receive keyboard focus.
FontSlant
Slant (style) of a font.
Force
FutureState
GlobalUserEvent
GpuPreferencewinit
Preferred GPU type, with fallback to other available hardware.
GpuResourceCacheLimitwinit
GPU resource cache limit used by the renderer.
ImageCover
How an image is positioned within its bounds once it has been scaled.
Interactive
Whether an element (and its descendants) responds to pointer events.
Key
The value received from the keypress.
Layer
The painting layer of an element, controlling what it draws on top of.
MouseButton
NamedKey
Key represents the meaning of a keypress.
NativeEventwinit
NavigationMode
How the user is navigating the application.
OriginValue
Position of a TransformOrigin along a single axis.
Overflow
Whether content overflowing an element’s bounds is shown or clipped.
PointerEventData
Data of a pointer event.
Position
How an element is placed relative to its parent or the window.
PreferredTheme
The color theme preferred by the operating system.
PressEventData
Data delivered to on_press from a mouse, keyboard, touch or assistive technology.
PressEventType
Position of a press inside a combo.
ReadableRef
RenderTarget
Custom fill target.
RendererPreferencewinit
Graphics driver preference a window asks for.
SamplingMode
The filtering algorithm used when an image is scaled.
ShadowPosition
Whether a Shadow is cast outside the element or inside it.
Size
TargetPlatform
Operating system targeted by an application.
TextAlign
Horizontal alignment of text within its element.
TextDecoration
A line drawn through, under or over text.
TextHeightBehavior
Controls whether the extra leading height of the first and last lines is kept or trimmed.
TextOverflow
How text that does not fit its bounds is truncated.
TextWidth
Whether text sizes itself to its content or expands to the available width.
TouchPhase
UserEvent
VerticalAlign
Vertical alignment for Paragraph text rendering.
VisibleSize
Controls the percentage of the measured size that will actually be used in layout, regardless of the element’s own size.
WheelSource

Traits§

AccessibilityExt
Methods for describing an element in the accessibility tree.
AccessibilityIdExt
Extension trait for AccessibilityId.
App
App is a trait for root-level application components. Types implementing App automatically implement Component and have a blanket PartialEq implementation that always returns true.
BackgroundExt
Methods for painting an element’s background.
ChildrenExt
Trait for composing child elements.
Component
Encapsulate reusable pieces of UI by using the Component trait. Every Component creates a new layer of state in the app, meaning that implementors of Component can make use of hooks in their Component::render method.
ComponentKey
ComponentOwned
ContainerConstraintsExt
Methods for setting an element’s size constraints.
ContainerExt
Method for setting an element’s inner padding.
ContainerPositionExt
Methods for setting how an element is placed relative to its parent or the window.
ContainerSizeExt
Methods for setting an element’s width and height.
ContainerWithContentExt
Layout methods for containers that arrange children along a direction axis.
CornerRadiusExt
Shorthand methods for setting an element’s CornerRadius to common values.
DebugExt
DecorationExt
Methods for decorating an element.
EffectExt
Methods for visual effects applied to an element: clipping, backdrop blur, rotation, opacity and scale.
EventHandlersExt
Methods for attaching event handlers to an element.
ImageExt
Methods for configuring how an image is scaled and sampled.
InteractiveExt
Method for controlling whether an element responds to pointer events.
IntoElement
IntoReadable
IntoWritable
IntoWritableSetter
KeyExt
Trait for giving an element a stable identity across renders.
KeyboardEventExt
Extension trait for KeyboardEventData with focus-related helpers.
LayerExt
Method for controlling which painting layer an element belongs to.
LayoutExt
Low-level access to an element’s LayoutData.
MaybeExt
Methods for applying changes to an element conditionally.
ModifiersExt
Extension trait for Modifiers adding platform-aware helpers.
ScrollableExt
ShaderProvider
StyleExt
Low-level access to an element’s StyleState.
TextOverflowExt
Methods for truncating text within an element’s bounds.
TextStyleExt
Methods for styling the text rendered by an element and inherited by its children.
WindowDragExtwinit
WinitPlatformExtwinit
Extension trait that adds winit-specific window management capabilities to Platform.
WinitPlatformWindowExtwinit
Winit APIs for the selected window, not necessarily the focused window.
WithExt
Methods for unconditionally modifying an element.
WritableUtils
A shared interface for types that provide reactive write access to a value of type T.

Functions§

consume_context
Look for a value in the current component, then its parents. Panics if not found.
consume_root_context
Get a value from the window’s root only. Panics if not found.
current_scope_id
image
image makes it possible to render a Skia image into the canvas. You most likely want to use a higher level than this, like the component ImageViewer.
label
Draw text with label(). Its a simplified version of crate::elements::paragraph.
launchwinit
mark_scope_as_dirty
paragraph
paragraph() makes it possible to render rich text with different styles. Its a more customizable API than crate::elements::label.
provide_context
Store a value in the current component, replacing any value of the same type.
provide_context_for_scope_id
Store a value in the given scope, replacing any value of the same type. None uses the current scope. The target scope must exist in the current window.
provide_root_context
Store a value in the window’s root, replacing any value of the same type. To share across windows, use GlobalContexts.
rect
rect() acts as a generic container to contain other elements inside, like a box.
spawn
Spawn a task cancelled when its current component unmounts. The returned TaskHandle can cancel it earlier.
spawn_global
Spawn an event-loop task with global context that survives window closure. It has no component context and must not retain window-owned state.
spawn_in_scope
Spawn a task attached to the given scope, or to the current one when passing None.
spawn_in_window
Spawn a task that survives its component but is cancelled when its window closes.
threadNon-Emscripten
Runs a blocking closure off the caller’s thread.
timerNon-Emscripten
Waits for the given duration.
try_consume_context
Look for a value in the current component, then its parents. Returns None if not found.
try_consume_context_from_scope_id
Look for a value in the given scope, then its parents. Returns None if not found. Pass None to start at the current scope.
try_consume_own_context
Get a value from the current component only, or None if not found.
try_consume_root_context
Get a value from the window’s root only, or None if not found.
use_a11y
Create a unique AccessibilityId that persists for the lifetime of the component.
use_after_side_effect
Hook for Effect::create_after. Registers the effect once per component.
use_consume
Look for a value in this component, then its parents. Panics if not found. Returns the same value on later renders.
use_drop
Run a callback for when the component gets dropped. Useful to clean resources.
use_focus
Reactively track the Focus state of an AccessibilityId.
use_future
Create a FutureTask with the given callback.
use_hook
This is the foundational hook used by all. It’s simple, it accepts an initialization callback whose return value will be stored in this component instance until its dropped. In subsequent renders the returned value of the function will be a Cloned value of what had been previously returned by the initialization callback.
use_id
Get a unique for a given generic type.
use_memo
Registers a callback that will run every time a State which was .read() inside, changes. It also returning a type that will get cached after the callback runs, thus allowing this to be used as a way to cache expensive values.
use_previous_and_current
Track the previous and current values of a reactive value.
use_provide_context
Create a value once in this component and make it available to descendants. Returns the same value on later renders.
use_provide_root_context
Reuse a value from the window’s root, or call init to create it if missing. Returns the same value on later renders. The value is stored in the root, not this component. To share across windows, use GlobalContexts.
use_reactive
Convert a borrowed value (&T) into a component-scoped State<T>.
use_side_effect
Hook for Effect::create. Registers the effect once per component.
use_side_effect_value
Hook for Effect::create_value. Registers the effect once per component and returns its State<T>.
use_side_effect_with_deps
Hook for Effect::create with reactive deps. Registers the effect once per component.
use_state
Creates a reactive state value initialized with the returned value of the init callback.
use_try_consume
Look for a value in this component, then its parents. Returns None if not found. Returns the same result on later renders.

Type Aliases§

Area
Area used by a Node, including its margins.
CursorPoint
EventHandlers
ReadRef
Size2D
Size2DFixed
WriteRef