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            macros::Preference,
201            themes::*,
202        },
203        tile::*,
204        tooltip::*,
205    };
206}
207
208pub mod text_edit {
209    pub use freya_edit::*;
210}
211
212pub mod clipboard {
213    pub use freya_clipboard::prelude::*;
214}
215
216pub mod animation {
217    pub use freya_animation::prelude::*;
218}
219
220#[cfg_attr(feature = "docs", doc(cfg(feature = "plot")))]
221#[cfg(feature = "plot")]
222pub mod plot {
223    pub use freya_plotters_backend::*;
224    pub use plotters;
225}
226
227#[cfg_attr(feature = "docs", doc(cfg(feature = "router")))]
228#[cfg(feature = "router")]
229pub mod router {
230    pub use freya_router::prelude::*;
231}
232
233#[cfg_attr(feature = "docs", doc(cfg(feature = "i18n")))]
234#[cfg(feature = "i18n")]
235pub mod i18n {
236    pub use freya_i18n::prelude::*;
237}
238
239#[cfg_attr(feature = "docs", doc(cfg(feature = "engine")))]
240#[cfg(feature = "engine")]
241pub mod engine {
242    pub use freya_engine::*;
243}
244
245pub mod winit {
246    pub use freya_winit::winit::*;
247}
248
249pub mod helpers {
250    pub use freya_core::helpers::*;
251}
252
253#[cfg_attr(feature = "docs", doc(cfg(feature = "tray")))]
254#[cfg(feature = "tray")]
255pub mod tray {
256    pub use freya_winit::tray::*;
257}
258
259#[cfg_attr(feature = "docs", doc(cfg(feature = "sdk")))]
260#[cfg(feature = "sdk")]
261pub mod sdk {
262    pub use freya_sdk::prelude::*;
263}
264
265#[cfg_attr(feature = "docs", doc(cfg(feature = "material-design")))]
266#[cfg(feature = "material-design")]
267pub mod material_design {
268    pub use freya_material_design::prelude::*;
269}
270
271#[cfg_attr(feature = "docs", doc(cfg(feature = "icons")))]
272#[cfg(feature = "icons")]
273pub mod icons {
274    pub use freya_icons::*;
275}
276
277/// Reexport `freya-radio` when the `radio` feature is enabled.
278#[cfg(feature = "radio")]
279#[cfg_attr(feature = "docs", doc(cfg(feature = "radio")))]
280pub mod radio {
281    pub use freya_radio::prelude::*;
282}
283
284/// Reexport `freya-query` when the `query` feature is enabled.
285#[cfg(feature = "query")]
286#[cfg_attr(feature = "docs", doc(cfg(feature = "query")))]
287pub mod query {
288    pub use freya_query::prelude::*;
289}
290
291/// Reexport `freya-webview` when the `webview` feature is enabled.
292#[cfg(feature = "webview")]
293#[cfg_attr(feature = "docs", doc(cfg(feature = "webview")))]
294pub mod webview {
295    pub use freya_webview::prelude::*;
296}
297
298/// Reexport `freya-terminal` when the `terminal` feature is enabled.
299#[cfg(feature = "terminal")]
300#[cfg_attr(feature = "docs", doc(cfg(feature = "terminal")))]
301pub mod terminal {
302    pub use freya_terminal::prelude::*;
303}
304
305/// Reexport `freya-code-editor` when the `code-editor` feature is enabled.
306#[cfg(feature = "code-editor")]
307#[cfg_attr(feature = "docs", doc(cfg(feature = "code-editor")))]
308pub mod code_editor {
309    pub use freya_code_editor::prelude::*;
310}
311
312#[cfg(doc)]
313pub mod _docs;