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