i_slint_common/lib.rs
1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
4#![doc = include_str!("README.md")]
5#![doc(html_logo_url = "https://slint.dev/logo/slint-logo-square-light.svg")]
6#![cfg_attr(not(feature = "shared-fontdb"), no_std)]
7
8pub mod builtin_structs;
9pub mod enums;
10pub mod key_codes;
11
12#[cfg(feature = "shared-fontdb")]
13pub mod sharedfontdb;
14
15/// Detect the native style depending on the platform
16pub fn get_native_style(has_qt: bool, target: &str) -> &'static str {
17 // NOTE: duplicated in api/cpp/CMakeLists.txt
18 if target.contains("android") {
19 "material"
20 } else if target.contains("windows") {
21 "fluent"
22 } else if target.contains("apple") {
23 "cupertino"
24 } else if target.contains("wasm") {
25 "fluent"
26 } else if target.contains("linux") | target.contains("bsd") {
27 if has_qt {
28 "qt"
29 } else {
30 "fluent"
31 }
32 } else if cfg!(target_os = "android") {
33 "material"
34 } else if cfg!(target_os = "windows") {
35 "fluent"
36 } else if cfg!(target_os = "macos") {
37 "cupertino"
38 } else if cfg!(target_family = "wasm") {
39 "fluent"
40 } else if has_qt {
41 "qt"
42 } else {
43 "fluent"
44 }
45}
46
47/// MenuItem with this title are actually MenuSeparator
48///
49/// Use a private unicode character so we are sure it is not used in the user's code
50pub const MENU_SEPARATOR_PLACEHOLDER_TITLE: &str = "\u{E001}⸺";