druid_shell/
lib.rs

1// Copyright 2018 The Druid Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Platform abstraction for Druid toolkit.
16//!
17//! `druid-shell` is an abstraction around a given platform UI & application
18//! framework. It provides common types, which then defer to a platform-defined
19//! implementation.
20//!
21//! # Env
22//!
23//! For testing and debugging, `druid-shell` can change its behavior based on environment
24//! variables. Here is a list of environment variables that `druid-shell` supports:
25//!
26//! - `DRUID_SHELL_DISABLE_X11_PRESENT`: if this is set and `druid-shell` is using the `x11`
27//! backend, it will avoid using the Present extension.
28
29#![warn(rustdoc::broken_intra_doc_links)]
30#![allow(clippy::new_without_default)]
31#![deny(clippy::trivially_copy_pass_by_ref)]
32#![doc(
33    html_logo_url = "https://raw.githubusercontent.com/linebender/druid/screenshots/images/doc_logo.png"
34)]
35// This is overeager right now, see https://github.com/rust-lang/rust-clippy/issues/8494
36#![allow(clippy::iter_overeager_cloned)]
37
38// Rename `gtk_rs` back to `gtk`.
39// This allows us to use `gtk` as the feature name.
40// The `target_os` requirement is there to exclude anything `wasm` like.
41#[cfg(all(
42    any(target_os = "freebsd", target_os = "linux", target_os = "openbsd"),
43    feature = "gtk"
44))]
45extern crate gtk_rs as gtk;
46
47#[cfg(feature = "image")]
48pub use piet::image_crate as image;
49pub use piet::kurbo;
50pub use piet_common as piet;
51
52// Reexport the version of `raw_window_handle` we are using.
53#[cfg(feature = "raw-win-handle")]
54pub use raw_window_handle;
55
56#[macro_use]
57mod util;
58
59mod application;
60mod backend;
61mod clipboard;
62mod common_util;
63mod dialog;
64mod error;
65mod hotkey;
66mod keyboard;
67mod menu;
68mod mouse;
69mod region;
70mod scale;
71mod screen;
72mod window;
73
74pub mod platform;
75pub mod text;
76
77pub use application::{AppHandler, Application};
78pub use clipboard::{Clipboard, ClipboardFormat, FormatId};
79pub use common_util::Counter;
80pub use dialog::{FileDialogOptions, FileInfo, FileSpec};
81pub use error::Error;
82pub use hotkey::{HotKey, RawMods, SysMods};
83pub use keyboard::{Code, IntoKey, KbKey, KeyEvent, KeyState, Location, Modifiers};
84pub use menu::Menu;
85pub use mouse::{Cursor, CursorDesc, MouseButton, MouseButtons, MouseEvent};
86pub use region::Region;
87pub use scale::{Scalable, Scale, ScaledArea};
88pub use screen::{Monitor, Screen};
89pub use window::{
90    FileDialogToken, IdleHandle, IdleToken, TextFieldToken, TimerToken, WinHandler, WindowBuilder,
91    WindowHandle, WindowLevel, WindowState,
92};
93
94pub use keyboard_types;