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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Copyright 2018 The xi-editor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Simple data-oriented GUI.
//!
//! Druid lets you build simple interactive graphical applications that
//! can be deployed on windows, mac, and linux.
//!
//! Druid is built on top of [`druid-shell`], which implements all of the
//! lower-level, platform-specific code, providing a common abstraction
//! for things like key and mouse events, creating windows, and launching
//! an application. Below [`druid-shell`] is [`piet`], which is a cross-platform
//! 2D graphics library, providing a simple and familiar drawing API that can be
//! implemented for various platforms.
//!
//! Druid is a data-driven, declarative framework. You describe your application
//! model in terms of the [`Data`] trait, and then you build up a tree of
//! [`widget`] s that can display and modify your data.
//!
//! Your widgets handle [`Event`]s, such as mouse movement, and can modify the data;
//! these changes are then delivered to relevant widgets, which can update
//! their state and redraw.
//!
//! As your application grows, you can use [`Lens`]es to expose only certain
//! subsets of your data model to certains subsets of your widget tree.
//!
//! # Examples
//!
//! For many more examples, see [`druid/examples`].
//!
//! ```no_run
//! use druid::widget::{Align, Flex, Label, TextBox};
//! use druid::{AppLauncher, Data, Env, Lens, LocalizedString, Widget, WindowDesc, WidgetExt};
//!
//! const VERTICAL_WIDGET_SPACING: f64 = 20.0;
//! const TEXT_BOX_WIDTH: f64 = 200.0;
//! const WINDOW_TITLE: LocalizedString<HelloState> = LocalizedString::new("Hello World!");
//!
//! #[derive(Clone, Data, Lens)]
//! struct HelloState {
//! name: String,
//! }
//!
//! fn main() {
//! // describe the main window
//! let main_window = WindowDesc::new(build_root_widget)
//! .title(WINDOW_TITLE)
//! .window_size((400.0, 400.0));
//!
//! // create the initial app state
//! let initial_state = HelloState {
//! name: "World".into(),
//! };
//!
//! // start the application
//! AppLauncher::with_window(main_window)
//! .launch(initial_state)
//! .expect("Failed to launch application");
//! }
//!
//! fn build_root_widget() -> impl Widget<HelloState> {
//! // a label that will determine its text based on the current app data.
//! let label = Label::new(|data: &HelloState, _env: &Env| format!("Hello {}!", data.name));
//! // a textbox that modifies `name`.
//! let textbox = TextBox::new()
//! .with_placeholder("Who are we greeting?")
//! .fix_width(TEXT_BOX_WIDTH)
//! .lens(HelloState::name);
//!
//! // arrange the two widgets vertically, with some padding
//! let layout = Flex::column()
//! .with_child(label)
//! .with_spacer(VERTICAL_WIDGET_SPACING)
//! .with_child(textbox);
//!
//! // center the two widgets in the available space
//! Align::centered(layout)
//! }
//! ```
//!
//! [`Widget`]: trait.Widget.html
//! [`Data`]: trait.Data.html
//! [`Lens`]: trait.Lens.html
//! [`widget`]: ./widget/index.html
//! [`Event`]: enum.Event.html
//! [`druid-shell`]: https://docs.rs/druid-shell
//! [`piet`]: https://docs.rs/piet
//! [`druid/examples`]: https://github.com/xi-editor/druid/tree/v0.5.0/druid/examples
// Allows to use macros from druid_derive in this crate
extern crate self as druid;
pub use Lens;
use druid_shell as shell;
pub use ;
// Types from kurbo & piet that are required by public API.
pub use ;
pub use ;
// these are the types from shell that we expose; others we only use internally.
pub use ;
pub use crateWidgetPod;
pub use ;
pub use ;
pub use BoxConstraints;
pub use ;
pub use ;
pub use Data;
pub use ;
pub use ;
pub use ;
pub use ;
pub use LocalizedString;
pub use ;
pub use MouseEvent;
pub use ;
pub use DruidHandler;
pub use ;
pub use ;