freya 0.4.0-rc.17

Cross-platform and non-web GUI Library powered by Skia.
Documentation
#![doc(
    html_logo_url = "https://freyaui.dev/logo.svg",
    html_favicon_url = "https://freyaui.dev/logo.svg"
)]
#![cfg_attr(feature = "docs", feature(doc_cfg))]
//! # Freya
//!
//! **Freya** is a declarative, cross-platform GUI 🦀 Rust library, powered by 🎨 [Skia](https://skia.org/).
//!
//! #### Example
//!
//! ```rust, no_run
//! # use freya::prelude::*;
//! fn main() {
//!     // *Start* your app with a window and its root component
//!     launch(LaunchConfig::new().with_window(WindowConfig::new(app)))
//! }
//!
//! fn app() -> impl IntoElement {
//!     // Define a reactive *state*
//!     let mut count = use_state(|| 0);
//!
//!     // Declare the *UI*
//!     rect()
//!         .width(Size::fill())
//!         .height(Size::fill())
//!         .background((35, 35, 35))
//!         .color(Color::WHITE)
//!         .padding(Gaps::new_all(12.))
//!         .on_mouse_up(move |_| *count.write() += 1)
//!         .child(format!("Click to increase -> {}", count.read()))
//! }
//! ```
//!
//! ### Basics
//! - [UI and Components](self::_docs::ui_and_components)
//! - [Elements](self::elements)
//! - [Hooks](self::_docs::hooks)
//! - [State](self::_docs::state_management)
//! - [Remote Data](self::_docs::remote_data)
//! - [Layers](self::_docs::layers)
//! - [Platforms](self::_docs::platforms)
//! - [Development Setup](self::_docs::development_setup)
//!
//! ### Learn
//! - [Built-in Components](crate::components)
//! - [Built-in Components Gallery](crate::components::gallery)
//! - [i18n](freya_i18n)
//! - [Animation](freya_animation)
//! - [Routing](freya_router)
//! - [Clipboard](freya_clipboard)
//! - [Icons](freya_icons)
//! - [Material Design](freya_material_design)
//! - [Plotters](freya_plotters_backend)
//! - [Testing](freya_testing)
//! - [WebView](freya_webview)
//! - [Terminal](freya_terminal)
//! - [Tokio Integration](self::_docs::tokio_integration)
//! - [Devtools](self::_docs::devtools)
//!
//! ## Features flags
//!
//! - `all`: Enables all the features listed below
//! - `router`: Reexport [freya_router] under [router]
//! - `i18n`: Reexport [freya_i18n] under [i18n]
//! - `remote-asset`: Enables support for **HTTP** asset sources for [ImageViewer](components::ImageViewer) and [GifViewer](components::GifViewer) components.
//! - `tray`: Enables tray support using the [tray_icon] crate.
//! - `sdk`: Reexport [freya_sdk] under [sdk].
//! - `gif`: Enables the [GifViewer](components::GifViewer) component.
//! - `plot`: Reexport of plotters under [plot].
//! - `material-design`: Reexport [freya_material_design] under [material_design].
//! - `calendar`: Enables the [Calendar](components::Calendar) component.
//! - `icons`: Reexport of [freya_icons] under [icons].
//! - `radio`: Reexport [freya_radio] under [radio].
//! - `query`: Reexport [freya_query] under [query].
//! - `markdown`: Enables the [MarkdownViewer](components::MarkdownViewer) component.
//! - `webview`: Reexport [freya_webview] under [webview].
//! - `titlebar`: Enables the [TitlebarButton](components::TitlebarButton) component.
//! - `terminal`: Reexport [freya_terminal] under [terminal].
//! - `code-editor`: Reexport [freya_code_editor] under [code_editor].
//!
//! ## Misc features
//! - `devtools`: Enables devtools support.
//! - `performance`: Reexports the performance overlay plugin. The plugin is auto-added in debug builds.
//! - `vulkan`: Enables Vulkan rendering support.
//! - `hotpath`: Enables Freya's internal usage of hotpath.

pub mod prelude {
    pub use freya_core::prelude::*;
    pub use freya_edit::{
        Clipboard,
        ClipboardError,
    };
    pub use freya_winit::{
        WindowDragExt,
        WinitPlatformExt,
        config::{
            CloseDecision,
            LaunchConfig,
            WindowConfig,
        },
        renderer::{
            NativeEvent,
            RendererContext,
        },
    };

    pub use crate::components::*;

    pub fn launch(launch_config: LaunchConfig) {
        #[cfg(feature = "devtools")]
        let launch_config = launch_config.with_plugin(freya_devtools::DevtoolsPlugin::default());
        #[cfg(debug_assertions)]
        let launch_config = launch_config
            .with_plugin(freya_performance_plugin::PerformanceOverlayPlugin::default());
        freya_winit::launch(launch_config)
    }

    #[cfg_attr(feature = "docs", doc(cfg(feature = "router")))]
    #[cfg(feature = "router")]
    pub use freya_router;
    pub use torin::{
        alignment::Alignment,
        content::Content,
        direction::Direction,
        gaps::Gaps,
        geometry::{
            Area,
            CursorPoint,
            Size2D,
        },
        position::Position,
        size::Size,
        visible_size::VisibleSize,
    };
}
pub mod elements {
    pub use freya_core::elements::*;
}

