Crate nuit

Source
Expand description

A declarative, cross-platform UI framework that uses native controls.

The API takes inspiration from contemporary reactive frameworks like SwiftUI, Xilem and React. A central design goal is to avoid using too much macro magic and instead heavily leverage associated types, traits and generics.

A simple hello world program in Nuit takes only a single line:

use nuit::Text;
 
nuit::run_app(Text::new("Hello world!"));

Macros§

assert_approx_eq
clone
Clones values for capture in a closure.

Structs§

Angle
A geometric angle.
Binding
A pair of a getter and a setter, encapsulating a reference to some value.
Button
A widget that performs an action when pressed/tapped.
CRoot
A C/FFI-compatible wrapper around Root<T>.
Capsule
A capsule shape.
Circle
A circular shape.
Color
An RGBA color.
Config
A configuration encapsulating an app with its preferred backend.
ConfigBuilder
A convenience for building a Config.
Context
A context used during rendering that tracks the path to the current view and holds a reference to internal storage.
Difference
The difference between two values.
DragEvent
An event emitted during a drag gesture.
DragGesture
A gesture recognizing a drag.
Ellipse
An elliptic shape.
Fill
A shape that fills its content using a given style.
ForEach
A group of views that is dynamically computed from a given collection.
Gestured
A view recognizing a gesture.
HStack
A view that lays out its children horizontally.
Handler
A view that handles events using a provided closure.
IdPath
A borrowed path of ids.
IdPathBuf
An owned path of ids.
Identified
A value with an id.
If
A conditional view that can take on one of at most two branches, depending on a boolean condition.
Insets
Insets along each edge of a rectangle.
List
A view that arranges its children in a stylized list.
Modified
A view that applies a modifier.
Overlay
A view that lays out its children on top of each other.
Picker
A view that lets the user choose a value.
Rectangle
A rectangular shape.
Root
The central state of a Nuit application.
RoundedRectangle
A rectangular shape with rounded corners.
Sector
A circular sector shape.
State
A wrapper around a value managed by nuit.
StateKey
A key that uniquely identifies a value in a storage.
Storage
A facility that manages view state internally.
Stroke
A shape that strokes its outline using a given style.
TapGesture
A gesture recognizing a tap.
Text
A text label.
TextField
A user-modifiable text field.
UnitPoint
A point in normalized 2D space ([0, 1] x [0, 1])
Update
VStack
A view that lays out its children vertically.
Vec2
A 2D vector (or position).
ZStack
A view that lays out its children on top of each other.

Enums§

Alignment
A 2D alignment.
Animation
An animation to use for smooth view transitions.
AnimationCurve
The curve of a simple animation.
Backend
A UI backend.
DragEventKind
Event
A UI event.
Font
An abstract/platform-dependent font.
FontDesign
FontLevel
FontSize
FontWeight
Frame
Geometry for a view.
GestureEvent
A gesture-related UI event.
GestureNode
A rendered gesture tree.
Id
An identifier for a view.
Material
A stylized, platform-specific background.
ModifierNode
A rendered modifier.
NeverGesture
A gesture type that can never be constructed.
NeverShape
A shape type that can never be constructed.
NeverView
A view type that can never be constructed.
Node
A rendered UI component tree.
ShapeNode
A rendered shape tree.
Style
A color or pattern for filling or stroking.

Constants§

DEFAULT_SPACING

Traits§

ApproxEq
A trait for approximate equality.
Bind
Binds a storage to the view’s state.
Diff
A type that can be diffed in terms of id paths.
Gesture
A composable gesture.
HasId
An identifiable value.
IdentifyExt
An extension trait for conveniently creating Identified values.
Shape
A composable shape component.
ShapeExt
An extension trait with various convenience methods for shapes.
View
The primary view trait. Represents a lightweight UI component.
ViewExt
An extension trait with various convenience methods for views.
Zero
A type that has a zero value.

Functions§

nuit_c_string_drop
run_app
Blocks and presents the given view to the user.

Derive Macros§

ApproxEq
Bind
Diff