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