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    pub use torin::{
109        alignment::Alignment,
110        content::Content,
111        direction::Direction,
112        gaps::Gaps,
113        geometry::{
114            Area,
115            CursorPoint,
116            Size2D,
117        },
118        position::Position,
119        size::Size,
120    };
121}
122pub mod elements {
123    pub use freya_core::elements::*;
124}
125
126pub mod components {
127    #[cfg_attr(feature = "docs", doc(cfg(feature = "gif")))]
128    #[cfg(feature = "gif")]
129    pub use freya_components::gif_viewer::*;
130    #[cfg_attr(feature = "docs", doc(cfg(feature = "markdown")))]
131    #[cfg(feature = "markdown")]
132    pub use freya_components::markdown::*;
133    cfg_if::cfg_if! {
134        if #[cfg(feature = "router")] {
135            #[cfg_attr(feature = "docs", doc(cfg(feature = "router")))]
136            pub use freya_components::activable_route::*;
137            pub use freya_components::link::*;
138            pub use freya_components::native_router::*;
139            pub use freya_components::animated_router::*;
140        }
141    }
142    #[cfg_attr(feature = "docs", doc(cfg(feature = "remote-asset")))]
143    #[cfg(feature = "remote-asset")]
144    pub use freya_components::Uri;
145    #[cfg_attr(feature = "docs", doc(cfg(feature = "calendar")))]
146    #[cfg(feature = "calendar")]
147    pub use freya_components::calendar::*;
148    #[cfg_attr(feature = "docs", doc(cfg(feature = "plot")))]
149    #[cfg(feature = "plot")]
150    pub use freya_components::plot::*;
151    #[cfg(feature = "titlebar")]
152    pub use freya_components::titlebar::*;
153    pub use freya_components::{
154        accordion::*,
155        activable_route_context::*,
156        button::*,
157        card::*,
158        checkbox::*,
159        chip::*,
160        color_picker::*,
161        context_menu::*,
162        cursor_area::*,
163        drag_drop::*,
164        draggable_canvas::*,
165        element_expansions::*,
166        floating_tab::*,
167        gallery,
168        get_theme,
169        icons::{
170            arrow::*,
171            tick::*,
172        },
173        image_viewer::*,
174        input::*,
175        loader::*,
176        menu::*,
177        overflowed_content::*,
178        popup::*,
179        portal::*,
180        progressbar::*,
181        radio_item::*,
182        resizable_container::*,
183        scrollviews::*,
184        segmented_button::*,
185        select::*,
186        selectable_text::*,
187        sidebar::*,
188        slider::*,
189        switch::*,
190        table::*,
191        theming::{
192            component_themes::*,
193            extensions::*,
194            hooks::*,
195            themes::*,
196        },
197        tile::*,
198        tooltip::*,
199    };
200}
201
202pub mod text_edit {
203    pub use freya_edit::*;
204}
205
206pub mod clipboard {
207    pub use freya_clipboard::prelude::*;
208}
209
210pub mod animation {
211    pub use freya_animation::prelude::*;
212}
213
214#[cfg_attr(feature = "docs", doc(cfg(feature = "router")))]
215#[cfg(feature = "router")]
216pub mod router {
217    pub use freya_router::*;
218}
219
220#[cfg_attr(feature = "docs", doc(cfg(feature = "i18n")))]
221#[cfg(feature = "i18n")]
222pub mod i18n {
223    pub use freya_i18n::*;
224}
225
226#[cfg_attr(feature = "docs", doc(cfg(feature = "engine")))]
227#[cfg(feature = "engine")]
228pub mod engine {
229    pub use freya_engine::*;
230}
231
232pub mod winit {
233    pub use freya_winit::winit::*;
234}
235
236pub mod helpers {
237    pub use freya_core::helpers::*;
238}
239
240#[cfg_attr(feature = "docs", doc(cfg(feature = "tray")))]
241#[cfg(feature = "tray")]
242pub mod tray {
243    pub use freya_winit::tray::*;
244}
245
246#[cfg_attr(feature = "docs", doc(cfg(feature = "sdk")))]
247#[cfg(feature = "sdk")]
248pub mod sdk {
249    pub use freya_sdk::*;
250}
251
252#[cfg_attr(feature = "docs", doc(cfg(feature = "material-design")))]
253#[cfg(feature = "material-design")]
254pub mod material_design {
255    pub use freya_material_design::prelude::*;
256}
257
258#[cfg_attr(feature = "docs", doc(cfg(feature = "icons")))]
259#[cfg(feature = "icons")]
260pub mod icons {
261    pub use freya_icons::*;
262}
263
264/// Reexport `freya-radio` when the `radio` feature is enabled.
265#[cfg(feature = "radio")]
266#[cfg_attr(feature = "docs", doc(cfg(feature = "radio")))]
267pub mod radio {
268    pub use freya_radio::prelude::*;
269}
270
271/// Reexport `freya-webview` when the `webview` feature is enabled.
272#[cfg(feature = "webview")]
273#[cfg_attr(feature = "docs", doc(cfg(feature = "webview")))]
274pub mod webview {
275    pub use freya_webview::*;
276}
277
278/// Reexport `freya-terminal` when the `terminal` feature is enabled.
279#[cfg(feature = "terminal")]
280#[cfg_attr(feature = "docs", doc(cfg(feature = "terminal")))]
281pub mod terminal {
282    pub use freya_terminal::prelude::*;
283}
284
285#[cfg(doc)]
286pub mod _docs;