pub mod components {
    #[cfg_attr(feature = "docs", doc(cfg(feature = "gif")))]
    #[cfg(feature = "gif")]
    pub use freya_components::gif_viewer::*;
    #[cfg_attr(feature = "docs", doc(cfg(feature = "markdown")))]
    #[cfg(feature = "markdown")]
    pub use freya_components::markdown::*;
    cfg_if::cfg_if! {
        if #[cfg(feature = "router")] {
            #[cfg_attr(feature = "docs", doc(cfg(feature = "router")))]
            pub use freya_components::activable_route::*;
            pub use freya_components::link::*;
            pub use freya_components::native_router::*;
            pub use freya_components::animated_router::*;
        }
    }
    #[cfg_attr(feature = "docs", doc(cfg(feature = "remote-asset")))]
    #[cfg(feature = "remote-asset")]
    pub use freya_components::Uri;
    #[cfg_attr(feature = "docs", doc(cfg(feature = "calendar")))]
    #[cfg(feature = "calendar")]
    pub use freya_components::calendar::*;
    #[cfg(feature = "titlebar")]
    pub use freya_components::titlebar::*;
    pub use freya_components::{
        accordion::*,
        activable_route_context::*,
        attached::*,
        button::*,
        canvas::*,
        card::*,
        checkbox::*,
        chip::*,
        color_picker::*,
        context_menu::*,
        cursor_area::*,
        define_theme,
        drag_drop::*,
        draggable_canvas::*,
        element_expansions::*,
        floating_tab::*,
        gallery,
        get_theme,
        icons::{
            arrow::*,
            tick::*,
        },
        image_viewer::*,
        input::*,
        loader::*,
        menu::*,
        overflowed_content::*,
        popup::*,
        portal::*,
        progressbar::*,
        radio_item::*,
        resizable_container::*,
        scrollviews::*,
        segmented_button::*,
        select::*,
        selectable_text::*,
        sidebar::*,
        slider::*,
        switch::*,
        table::*,
        theming::{
            component_themes::{
                ColorsSheet,
                Theme,
            },
            extensions::*,
            hooks::*,
            macros::Preference,
            themes::*,
        },
        tile::*,
        tooltip::*,
    };
}

pub mod text_edit {
    pub use freya_edit::*;
}

pub mod clipboard {
    pub use freya_clipboard::prelude::*;
}

pub mod animation {
    pub use freya_animation::prelude::*;
}

#[cfg_attr(feature = "docs", doc(cfg(feature = "plot")))]
#[cfg(feature = "plot")]
pub mod plot {
    pub use freya_plotters_backend::*;
    pub use plotters;
}

#[cfg_attr(feature = "docs", doc(cfg(feature = "router")))]
#[cfg(feature = "router")]
pub mod router {
    pub use freya_router::prelude::*;
}

#[cfg_attr(feature = "docs", doc(cfg(feature = "i18n")))]
#[cfg(feature = "i18n")]
pub mod i18n {
    pub use freya_i18n::prelude::*;
}

#[cfg_attr(feature = "docs", doc(cfg(feature = "engine")))]
#[cfg(feature = "engine")]
pub mod engine {
    pub use freya_engine::*;
}

pub mod winit {
    pub use freya_winit::winit::*;
}

pub mod helpers {
    pub use freya_core::helpers::*;
}

#[cfg_attr(feature = "docs", doc(cfg(feature = "tray")))]
#[cfg(feature = "tray")]
pub mod tray {
    pub use freya_winit::tray::*;
}

#[cfg_attr(feature = "docs", doc(cfg(feature = "sdk")))]
#[cfg(feature = "sdk")]
pub mod sdk {
    pub use freya_sdk::prelude::*;
}

#[cfg_attr(feature = "docs", doc(cfg(feature = "material-design")))]
#[cfg(feature = "material-design")]
pub mod material_design {
    pub use freya_material_design::prelude::*;
}

#[cfg_attr(feature = "docs", doc(cfg(feature = "icons")))]
#[cfg(feature = "icons")]
pub mod icons {
    pub use freya_icons::*;
}

/// Reexport `freya-radio` when the `radio` feature is enabled.
#[cfg(feature = "radio")]
#[cfg_attr(feature = "docs", doc(cfg(feature = "radio")))]
pub mod radio {
    pub use freya_radio::prelude::*;
}

/// Reexport `freya-query` when the `query` feature is enabled.
#[cfg(feature = "query")]
#[cfg_attr(feature = "docs", doc(cfg(feature = "query")))]
pub mod query {
    pub use freya_query::prelude::*;
}

/// Reexport `freya-webview` when the `webview` feature is enabled.
#[cfg(feature = "webview")]
#[cfg_attr(feature = "docs", doc(cfg(feature = "webview")))]
pub mod webview {
    pub use freya_webview::prelude::*;
}

/// Reexport `freya-terminal` when the `terminal` feature is enabled.
#[cfg(feature = "terminal")]
#[cfg_attr(feature = "docs", doc(cfg(feature = "terminal")))]
pub mod terminal {
    pub use freya_terminal::prelude::*;
}

/// Reexport `freya-code-editor` when the `code-editor` feature is enabled.
#[cfg(feature = "code-editor")]
#[cfg_attr(feature = "docs", doc(cfg(feature = "code-editor")))]
pub mod code_editor {
    pub use freya_code_editor::prelude::*;
}

#[cfg(feature = "performance")]
#[cfg_attr(feature = "docs", doc(cfg(feature = "performance")))]
pub mod performance {
    pub use freya_performance_plugin::*;
}

#[cfg(target_os = "android")]
pub mod android {
    pub use freya_android::*;
}

#[cfg(doc)]
pub mod _docs;