# Copyright © SixtyFPS GmbH <info@slint.dev>
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial

[package]
name = "slint"
description = "GUI toolkit to efficiently develop fluid graphical user interfaces for embedded devices and desktop applications"
authors.workspace = true
documentation.workspace = true
edition.workspace = true
homepage = "https://slint.rs"
keywords.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true
categories = ["gui", "rendering::engine", "no-std"]

[lib]
path = "lib.rs"

[features]

default = [
  "std",
  "backend-winit",
  "renderer-femtovg",
  "renderer-software",
  "backend-qt",
  "accessibility",
  "compat-1-2",
]

## Mandatory feature:
## This feature is required to keep the compatibility with Slint 1.2
## Newer patch version may put current functionality behind a new feature
## that would be enabled by default only if this feature was added.
## [More info in this blog post](https://slint.dev/blog/rust-adding-default-cargo-feature.html)
"compat-1-2" = []
"compat-1-0" = ["compat-1-2", "renderer-software"]

## Enable use of the Rust standard library.
std = ["i-slint-core/std"]

## Enable the translations using [gettext](https://www.gnu.org/software/gettext/gettext)
##
## the `@tr(...)` code from .slint files will be transformed into call to `dgettext`
## with the crate name as domain name
##
## translations must be enabled with the [`init_translations!`] macro
gettext = ["i-slint-core/gettext-rs"]

## This feature enables floating point arithmetic emulation using the [libm](https://crates.io/crates/libm) crate. Use this
## in MCU environments where the processor does not support floating point arithmetic.
libm = ["i-slint-core/libm"]

## If enabled, calls of `debug()` in `.slint` files use to the [`log::debug!()`] macro
## of the [log](https://crates.io/crates/log) crate instead of just `println!()`.
log = ["dep:log"]

## Implement the `serde::Serialize` and `serde::Deserialize` for some of the base types
## such as `SharedString` and `SharedVector`.
serde = ["i-slint-core/serde"]

## This feature enables the software renderer to pick up fonts from the operating system for text rendering.
software-renderer-systemfonts = ["renderer-software", "i-slint-core/software-renderer-systemfonts"]

## Slint uses internally some `thread_local` state.
##
## When the `std` feature is enabled, Slint can use [`std::thread_local!`], but when in a `#![no_std]`
## environment, we need a replacement. Using this feature, Slint will just use static variable
## disregarding Rust's Send and Sync safety
##
## **Safety** : You must ensure that there is only one single thread that call into the Slint API
unsafe-single-threaded = ["i-slint-core/unsafe-single-threaded"]

## Enable integration with operating system provided accessibility APIs
##
## Enabling this feature will try to expose the tree of UI elements to OS provided accessibility
## APIs to support screen readers and other assistive technologies.
accessibility = ["i-slint-backend-selector/accessibility"]

#! ### Backends

#! Slint needs a backend that will act as liaison between Slint and the OS.
#! By default, Slint will use the Qt backend, if Qt is installed, otherwise, it
#! will use [Winit](https://crates.io/crates/winit) with [FemtoVG](https://crates.io/crates/femtovg).
#! Both backends are compiled in. If you want to not compile one of these you need
#! to disable the default feature and re-enable one backend. It is also possible
#! to use Slint without backend if you provide the platform abstraction yourself
#! with [`platform::set_platform()`].
#!
#! If you enable the Winit backend, you need to also include a renderer.
#! `renderer-femtovg` is the only stable renderer, the other ones are experimental
#!
#! It is also possible to select the backend and renderer at runtime when several
#! are enabled, using the `SLINT_BACKEND`  environment variable.
#!  * `SLINT_BACKEND=Qt` selects the Qt backend
#!  * `SLINT_BACKEND=winit` selects the winit backend
#!  * `SLINT_BACKEND=winit-femtovg` selects the winit backend with the FemtoVG renderer
#!  * `SLINT_BACKEND=winit-skia` selects the winit backend with the skia renderer
#!  * `SLINT_BACKEND=winit-software` selects the winit backend with the software renderer
#!
#! If the selected backend is not available, the default will be used.
#!
#! Here are the cargo features controlling the backend:

