Expand description
Common imports to build Freya apps, use it with use freya::prelude::*;.
Re-exports§
pub use freya_router;routerpub use crate::components::*;pub use crate::markdown::*;markdown
Modules§
Structs§
- Accent
Color accent-color - The user’s current system wide accent color preference.
- Accessibility
Action Event Data - Accessibility
Data - Accessibility
Id - The stable identity of a
Node, unique within the node’s tree. - Accessibility
State - Animation
Clock - Controls the animation speed of this window.
- Border
- An outline drawn around an element, with a
fillcolor, awidthper side and analignment. - Border
Width - 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
- Conic
Gradient - A gradient that transitions colors by sweeping around the element’s center.
- Corner
Radius - Radius applied to each corner of an element to round it, plus an optional
smoothingfactor (0.0..=1.0) that turns sharp rounding into a squircle. - Current
Window Id - The ID of the window whose component context is currently executing.
- Cursor
Style Data - Effect
- Creates side effect callback that is rerun when reactive values read on it, change.
- Effect
Data - Effect
State - Event
- Event
Handler - Events
Combos - Turns consecutive presses into double, triple and quadruple presses.
- File
Event Data - Fill
Render Context - Context for drawing a background or configuring text paint.
- Font
Feature - An OpenType feature of the font, enabled with a value.
- Font
Size - Defaults to
16. - Font
Weight - Thickness of a font, from
100(thin) to1000. Defaults toFontWeight::NORMAL(400). - Font
Width - Horizontal width (condensed to expanded) of a font. Defaults to
FontWidth::NORMAL. - Future
Task - Gaps
- Spacing applied around the four sides of an element, used for
paddingandmargin. - Global
Contexts - Stores values by type, shared across windows and global tasks. See the module guide for setup and usage.
- Global
Tasks - Tasks owned by the event loop rather than a window runner.
- Gradient
Stop - A single color stop within a gradient, placed at an
offsetpercentage (0.0..=100.0). - ImePreedit
Event Data - Keyboard
Event Data - Data of a Keyboard event.
- Label
- Launch
Config winit - Configuration for the initial state of the application.
- Launch
Proxy winit - Proxy wrapper provided to launch tasks so they can post callbacks executed inside the renderer.
- Layer
State - Layout
Data - Letter
Spacing - Space between letters, in pixels. Defaults to
0.0. - Linear
Gradient - A gradient that transitions colors along a straight line at a given
angle. - Memo
- Modifiers
- Pressed modifier keys.
- Mouse
Event Data - NoArg
Callback - Owned
Task Handle - An owning handle that cancels its task when the last clone is dropped.
Created with
TaskHandle::owned. - Paragraph
- Paragraph
Holder - A shared slot that receives the laid-out paragraph, so callers can hit-test and measure
text after layout. Pass it to a
paragraph()withParagraph::holder. - Platform
- Application-wide platform api.
- Platform
Window - State and APIs for a given window.
- Radial
Gradient - A gradient that transitions colors outward in a circle from the element’s center.
- Reactive
Context - Readable
- A type-erased readable state that only exposes the value type
T. - Rect
- Render
Callback - Render
Context - Renderer
Context winit - Rendering
Ticker - Receives frame notifications.
- Scale
- A scale factor applied to an element on each axis, where
1.0is the original size. - ScopeId
- Screen
Reader - Shader
Fill - A custom paint source backed by an SkSL shader.
- Shadow
- A shadow cast by an element.
- Sized
Event Data - Data of a Sized event.
- Span
- A run of text with its own style, used to build a
paragraph(). - Srgba
accent-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
Tand manages subscriptions to changes. - Style
State - Styled
Event Data - Data of a Styled event.
- Task
- A component or window task scheduled by the runner.
- Task
Handle - A non-owning task handle whose drop does not cancel the task.
Use
TaskHandle::ownedfor cancellation on drop. - TaskId
- The opaque identifier of a task scheduled by Freya’s async runtime.
- Task
Waker - Wakes a Freya task by asking the runner to poll it again.
- Text
Shadow - A shadow cast behind text, with a
Color, an(x, y)offset and a blur sigma. - Text
Style Data - Text
Style State - Touch
Event Data - Data of a Touch event.
- Transform
Origin - Reference point that the scale and rotation effects of an element pivot around.
- UseId
- Visible
Event Data - Data of a Visible event.
- Wheel
Event Data - Data of a Wheel event.
- Window
Config winit - Configuration for a Window.
- Writable
- A writable reactive value that hides its backing storage type.
- Writable
Setter - A writable value whose updates go through a setter callback.
Enums§
- Accessibility
Action - An action to be taken on an accessibility node.
- Accessibility
Focus Movement - Strategy focusing an Accessibility Node.
- Accessibility
Focus Strategy - Strategy focusing an Accessibility Node.
- Accessibility
Role - The type of an accessibility node.
- Alignment
- Aspect
Ratio - How an image is scaled to fit its bounds while preserving its aspect ratio.
- Border
Alignment - Where a
Borderis drawn relative to the element’s edge. - Border
Shape - Brightness
- A color’s classification for choosing black or white foreground text.
- Clipboard
Error - Close
Decision winit - Decision returned by the
on_closehook 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.
- Cursor
Icon - Describes the appearance of the (usually mouse) cursor icon.
- Cursor
Mode - Determines how the cursor and highlights are positioned within a Paragraph.
- Cursor
Style - Shape of the text cursor drawn in a
paragraph. - DiffKey
- Direction
- Element
- Event
Type - 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. - Focus
Press Event Data - Data delivered to
on_focus_press, which can originate from a mouse or a touch. - Focusable
- Whether an element can receive keyboard focus.
- Font
Slant - Slant (style) of a font.
- Force
- Future
State - Global
User Event - GpuPreference
winit - Preferred GPU type, with fallback to other available hardware.
- GpuResource
Cache Limit winit - GPU resource cache limit used by the renderer.
- Image
Cover - 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.
- Mouse
Button - Named
Key - Key represents the meaning of a keypress.
- Native
Event winit - Navigation
Mode - How the user is navigating the application.
- Origin
Value - Position of a
TransformOriginalong a single axis. - Overflow
- Whether content overflowing an element’s bounds is shown or clipped.
- Pointer
Event Data - Data of a pointer event.
- Position
- How an element is placed relative to its parent or the window.
- Preferred
Theme - The color theme preferred by the operating system.
- Press
Event Data - Data delivered to
on_pressfrom a mouse, keyboard, touch or assistive technology. - Press
Event Type - Position of a press inside a combo.
- Readable
Ref - Render
Target - Custom fill target.
- Renderer
Preference winit - Graphics driver preference a window asks for.
- Sampling
Mode - The filtering algorithm used when an image is scaled.
- Shadow
Position - Whether a
Shadowis cast outside the element or inside it. - Size
- Target
Platform - Operating system targeted by an application.
- Text
Align - Horizontal alignment of text within its element.
- Text
Decoration - A line drawn through, under or over text.
- Text
Height Behavior - Controls whether the extra leading height of the first and last lines is kept or trimmed.
- Text
Overflow - How text that does not fit its bounds is truncated.
- Text
Width - Whether text sizes itself to its content or expands to the available width.
- Touch
Phase - User
Event - Vertical
Align - Vertical alignment for Paragraph text rendering.
- Visible
Size - Controls the percentage of the measured size that will actually be used in layout, regardless of the element’s own size.
- Wheel
Source
Traits§
- Accessibility
Ext - Methods for describing an element in the accessibility tree.
- Accessibility
IdExt - 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.
- Background
Ext - Methods for painting an element’s background.
- Children
Ext - 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.
- Component
Key - Component
Owned - Container
Constraints Ext - Methods for setting an element’s size constraints.
- Container
Ext - Method for setting an element’s inner padding.
- Container
Position Ext - Methods for setting how an element is placed relative to its parent or the window.
- Container
Size Ext - Methods for setting an element’s width and height.
- Container
With Content Ext - Layout methods for containers that arrange children along a direction axis.
- Corner
Radius Ext - Shorthand methods for setting an element’s
CornerRadiusto common values. - Debug
Ext - Decoration
Ext - Methods for decorating an element.
- Effect
Ext - Methods for visual effects applied to an element: clipping, backdrop blur, rotation, opacity and scale.
- Event
Handlers Ext - Methods for attaching event handlers to an element.
- Image
Ext - Methods for configuring how an image is scaled and sampled.
- Interactive
Ext - Method for controlling whether an element responds to pointer events.
- Into
Element - Into
Readable - Into
Writable - Into
Writable Setter - KeyExt
- Trait for giving an element a stable identity across renders.
- Keyboard
Event Ext - Extension trait for
KeyboardEventDatawith focus-related helpers. - Layer
Ext - Method for controlling which painting layer an element belongs to.
- Layout
Ext - Low-level access to an element’s
LayoutData. - Maybe
Ext - Methods for applying changes to an element conditionally.
- Modifiers
Ext - Extension trait for
Modifiersadding platform-aware helpers. - Scrollable
Ext - Shader
Provider - Style
Ext - Low-level access to an element’s
StyleState. - Text
Overflow Ext - Methods for truncating text within an element’s bounds.
- Text
Style Ext - Methods for styling the text rendered by an element and inherited by its children.
- Window
Drag Ext winit - Winit
Platform Ext winit - Extension trait that adds winit-specific window management capabilities to
Platform. - Winit
Platform Window Ext winit - Winit APIs for the selected window, not necessarily the focused window.
- WithExt
- Methods for unconditionally modifying an element.
- Writable
Utils - 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.
- launch
winit - 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.
Noneuses 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
TaskHandlecan 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.
- thread
Non-Emscripten - Runs a blocking closure off the caller’s thread.
- timer
Non-Emscripten - Waits for the given duration.
- try_
consume_ context - Look for a value in the current component, then its parents. Returns
Noneif not found. - try_
consume_ context_ from_ scope_ id - Look for a value in the given scope, then its parents. Returns
Noneif not found. PassNoneto start at the current scope. - try_
consume_ own_ context - Get a value from the current component only, or
Noneif not found. - try_
consume_ root_ context - Get a value from the window’s root only, or
Noneif not found. - use_
a11y - Create a unique
AccessibilityIdthat 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
Focusstate of anAccessibilityId. - 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
initto 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, useGlobalContexts. - use_
reactive - Convert a borrowed value (
&T) into a component-scopedState<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 itsState<T>. - use_
side_ effect_ with_ deps - Hook for
Effect::createwith reactivedeps. Registers the effect once per component. - use_
state - Creates a reactive state value initialized with the returned value of the
initcallback. - use_
try_ consume - Look for a value in this component, then its parents. Returns
Noneif not found. Returns the same result on later renders.
Type Aliases§
- Area
- Area used by a Node, including its margins.
- Cursor
Point - Event
Handlers - ReadRef
- Size2D
- Size2D
Fixed - Write
Ref