1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! A graphical user interface library. This crate exposes all of the built-in
//! functionality of Gooey, as well as types for building apps.
//!
//! ## Feature Flags
//!
//! This crate has several feature flags to control what features are enabled.
//! The default feature flags are `["frontend-kludgine", "frontend-browser", "fluent"]`.
//!
//! * `frontend-browser`: Enables the `frontends::browser` module, which is
//!   `gooey-browser` re-exported.
//! * `frontend-kludgine`: Enables the `frontends::rasterizer` module and the
//!   `frontends::renderers::kludgine` module. These are re-exports of
//!   `gooey-rasterizer` and `gooey-kludgine` respectively.
//! * `async`: Enables the `App::spawn()` function.
//! * `fluent`: Enables using [`fluent`](https://crates.io/crates/fluent) for
//!   localization.
//!
//! ## Top-level exports
//!
//! The `ActiveFrontend`, `main()`, and `main_with()` function will change types
//! based on the feature flags enabled as well as the target platform. Here is a
//! reference to understand what symbols to expect:
//!
//! | `target_arch = "wasm32"` | `frontend-kludgine` | `frontend-browser` | `ActiveFrontend`/`main()` |
//! | - | - | - | - |
//! | `false` | `false` | `false` | |
//! | `false` | `false` | `true`  | |
//! | `false` | `true`  | `false` | `Rasterizer<Kludgine>`/`kludgine_main` |
//! | `false` | `true`  | `true`  | `Rasterizer<Kludgine>`/`kludgine_main` |
//! | `true`  | `false` | `true`  | `WebSys`/`browser_main` |
//! | `true`  | `true`  | `true`  | `WebSys`/`browser_main` |

#![forbid(unsafe_code)]
#![warn(
    clippy::cargo,
    missing_docs,
    clippy::pedantic,
    future_incompatible,
    rust_2018_idioms
)]
#![allow(
    clippy::if_not_else,
    clippy::module_name_repetitions,
    clippy::multiple_crate_versions, // this is a mess due to winit dependencies and wgpu dependencies not lining up
)]
#![cfg_attr(doc, warn(rustdoc::all))]

/// Available [`Frontends`](gooey_core::Frontend).
pub mod frontends {
    #[cfg(feature = "frontend-browser")]
    #[doc(inline)]
    pub use gooey_browser as browser;
    #[cfg(feature = "gooey-rasterizer")]
    #[doc(inline)]
    pub use gooey_rasterizer as rasterizer;
    /// Available [`Renderers`](gooey_renderer::Renderer).
    pub mod renderers {
        #[cfg(all(feature = "frontend-kludgine", not(target_arch = "wasm32")))]
        #[doc(inline)]
        pub use gooey_kludgine as kludgine;
    }
}
use cfg_if::cfg_if;
#[doc(inline)]
pub use gooey_core as core;
#[cfg(feature = "fluent")]
#[doc(inline)]
pub use gooey_fluent as fluent;
#[doc(inline)]
pub use gooey_renderer as renderer;
#[doc(inline)]
pub use gooey_text as text;
#[doc(inline)]
pub use gooey_widgets as widgets;

#[cfg(all(feature = "frontend-kludgine", not(target_arch = "wasm32")))]
mod headless;
#[cfg(all(feature = "frontend-kludgine", not(target_arch = "wasm32")))]
pub use headless::{Headless, HeadlessError, Recorder};

#[cfg(all(feature = "frontend-kludgine", not(target_arch = "wasm32")))]
mod kludgine;
#[cfg(all(feature = "frontend-kludgine", not(target_arch = "wasm32")))]
pub use crate::kludgine::{kludgine_app, kludgine_main, kludgine_main_with, kludgine_run};

#[cfg(feature = "frontend-browser")]
mod browser;
#[cfg(feature = "frontend-browser")]
pub use browser::{browser_app, browser_main, browser_main_with, browser_run};

cfg_if! {
    if #[cfg(all(target_arch = "wasm32", feature = "frontend-browser"))] {
        pub use browser_main as main;
        pub use browser_main_with as main_with;
        pub use browser_app as app;
        pub use browser_run as run;
        /// The active frontend.
        pub type ActiveFrontend = gooey_browser::WebSys;
    } else if #[cfg(feature = "frontend-kludgine")] {
        pub use kludgine_main as main;
        pub use kludgine_main_with as main_with;
        pub use kludgine_app as app;
        pub use kludgine_run as run;
        /// The active frontend.
        pub type ActiveFrontend = gooey_rasterizer::Rasterizer<gooey_kludgine::Kludgine>;
    }
}

mod app;

pub use app::App;
/// Styles for applications.
pub mod style;