## The Qt backend feature uses Qt for the windowing system integration and rendering.
## This backend also provides the `native` style.
## It requires Qt 5.15 or later to be installed. If Qt is not installed, the
## backend will not be operational
backend-qt = ["i-slint-backend-selector/i-slint-backend-qt", "std"]

## The [winit](https://crates.io/crates/log) crate is used for the event loop and windowing system integration.
## It supports Windows, macOS, web browsers, X11 and Wayland. X11 and wayland are only available when
## compiling for Linux or other Unix-like operating systems. With this feature, both X11 and Wayland are supported.
## For a smaller build, omit this feature and select one of the other specific `backend-winit-XX` features.
backend-winit = ["i-slint-backend-selector/backend-winit", "std"]

## Simliar to `backend-winit` this enables the winit based event loop but only
## with support for the X Window System on Unix.
backend-winit-x11 = ["i-slint-backend-selector/backend-winit-x11", "std"]

## Simliar to `backend-winit` this enables the winit based event loop but only
## with support for the Wayland window system on Unix.
backend-winit-wayland = ["i-slint-backend-selector/backend-winit-wayland", "std"]

# deprecated aliases
renderer-winit-femtovg = ["renderer-femtovg"]
renderer-winit-skia = ["renderer-skia"]
renderer-winit-skia-opengl= ["renderer-skia-opengl"]
renderer-winit-skia-vulkan= ["renderer-skia-vulkan"]
renderer-winit-software = ["renderer-software"]

## Render using the [FemtoVG](https://crates.io/crates/femtovg) crate.
renderer-femtovg = ["i-slint-backend-selector/renderer-femtovg", "dep:i-slint-renderer-femtovg", "std"]

## Render using [Skia](https://skia.org/).
renderer-skia = ["i-slint-backend-selector/renderer-skia", "std"]

## Same as `renderer-skia`, but Skia will always use OpenGL.
renderer-skia-opengl = ["i-slint-backend-selector/renderer-skia-opengl", "std"]

## Same as `renderer-skia`, but Skia will always use Vulkan.
renderer-skia-vulkan = ["i-slint-backend-selector/renderer-skia-vulkan", "std"]

## Render using the software renderer.
renderer-software = ["i-slint-backend-selector/renderer-software", "i-slint-core/software-renderer"]

## KMS with Vulkan or EGL and libinput on Linux are used to render the application in full screen mode, without any
## windowing system. (Experimental)
backend-linuxkms = ["i-slint-backend-selector/backend-linuxkms", "std"]

[dependencies]
i-slint-core = { workspace = true }
slint-macros = { workspace = true, features = ["default"] }
i-slint-backend-selector = { workspace = true, features = ["default"] }

const-field-offset = { version = "0.1.2", path = "../../../helper_crates/const-field-offset" }
document-features = { version = "0.2.0", optional = true }
vtable = { version = "0.1.6", path = "../../../helper_crates/vtable" }

once_cell = { version = "1.5", default-features = false, features = ["alloc"] }
pin-weak = { version = "1.1", default-features = false }
num-traits = { version = "0.2", default-features = false }

log = { version = "0.4.17", optional = true }

[target.'cfg(not(target_os = "android"))'.dependencies]
# FemtoVG is disabled on android because it doesn't compile without setting RUST_FONTCONFIG_DLOPEN=on
# end even then wouldn't work because it can't load fonts
i-slint-renderer-femtovg = { workspace = true, optional = true }

[dev-dependencies]
slint-build = { path = "../build" }
i-slint-backend-testing = { path = "../../../internal/backends/testing" }
serde_json = "1.0.96"
serde = { version = "1.0.163", features = ["derive"] }

[package.metadata.docs.rs]
rustdoc-args = [
  # "--html-in-header",
  # "docs/resources/slint-docs-preview.html",
  "--html-in-header",
  "docs/resources/slint-docs-highlight.html",
]
features = ["document-features", "log", "gettext", "renderer-software", "renderer-femtovg"]
