Translator's note: If you can read Chinese, please prioritize reading the Chinese version; this is the author's original manuscript, other language versions are primarily translated by AI models and are for reference only.

Crate Structure

Graphics backend and platform layer are at the same dependency level, not depending on each other, selected by core framework via feature.

CratePurposeDependency Level
flor-baseShared types, platform abstraction and graphics abstraction.L0 Base
flor-macrosProcedural macros (style!, color!, etc.).L0 Base
flor-graphics-direct2dDirect2D rendering backend.L1 Render Backend
flor-graphics-openglOpenGL rendering backend.L1 Render Backend
flor-graphics-tiny-skiaTiny Skia rendering backend.L1 Render Backend
flor-platform-windowsWindows platform implementation.L1 Platform Layer
florCore framework: view system, signals, event loop, window management.L2 Framework

Lower layer numbers mean more foundational; crates at the same layer don't depend on each other.

Framework Features

flor doesn't enable any features by default. Applications usually need at least one rendering backend, then enable layout, atomic class, platform capabilities etc. as needed.

[dependencies]
flor = { version = "0.1.0", features = ["direct2d", "tiny-skia", "layout-flex", "class"] }

Below are features exposed to users by flor crate. View libraries may forward some of these features, but framework-side names are as listed here. For detailed usage of platform capabilities, see Framework Capabilities.

Rendering Backends

Rendering backends submit Flor's drawing commands to specific graphics implementations. Applications need to enable at least one backend; if both GPU backend and tiny-skia are enabled, it will continue trying CPU backend after GPU initialization fails.

FeatureBackend TypeBackend CrateSupported PlatformsPurpose
direct2dGPUflor-graphics-direct2dWindowsWindows native Direct2D backend.
openglGPUflor-graphics-openglWindows (current implementation)OpenGL backend.
tiny-skiaCPUflor-graphics-tiny-skiaWindows (current implementation)Pure CPU rasterization backend, can be fallback when GPU backend initialization fails.

direct2d and opengl both enable gpu-render-backend marker; choose one GPU backend in the same build. tiny-skia enables cpu-render-backend marker, can be enabled together with a GPU backend.

Drawing Capabilities

These features are not backends themselves, but add drawing or resource capabilities on enabled backends.

FeatureSupported BackendsSupported PlatformsPurpose
svgdirect2d / opengl / tiny-skiaFollows enabled rendering backend; current implementation is WindowsEnables SVG resource and SVG drawing support.
memory-fontdirect2d / opengl / tiny-skiaFollows enabled rendering backend; current implementation is WindowsEnables loading fonts from memory.

Basic shapes, text, images and other conventional drawing capabilities are provided by rendering backends, no need to additionally enable svg or memory-font.

Layout and Class

FeaturePurpose
layout-flexEnables Flex layout related capabilities.
layout-gridEnables Grid layout related capabilities.
layout-blockEnables Block layout related capabilities.
classEnables .class(...) atomic class capability.

For complete layout builder methods, see Layout Builder. For class usage, see Atomic Class. For layout class syntax list, see Layout Class Syntax.

Platform Capabilities

FeaturePurpose
clipboardClipboard capability.
drag-dropDrag-drop events and related handlers.
traySystem tray capability.
theme-changeSystem theme change related capability.
monitorMonitor information related capability.
hi-dpiHigh DPI related capability.
cross-thread-window-creationAllows cross-thread window creation.

For feature-controlled parts in event builder and handlers, see Event Builder and Handler API.

Development and Internal Selection

FeaturePurpose
signal-tracingPreserves signal labels in release mode for subsequent tracing and debugging.
cpu-render-backendCPU rendering chain marker, usually indirectly enabled by tiny-skia.
gpu-render-backendGPU rendering chain marker, usually indirectly enabled by direct2d or opengl.
no-check-backendSkips "must enable at least one rendering backend" compile check, usually only for special middle layers or test scenarios.

Applications usually directly enable direct2d, opengl or tiny-skia. Don't manually enable only cpu-render-backend / gpu-render-backend internal markers.

Introduction to Each Part

What you need to know for simply using the framework

By default you'll use it with a view library, prioritize these contents:

  • Initialization and message loop
  • Window Creation and Control
  • Cross-thread reactive signal system
  • Use class or declarative builder to configure layout and style
  • Enable framework features as needed

What you need to know for developing views

By default you already know how to use Flor to write applications, then continue with these contents:

  • View trait: Trait that new views need to implement. Framework manages lifecycle, events, drawing etc. flows.
  • ViewId: View's unique ID, also provides runtime access entries for parent-child relationships, focus, scroll, visibility state, redraw etc.
  • Resolver attribute macro and struct: Generates view-state property template code through enums.
  • Render API: Framework provides a drawing API sufficient for most view drawing; when advanced capabilities are needed, get corresponding handle by backend for custom processing.