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