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//! - [State](self::_docs::state_management)
40//! - [Development Setup](self::_docs::development_setup)
41//!
42//! ### Learn
43//! - [Built-in Components](crate::components)
44//! - [Built-in Components Gallery](crate::components::gallery)
45//! - [i18n](freya_i18n)
46//! - [Animation](freya_animation::prelude::use_animation)
47//! - [Routing](freya_router)
48//! - [Clipboard](freya_clipboard)
49//! - [Icons](freya_icons)
50//! - [Material Design](freya_material_design)
51//! - [Plotters](freya_plotters_backend)
52//! - [Testing](freya_testing)
53//! - [WebView](freya_webview)
54//! - [Terminal](freya_terminal)
55//!
56//! ## Features flags
57//!
58//! - `all`: Enables all the features listed below
59//! - `router`: Reexport [freya_router] under [router]
60//! - `i18n`: Reexport [freya_i18n] under [i18n]
61//! - `remote-asset`: Enables support for **HTTP** asset sources for [ImageViewer](components::ImageViewer) and [GifViewer](components::GifViewer) components.
62//! - `tray`: Enables tray support using the [tray_icon] crate.
63//! - `sdk`: Reexport [freya_sdk] under [sdk].
64//! - `gif`: Enables the [GifViewer](components::GifViewer) component.
65//! - `plot`: Reexport of plotters under [plot].
66//! - `material-design`: Reexport [freya_material_design] under [material_design].
67//! - `calendar`: Enables the [Calendar](components::Calendar) component.
68//! - `icons`: Reexport of [freya_icons] under [icons].
69//! - `radio`: Reexport [freya_radio] under [radio].
70//! - `query`: Reexport [freya_query] under [query].
71//! - `markdown`: Enables the [MarkdownViewer](components::MarkdownViewer) component.
72//! - `webview`: Reexport [freya_webview] under [webview].
73//! - `titlebar`: Enables the [TitlebarButton](components::TitlebarButton) component.
74//! - `terminal`: Reexport [freya_terminal] under [terminal].
75//!
76//! ## Misc features
77//! - `devtools`: Enables devtools support.
78//! - `performance`: Enables the performance overlay plugin.
79//! - `vulkan`: Enables Vulkan rendering support.
80//! - `hotpath`: Enables Freya's internal usage of hotpath.
81
82pub mod prelude {
83    pub use freya_core::prelude::*;
84    pub use freya_edit::{
85        Clipboard,
86        ClipboardError,
87    };
88    pub use freya_winit::{
89        WindowDragExt,
90        WinitPlatformExt,
91        config::{
92            CloseDecision,
93            LaunchConfig,
94            WindowConfig,
95        },
96        renderer::RendererContext,
97    };
98
99    pub use crate::components::*;
100    pub fn launch(launch_config: LaunchConfig) {
101        #[cfg(feature = "devtools")]
102        let launch_config = launch_config.with_plugin(freya_devtools::DevtoolsPlugin::default());
103        #[cfg(feature = "performance")]
104        let launch_config = launch_config
105            .with_plugin(freya_performance_plugin::PerformanceOverlayPlugin::default());
106        freya_winit::launch(launch_config)
107    }
108
109    #[cfg_attr(feature = "docs", doc(cfg(feature = "router")))]
110    #[cfg(feature = "router")]
111    pub use freya_router;
112    pub use torin::{
113        alignment::Alignment,
114        content::Content,
115        direction::Direction,
116        gaps::Gaps,
117        geometry::{
118            Area,
119            CursorPoint,
120            Size2D,
121        },
122        position::Position,
123        size::Size,
124        visible_size::VisibleSize,
125    };
126}
127pub mod elements {
128    pub use freya_core::elements::*;
129}
130
131pub mod components {
132    #[cfg_attr(feature = "docs", doc(cfg(feature = "gif")))]
133    #[cfg(feature = "gif")]
134    pub use freya_components::gif_viewer::*;
135    #[cfg_attr(feature = "docs", doc(cfg(feature = "markdown")))]
136    #[cfg(feature = "markdown")]
137    pub use freya_components::markdown::*;
138    cfg_if::cfg_if! {
139        if #[cfg(feature = "router")] {
140            #[cfg_attr(feature = "docs", doc(cfg(feature = "router")))]
141            pub use freya_components::activable_route::*;
142            pub use freya_components::link::*;
143            pub use freya_components::native_router::*;
144            pub use freya_components::animated_router::*;
145        }
146    }
147    #[cfg_attr(feature = "docs", doc(cfg(feature = "remote-asset")))]
148    #[cfg(feature = "remote-asset")]
149    pub use freya_components::Uri;
150    #[cfg_attr(feature = "docs", doc(cfg(feature = "calendar")))]
151    #[cfg(feature = "calendar")]
152    pub use freya_components::calendar::*;
153    #[cfg(feature = "titlebar")]
154    pub use freya_components::titlebar::*;
155    pub use freya_components::{
156        accordion::*,
157        activable_route_context::*,
158        button::*,
159        canvas::*,
160        card::*,
161        checkbox::*,
162        chip::*,
163        color_picker::*,
164        context_menu::*,
165        cursor_area::*,
166        drag_drop::*,
167        draggable_canvas::*,
168        element_expansions::*,
169        floating_tab::*,
170        gallery,
171        get_theme,
172        icons::{
173            arrow::*,
174            tick::*,
175        },
176        image_viewer::*,
177        input::*,
178        loader::*,
179        menu::*,
180        overflowed_content::*,
181        popup::*,
182        portal::*,
183        progressbar::*,
184        radio_item::*,
185        resizable_container::*,
186        scrollviews::*,
187        segmented_button::*,
188        select::*,
189        selectable_text::*,
190        sidebar::*,
191        slider::*,
192        switch::*,
193        table::*,
194        theming::{
195            component_themes::*,
196            extensions::*,
197            hooks::*,
198            themes::*,
199        },
200        tile::*,
201        tooltip::*,
202    };
203}
204
205pub mod text_edit {
206    pub use freya_edit::*;
207}
208
209pub mod clipboard {
210    pub use freya_clipboard::prelude::*;
211}
212
213pub mod animation {
214    pub use freya_animation::prelude::*;
215}
216
217#[cfg_attr(feature = "docs", doc(cfg(feature = "plot")))]
218#[cfg(feature = "plot")]
219pub mod plot {
220    pub use freya_plotters_backend::*;
221    pub use plotters;
222}
223
224#[cfg_attr(feature = "docs", doc(cfg(feature = "router")))]
225#[cfg(feature = "router")]
226pub mod router {
227    pub use freya_router::prelude::*;
228}
229
230#[cfg_attr(feature = "docs", doc(cfg(feature = "i18n")))]
231#[cfg(feature = "i18n")]
232pub mod i18n {
233    pub use freya_i18n::prelude::*;
234}
235
236#[cfg_attr(feature = "docs", doc(cfg(feature = "engine")))]
237#[cfg(feature = "engine")]
238pub mod engine {
239    pub use freya_engine::*;
240}
241
242pub mod winit {
243    pub use freya_winit::winit::*;
244}
245
246pub mod helpers {
247    pub use freya_core::helpers::*;
248}
249
250#[cfg_attr(feature = "docs", doc(cfg(feature = "tray")))]
251#[cfg(feature = "tray")]
252pub mod tray {
253    pub use freya_winit::tray::*;
254}
255
256#[cfg_attr(feature = "docs", doc(cfg(feature = "sdk")))]
257#[cfg(feature = "sdk")]
258pub mod sdk {
259    pub use freya_sdk::prelude::*;
260}
261
262#[cfg_attr(feature = "docs", doc(cfg(feature = "material-design")))]
263#[cfg(feature = "material-design")]
264pub mod material_design {
265    pub use freya_material_design::prelude::*;
266}
267
268#[cfg_attr(feature = "docs", doc(cfg(feature = "icons")))]
269#[cfg(feature = "icons")]
270pub mod icons {
271    pub use freya_icons::*;
272}
273
274/// Reexport `freya-radio` when the `radio` feature is enabled.
275#[cfg(feature = "radio")]
276#[cfg_attr(feature = "docs", doc(cfg(feature = "radio")))]
277pub mod radio {
278    pub use freya_radio::prelude::*;
279}
280
281/// Reexport `freya-query` when the `query` feature is enabled.
282#[cfg(feature = "query")]
283#[cfg_attr(feature = "docs", doc(cfg(feature = "query")))]
284pub mod query {
285    pub use freya_query::prelude::*;
286}
287
288/// Reexport `freya-webview` when the `webview` feature is enabled.
289#[cfg(feature = "webview")]
290#[cfg_attr(feature = "docs", doc(cfg(feature = "webview")))]
291pub mod webview {
292    pub use freya_webview::prelude::*;
293}
294
295/// Reexport `freya-terminal` when the `terminal` feature is enabled.
296#[cfg(feature = "terminal")]
297#[cfg_attr(feature = "docs", doc(cfg(feature = "terminal")))]
298pub mod terminal {
299    pub use freya_terminal::prelude::*;
300}
301
302#[cfg(doc)]
303pub mod _docs;