Skip to content

Commit

Permalink
Use standardized Druid naming convention. (#2337)
Browse files Browse the repository at this point in the history
  • Loading branch information
xStrom authored Jan 27, 2023
1 parent 5b160d2 commit 2cd22fb
Show file tree
Hide file tree
Showing 45 changed files with 96 additions and 94 deletions.
14 changes: 8 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ You can find its changes [documented below](#070---2021-01-01).
- Added examples in `TextBox` ([#2284] by [@ThomasMcandrew])
- Removed outdated section in docs for `LifeCycle::WidgetAdded` ([#2320] by [@sprocklem])
- Updated `Event::AnimFrame` docs with info about when `paint` happens. ([#2323] by [@xStrom])
- Implemented standardized Druid naming convention. ([#2337] by [@xStrom])

### Examples
- Add readme ([#1423] by [@JAicewizard])
Expand Down Expand Up @@ -344,16 +345,16 @@ values and their textual representations. ([#1377])

#### X11 backend for druid-shell.

[@crsaracco] got us started and implemented basic support to run druid on bare-metal X11 in [#599].
[@crsaracco] got us started and implemented basic support to run Druid on bare-metal X11 in [#599].
Additional features got fleshed out in [#894] and [#900] by [@xStrom]
and in [#920], [#961], and [#982] by [@jneem].

While still incomplete this lays the foundation for running druid on Linux without relying on GTK.
While still incomplete this lays the foundation for running Druid on Linux without relying on GTK.

#### Web backend for druid-shell.

[@elrnv] continued the work of [@tedsta] and implemented a mostly complete web backend
via WebAssembly (Wasm) in [#759] and enabled all druid examples to
via WebAssembly (Wasm) in [#759] and enabled all Druid examples to
[run in the browser](https://elrnv.github.io/druid-wasm-examples/).

While some features like the clipboard, menus or file dialogs are not yet available,
Expand All @@ -364,8 +365,8 @@ all fundamental features are there.
[@cmyr] continued the work of [@jrmuizel] and implemented Core Graphics support for Piet in
[piet#176](https://github.com/linebender/piet/pull/176).

Those changes made it into druid via [#905].
This means that druid no longer requires cairo on macOS and uses Core Graphics instead.
Those changes made it into Druid via [#905].
This means that Druid no longer requires cairo on macOS and uses Core Graphics instead.

### Added

Expand Down Expand Up @@ -494,7 +495,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i

### Outside News

- There are new projects using druid:
- There are new projects using Druid:
- [Kondo](https://github.com/tbillington/kondo) Save disk space by cleaning unneeded files from software projects.
- [jack-mixer](https://github.com/derekdreery/jack-mixer) A jack client that provides mixing, levels and a 3-band eq.
- [kiro-synth](https://github.com/chris-zen/kiro-synth) An in progress modular sound synthesizer.
Expand Down Expand Up @@ -893,6 +894,7 @@ Last release without a changelog :(
[#2324]: https://github.com/linebender/druid/pull/2324
[#2331]: https://github.com/linebender/druid/pull/2331
[#2335]: https://github.com/linebender/druid/pull/2335
[#2337]: https://github.com/linebender/druid/pull/2337
[#2338]: https://github.com/linebender/druid/pull/2338
[#2340]: https://github.com/linebender/druid/pull/2340
[#2343]: https://github.com/linebender/druid/pull/2343
Expand Down
2 changes: 1 addition & 1 deletion docs/src/02_getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ On OpenBSD, Druid requires gtk+3; install from packages:

## Starting a project

Create a new cargo binary crate, and add druid as a dependency:
Create a new cargo binary crate, and add `druid` as a dependency:

```sh
> cargo new my-druid-app
Expand Down
2 changes: 1 addition & 1 deletion docs/src/05_lens.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Lens<Container2, Name> for NameLens {

As you'll see, we've introduced `Rc`: the reference-counted pointer. You will see this and its multithreaded cousin `Arc` used pervasively in the examples. Now, the only time we actually have to copy memory is when `Rc::make_mut` is called in the `f` in `with_mut`. This means that in the case where nothing changes, all we will be doing is incrementing and decrementing reference counts. Moreover, we give the compiler the opportunity to inline `f` and `with`/`with_mut`, making this abstraction potentially zero-cost (disclaimer: I haven't actually studied the produced assembly to validate this claim).

The trade-off is that we introduce more complexity into the `Name` type: to make changes to the data we have to use `Rc::make_mut` to get mutable access to the `String`. (The code in the lens will ensure that the newer copy of the `Rc`d data is saved to the outer type.) This means the writing fast druid code requires knowledge of the Rust pointer types (`Rc`/`Arc`, and also potentially `RefCell`/`Mutex`).
The trade-off is that we introduce more complexity into the `Name` type: to make changes to the data we have to use `Rc::make_mut` to get mutable access to the `String`. (The code in the lens will ensure that the newer copy of the `Rc`d data is saved to the outer type.) This means the writing fast Druid code requires knowledge of the Rust pointer types (`Rc`/`Arc`, and also potentially `RefCell`/`Mutex`).

We can actually do even better than this. Suppose that we are working on a vector of data rather than a string. We can import the `im` crate to get collections that use *structural sharing*, meaning that even when the vector is mutated, we only *Clone* what we need to. Because `im` is so useful, it is included in `druid` (behind the `im` feature).

Expand Down
6 changes: 3 additions & 3 deletions docs/src/07_resolution_independence.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ the large image assets would be scaled down to the size that makes sense for the

Druid aims to make all of this as **easy and automatic** as possible.
Druid has expressive vector drawing capabilities that you should use whenever possible.
Vector drawing is also used by the widgets that come included with druid.
Vector drawing is also used by the widgets that come included with Druid.
Handling different pixel densities is done at the `druid-shell` level already.
In fact pixels mostly don't even enter the conversation at the `druid` level.
The `druid` coordinate system is instead measured in **display points** (**dp**),
e.g. you might say a widget has a width of **100dp**.
*Display points* are conceptually similar to Microsoft's *device-independent pixels*,
Google's *density-independent pixels*, Apple's *points*, and CSS's *pixel units*.

You **describe the UI using display points and then druid will automatically
You **describe the UI using display points and then Druid will automatically
translate that into pixels** based on the pixel density of the platform.
Remember there might be multiple displays connected with different pixel densities,
and your application might have multiple windows - with each window on a different display.
It will all just work, because druid will adjust the actual pixel dimensions
It will all just work, because Druid will adjust the actual pixel dimensions
based on the display that the window is currently located on.
2 changes: 1 addition & 1 deletion druid-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "druid-derive"
version = "0.4.0"
license = "Apache-2.0"
authors = ["Druid authors"]
description = "derive impls for druid, a Rust UI toolkit."
description = "derive impls for Druid, a Rust UI toolkit."
repository = "https://github.com/linebender/druid"
edition = "2018"

Expand Down
4 changes: 2 additions & 2 deletions druid-derive/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# druid-derive

This crate is implementations of derive macros for [druid][].
This crate contains the implementations of derive macros for [Druid].

[druid]: https://github.com/linebender/druid
[Druid]: https://github.com/linebender/druid
2 changes: 1 addition & 1 deletion druid-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! derive macros for druid.
//! derive macros for Druid.
#![deny(clippy::trivially_copy_pass_by_ref)]
#![doc(
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "druid-shell"
version = "0.7.0"
license = "Apache-2.0"
authors = ["Raph Levien <[email protected]>"]
description = "Platform abstracting application shell used for druid toolkit."
description = "Platform abstracting application shell used for Druid toolkit."
repository = "https://github.com/linebender/druid"
readme = "README.md"
categories = ["os::macos-apis", "os::windows-apis", "gui"]
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/examples/edit_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! This example shows a how a single-line text field might be implemented for druid-shell.
//! This example shows a how a single-line text field might be implemented for `druid-shell`.
//! Beyond the omission of multiple lines and text wrapping, it also is missing many motions
//! (like "move to previous word") and bidirectional text support.
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/backend/mac/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! macOS druid-shell backend.
//! macOS `druid-shell` backend.
#![allow(clippy::let_unit_value)]

Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/backend/mac/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ fn set_size_deferred(this: &mut Object, _view_state: &mut ViewState, size: Size)
let current_frame: NSRect = msg_send![window, frame];
let mut new_frame = current_frame;

// maintain druid origin (as mac origin is bottom left)
// maintain Druid origin (as mac origin is bottom left)
new_frame.origin.y -= size.height - current_frame.size.height;
new_frame.size.width = size.width;
new_frame.size.height = size.height;
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/backend/wayland/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum Error {
version: u32,
inner: Arc<wl::GlobalError>,
},
/// An unexpected error occurred. It's not handled by druid-shell/wayland, so you should
/// An unexpected error occurred. It's not handled by `druid-shell`/wayland, so you should
/// terminate the app.
Fatal(Arc<dyn StdError + 'static>),
String(ErrorString),
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/backend/wayland/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Keyboard {
event.mods = self.xkb_mods.get();

if let Err(cause) = keystroke.queue.send(event) {
tracing::error!("failed to send druid key event: {:?}", cause);
tracing::error!("failed to send Druid key event: {:?}", cause);
}
}

Expand Down
4 changes: 2 additions & 2 deletions druid-shell/src/backend/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! Windows implementation of druid-shell.
//! Windows implementation of `druid-shell`.
mod accels;
pub mod application;
Expand Down Expand Up @@ -40,7 +40,7 @@ pub mod window;
//
// https://docs.microsoft.com/en-us/windows/win32/direct2d/devices-and-device-contexts
// A Device Context, ID2D1DeviceContext, is available as of windows 7 platform update. This
// is the minimum compatibility target for druid. We are not making an effort to do
// is the minimum compatibility target for Druid. We are not making an effort to do
// RenderTarget only.
//
// Basically, go from HwndRenderTarget or DxgiSurfaceRenderTarget (2d or 3d) to a Device Context.
Expand Down
8 changes: 4 additions & 4 deletions druid-shell/src/backend/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub enum PresentStrategy {
/// We work hard to avoid calling into `WinHandler` re-entrantly. Since we use
/// the system's event loop, and since the `WinHandler` gets a `WindowHandle` to use, this implies
/// that none of the `WindowHandle`'s methods can return control to the system's event loop
/// (because if it did, the system could call back into druid-shell with some mouse event, and then
/// (because if it did, the system could call back into `druid-shell` with some mouse event, and then
/// we'd try to call the `WinHandler` again).
///
/// The solution is that for every `WindowHandle` method that *wants* to return control to the
Expand All @@ -146,12 +146,12 @@ pub enum PresentStrategy {
/// method returns.
///
/// An example call trace might look like:
/// 1. the system hands a mouse click event to druid-shell
/// 2. druid-shell calls `WinHandler::mouse_up`
/// 1. the system hands a mouse click event to `druid-shell`
/// 2. `druid-shell` calls `WinHandler::mouse_up`
/// 3. after some processing, the `WinHandler` calls `WindowHandle::save_as`, which schedules a
/// deferred op and returns immediately
/// 4. after some more processing, `WinHandler::mouse_up` returns
/// 5. druid-shell displays the "save as" dialog that was requested in step 3.
/// 5. `druid-shell` displays the "save as" dialog that was requested in step 3.
enum DeferredOp {
SaveAs(FileDialogOptions, FileDialogToken),
Open(FileDialogOptions, FileDialogToken),
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/backend/x11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! X11 implementation of druid-shell.
//! X11 implementation of `druid-shell`.
// TODO(x11/render_improvements): screen is currently flashing when resizing in perftest.
// Might be related to the "sleep scheduler" in XWindow::render()?
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! Platform abstraction for druid toolkit.
//! Platform abstraction for Druid toolkit.
//!
//! `druid-shell` is an abstraction around a given platform UI & application
//! framework. It provides common types, which then defer to a platform-defined
Expand Down
4 changes: 2 additions & 2 deletions druid-shell/src/scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::kurbo::{Insets, Line, Point, Rect, Size, Vec2};
/// These display points will be automatically converted into pixels under the hood.
/// One pixel is equal to one display point when the platform scale factor is `1.0`.
///
/// Read more about pixels and display points [in the druid book].
/// Read more about pixels and display points [in the Druid book].
///
/// ## Converting with `Scale`
///
Expand All @@ -42,7 +42,7 @@ use crate::kurbo::{Insets, Line, Point, Rect, Size, Vec2};
///
/// [`x`]: #method.x
/// [`y`]: #method.y
/// [in the druid book]: https://linebender.org/druid/resolution_independence.html
/// [in the Druid book]: https://linebender.org/druid/07_resolution_independence.html
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct Scale {
/// The scale factor on the x axis.
Expand Down
4 changes: 2 additions & 2 deletions druid-shell/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
//! 3. The user presses a key on the keyboard. The platform first calls
//! `WinHandler::key_down`. If this method returns `true`, the application
//! has indicated the keypress was captured, and we skip the remaining steps.
//! 4. If `key_down` returned `false`, druid-shell forwards the key event to the
//! 4. If `key_down` returned `false`, `druid-shell` forwards the key event to the
//! platform's text input system
//! 5. The platform, in response to either this key event or some other user
//! action, determines it's time for some text input. It calls
Expand Down Expand Up @@ -97,7 +97,7 @@
//! ## Supported Platforms
//!
//! Currently, `druid-shell` text input is fully implemented on macOS. Our goal
//! is to have full support for all druid-shell targets, but for now,
//! is to have full support for all `druid-shell` targets, but for now,
//! `InputHandler` calls are simulated from keypresses on other platforms, which
//! doesn't allow for IME input, dead keys, etc.
Expand Down
4 changes: 2 additions & 2 deletions druid/examples/game_of_life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! This is an example of how you would implement the game of life with druid.
//! This example doesn't showcase anything specific in druid.
//! This is an example of how you would implement the game of life with Druid.
//! This example doesn't showcase anything specific in Druid.
// On Windows platform, don't show a console when opening the app.
#![windows_subsystem = "windows"]
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! This is a very small example of how to setup a druid application.
//! This is a very small example of how to setup a Druid application.
//! It does the almost bare minimum while still being useful.
// On Windows platform, don't show a console when opening the app.
Expand Down
4 changes: 2 additions & 2 deletions druid/examples/hello_web/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Druid web hello world

This is a minimal example of building a single druid application for the web.
To build all the druid examples for the web, check out the `web` example directory.
This is a minimal example of building a single Druid application for the web.
To build all the Druid examples for the web, check out the `web` example directory.

## Building

Expand Down
2 changes: 1 addition & 1 deletion druid/examples/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn build_app() -> impl Widget<u32> {
.background(Color::WHITE);
col.add_flex_child(aspect_ratio_box.center(), 1.0);

// This method asks druid to draw colored rectangles around our widgets,
// This method asks Druid to draw colored rectangles around our widgets,
// so we can visually inspect their layout rectangles.
col.debug_paint_layout()
}
Expand Down
Loading

0 comments on commit 2cd22fb

Please sign in to comment.