freya/
lib.rs

1#![doc(
2    html_logo_url = "https://freyaui.dev/logo.svg",
3    html_favicon_url = "https://freyaui.dev/logo.svg"
4)]
5#![cfg_attr(feature = "docs", feature(doc_cfg))]
6//! # Freya
7//!
8//! **Freya** is a declarative, cross-platform GUI 🦀 Rust library, powered by 🎨 [Skia](https://skia.org/).
9//!
10//! #### Example
11//!
12//! ```rust, no_run
13//! # use freya::prelude::*;
14//! fn main() {
15//!     // *Start* your app with a window and its root component
16//!     launch(LaunchConfig::new().with_window(WindowConfig::new(app)))
17//! }
18//!
19//! fn app() -> impl IntoElement {
20//!     // Define a reactive *state*
21//!     let mut count = use_state(|| 0);
22//!
23//!     // Declare the *UI*
24//!     rect()
25//!         .width(Size::fill())
26//!         .height(Size::fill())
27//!         .background((35, 35, 35))
28//!         .color(Color::WHITE)
29//!         .padding(Gaps::new_all(12.))
30//!         .on_mouse_up(move |_| *count.write() += 1)
31//!         .child(format!("Click to increase -> {}", count.read()))
32//! }
33//! ```
34//!
35//! ### Basics
36//! - [UI and Components](self::_docs::ui_and_components)
37//! - [Elements](self::elements)
38//! - [Hooks](self::_docs::hooks)
39//! - [Development Setup](self::_docs::development_setup)
40//!
41//! ### Learn
42//! - [Built-in Components](crate::components)
43//! - [Built-in Components Gallery](crate::components::gallery)
44//! - [i18n](freya_i18n)
45//! - [Animation](freya_animation::prelude::use_animation)
46//! - [Routing](freya_router)
47//! - [Clipboard](freya_clipboard)
48//! - [Icons](freya_icons)
49//! - [Material Design](freya_material_design)
50//! - [Plotters](freya_plotters_backend)
51//! - [Testing](freya_testing)
52//!
53//! ## Features flags
54//!
55//! - `all`: Enables all the features listed below
56//! - `router`: Reexport [freya_router] under [router]
57//! - `i18n`: Reexport [freya_i18n] under [i18n]
58//! - `remote-asset`: Enables support for **HTTP** asset sources for [ImageViewer](components::ImageViewer) and [GifViewer](components::GifViewer) components.
59//! - `tray`: Enables tray support using the [tray_icon] crate.
60//! - `sdk`: Reexport [freya_sdk] under [sdk].
61//! - `gif`: Enables the [GifViewer](components::GifViewer) component.
62//! - `plot`: Enables the [plot](prelude::plot) element.
63//! - `material-design`: Reexport [freya_material_design] under [material_design].
64//! - `calendar`: Enables the [Calendar](components::Calendar) component.
65//! - `icons`: Reexport of [freya_icons] under [icons].
66//! - `radio`: Reexport [freya_radio] under [radio].
67//! - `markdown`: Enables the [MarkdownViewer](components::MarkdownViewer) component.
68//!
69//! ## Misc features
70//! - `devtools`: Enables devtools support.
71//! - `performance`: Enables the performance overlay plugin.
72//! - `vulkan`: Enables Vulkan rendering support.
73//! - `hotpath`: Enables Freya's internal usage of hotpath.
74
75pub mod prelude {
76    pub use freya_core::prelude::*;
77    pub use freya_edit::{
78        Clipboard,
79        ClipboardError,
80    };
81    pub use freya_winit::{
82        WinitPlatformExt,
83        config::{
84            LaunchConfig,
85            WindowConfig,
86        },
87        renderer::RendererContext,
88    };
89
90    pub use crate::components::*;
91    pub fn launch(launch_config: LaunchConfig) {
92        #[cfg(feature = "devtools")]
93        let launch_config = launch_config.with_plugin(freya_devtools::DevtoolsPlugin::default());
94        #[cfg(feature = "performance")]
95        let launch_config = launch_config
96            .with_plugin(freya_performance_plugin::PerformanceOverlayPlugin::default());
97        freya_winit::launch(launch_config)
98    }
99
100    pub use torin::{
101        alignment::Alignment,
102        content::Content,
103        direction::Direction,
104        gaps::Gaps,
105        geometry::{
106            Area,
107            CursorPoint,
108            Size2D,
109        },
110        position::Position,
111        size::Size,
112    };
113}
114pub mod elements {
115    pub use freya_core::elements::*;
116}
117
118pub mod components {
119    #[cfg_attr(feature = "docs", doc(cfg(feature = "gif")))]
120    #[cfg(feature = "gif")]
121    pub use freya_components::gif_viewer::*;
122    #[cfg_attr(feature = "docs", doc(cfg(feature = "markdown")))]
123    #[cfg(feature = "markdown")]
124    pub use freya_components::markdown::*;
125    cfg_if::cfg_if! {
126        if #[cfg(feature = "router")] {
127            #[cfg_attr(feature = "docs", doc(cfg(feature = "router")))]
128            pub use freya_components::activable_route::*;
129            pub use freya_components::link::*;
130            pub use freya_components::native_router::*;
131            pub use freya_components::animated_router::*;
132        }
133    }
134    #[cfg_attr(feature = "docs", doc(cfg(feature = "remote-asset")))]
135    #[cfg(feature = "remote-asset")]
136    pub use freya_components::Uri;
137    #[cfg_attr(feature = "docs", doc(cfg(feature = "calendar")))]
138    #[cfg(feature = "calendar")]
139    pub use freya_components::calendar::*;
140    #[cfg_attr(feature = "docs", doc(cfg(feature = "plot")))]
141    #[cfg(feature = "plot")]
142    pub use freya_components::plot::*;
143    pub use freya_components::{
144        accordion::*,
145        activable_route_context::*,
146        button::*,
147        checkbox::*,
148        chip::*,
149        color_picker::*,
150        context_menu::*,
151        cursor_area::*,
152        drag_drop::*,
153        draggable_canvas::*,
154        element_expansions::*,
155        floating_tab::*,
156        gallery,
157        get_theme,
158        icons::{
159            arrow::*,
160            tick::*,
161        },
162        image_viewer::*,
163        input::*,
164        loader::*,
165        menu::*,
166        overflowed_content::*,
167        popup::*,
168        portal::*,
169        progressbar::*,
170        radio_item::*,
171        resizable_container::*,
172        scrollviews::*,
173        segmented_button::*,
174        select::*,
175        selectable_text::*,
176        sidebar::*,
177        slider::*,
178        switch::*,
179        table::*,
180        theming::{
181            component_themes::*,
182            extensions::*,
183            hooks::*,
184            themes::*,
185        },
186        tile::*,
187        tooltip::*,
188    };
189}
190
191pub mod text_edit {
192    pub use freya_edit::*;
193}
194
195pub mod clipboard {
196    pub use freya_clipboard::prelude::*;
197}
198
199pub mod animation {
200    pub use freya_animation::prelude::*;
201}
202
203#[cfg_attr(feature = "docs", doc(cfg(feature = "router")))]
204#[cfg(feature = "router")]
205pub mod router {
206    pub use freya_router::*;
207}
208
209#[cfg_attr(feature = "docs", doc(cfg(feature = "i18n")))]
210#[cfg(feature = "i18n")]
211pub mod i18n {
212    pub use freya_i18n::*;
213}
214
215#[cfg_attr(feature = "docs", doc(cfg(feature = "engine")))]
216#[cfg(feature = "engine")]
217pub mod engine {
218    pub use freya_engine::*;
219}
220
221pub mod winit {
222    pub use freya_winit::winit::*;
223}
224
225pub mod helpers {
226    pub use freya_core::helpers::*;
227}
228
229#[cfg_attr(feature = "docs", doc(cfg(feature = "tray")))]
230#[cfg(feature = "tray")]
231pub mod tray {
232    pub use freya_winit::tray::*;
233}
234
235#[cfg_attr(feature = "docs", doc(cfg(feature = "sdk")))]
236#[cfg(feature = "sdk")]
237pub mod sdk {
238    pub use freya_sdk::*;
239}
240
241#[cfg_attr(feature = "docs", doc(cfg(feature = "material-design")))]
242#[cfg(feature = "material-design")]
243pub mod material_design {
244    pub use freya_material_design::prelude::*;
245}
246
247#[cfg_attr(feature = "docs", doc(cfg(feature = "icons")))]
248#[cfg(feature = "icons")]
249pub mod icons {
250    pub use freya_icons::*;
251}
252
253/// Reexport `freya-radio` when the `radio` feature is enabled.
254#[cfg(feature = "radio")]
255#[cfg_attr(feature = "docs", doc(cfg(feature = "radio")))]
256pub mod radio {
257    pub use freya_radio::prelude::*;
258}
259
260#[cfg(doc)]
261pub mod _docs;