Skip to content

Commit

Permalink
Merge branch 'master' into fix-1995
Browse files Browse the repository at this point in the history
  • Loading branch information
maan2003 authored Oct 1, 2021
2 parents c41c7cb + 70e0b97 commit 22ca794
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 50 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ You can find its changes [documented below](#070---2021-01-01).
- X11: detect keyboard layout ([#1779] by [@Maan2003])
- WindowDesc::with_config ([#1929] by [@Maan2003])
- `Notification::route` ([#1978] by [@xarvic])
- Build on OpenBSD ([#1993] by [@klemensn])

### Changed

Expand Down Expand Up @@ -522,6 +523,7 @@ Last release without a changelog :(
[@DrGabble]: https://github.com/DrGabble
[@lisael]: https://github.com/lisael
[@jenra-uwu]: https://github.com/jenra-uwu
[@klemensn]: https://github.com/klemensn

[#599]: https://github.com/linebender/druid/pull/599
[#611]: https://github.com/linebender/druid/pull/611
Expand Down Expand Up @@ -798,6 +800,7 @@ Last release without a changelog :(
[#1953]: https://github.com/linebender/druid/pull/1953
[#1967]: https://github.com/linebender/druid/pull/1967
[#1978]: https://github.com/linebender/druid/pull/1978
[#1993]: https://github.com/linebender/druid/pull/1993
[#1996]: https://github.com/linebender/druid/pull/1996

[Unreleased]: https://github.com/linebender/druid/compare/v0.7.0...master
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ druid = { git = "https://github.com/linebender/druid.git" }
On Linux, Druid requires gtk+3; see [GTK installation page].
(On ubuntu-based distro, running `sudo apt-get install libgtk-3-dev` from the terminal will do the job.)

#### OpenBSD

On OpenBSD, Druid requires gtk+3; install from packages:
```sh
pkg_add gtk+3
```

Alternatively, there is an X11 backend available, although it is currently
[missing quite a few features](https://github.com/linebender/druid/issues?q=is%3Aopen+is%3Aissue+label%3Ashell%2Fx11+label%3Amissing).
Expand Down Expand Up @@ -152,7 +158,7 @@ Druid relies on the [Piet library] for drawing and text layout. Piet is a 2D gra
abstraction with multiple backends: `piet-direct2d`, `piet-coregraphics`, `piet-cairo`,
`piet-web`, and `piet-svg` are currently available, and a GPU backend is planned.
In terms of Druid platform support via Piet, macOS uses `piet-coregraphics`,
Linux uses `piet-cairo`, Windows uses `piet-direct2d`, and web uses `piet-web`.
Linux and OpenBSD use `piet-cairo`, Windows uses `piet-direct2d`, and web uses `piet-web`.

```rust
use druid::kurbo::{BezPath, Point, Rect};
Expand Down
6 changes: 6 additions & 0 deletions docs/src/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ sudo dnf install gtk3-devel glib2-devel

See [GTK installation page] for more installation instructions.

### OpenBSD
On OpenBSD, Druid requires gtk+3; install from packages:
```no_compile
pkg_add gtk+3
```

## Starting a project
Starting a project is as easy as creating an empty application with
```no_compile
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ core-graphics = "0.22.0"
foreign-types = "0.3.2"
bitflags = "1.2.1"

[target.'cfg(target_os="linux")'.dependencies]
[target.'cfg(any(target_os="linux", target_os="openbsd"))'.dependencies]
# TODO(x11/dependencies): only use feature "xcb" if using X11
cairo-rs = { version = "0.14.0", default_features = false, features = ["xcb"] }
cairo-sys-rs = { version = "0.14.0", default_features = false, optional = true }
Expand Down
4 changes: 3 additions & 1 deletion druid-shell/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ fn main() {
use std::env;
use std::path::PathBuf;

if env::var("CARGO_CFG_TARGET_OS").unwrap() != "linux" {
if env::var("CARGO_CFG_TARGET_OS").unwrap() != "linux"
&& env::var("CARGO_CFG_TARGET_OS").unwrap() != "openbsd"
{
return;
}

Expand Down
12 changes: 6 additions & 6 deletions druid-shell/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ pub use mac::*;
#[cfg(target_os = "macos")]
pub(crate) mod shared;

#[cfg(all(feature = "x11", target_os = "linux"))]
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "openbsd")))]
mod x11;
#[cfg(all(feature = "x11", target_os = "linux"))]
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "openbsd")))]
pub use x11::*;
#[cfg(all(feature = "x11", target_os = "linux"))]
#[cfg(all(feature = "x11", any(target_os = "linux", target_os = "openbsd")))]
pub(crate) mod shared;

#[cfg(all(not(feature = "x11"), target_os = "linux"))]
#[cfg(all(not(feature = "x11"), any(target_os = "linux", target_os = "openbsd")))]
mod gtk;
#[cfg(all(not(feature = "x11"), target_os = "linux"))]
#[cfg(all(not(feature = "x11"), any(target_os = "linux", target_os = "openbsd")))]
pub use self::gtk::*;
#[cfg(all(not(feature = "x11"), target_os = "linux"))]
#[cfg(all(not(feature = "x11"), any(target_os = "linux", target_os = "openbsd")))]
pub(crate) mod shared;

#[cfg(target_arch = "wasm32")]
Expand Down
7 changes: 5 additions & 2 deletions druid-shell/src/backend/shared/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
#[allow(unused)]
use keyboard_types::{Code, Location};

#[cfg(any(all(feature = "x11", target_os = "linux"), target_os = "macos"))]
#[cfg(any(
all(feature = "x11", any(target_os = "linux", target_os = "openbsd")),
target_os = "macos"
))]
/// Map key code to location.
///
/// The logic for this is adapted from InitKeyEvent in TextInputHandler (in the Mozilla
Expand Down Expand Up @@ -51,7 +54,7 @@ pub fn code_to_location(code: Code) -> Location {
}
}

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "openbsd"))]
/// Map hardware keycode to code.
///
/// In theory, the hardware keycode is device dependent, but in
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/backend/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! Logic that is shared by more than one backend.
cfg_if::cfg_if! {
if #[cfg(any(target_os = "macos", target_os = "linux"))] {
if #[cfg(any(target_os = "macos", target_os = "linux", target_os = "openbsd"))] {
mod keyboard;
pub use keyboard::*;
}
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ cfg_if::cfg_if! {
} else {
impl ClipboardFormat {
cfg_if::cfg_if! {
if #[cfg(target_os = "linux")] {
if #[cfg(any(target_os = "linux", target_os = "openbsd"))] {
// trial and error; this is the most supported string type for gtk?
pub const TEXT: &'static str = "UTF8_STRING";
} else {
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct FileInfo {
}

/// Type of file dialog.
#[cfg(not(all(target_os = "linux", feature = "x11")))]
#[cfg(not(all(any(target_os = "linux", target_os = "openbsd"), feature = "x11")))]
#[derive(Clone, Copy, PartialEq)]
pub enum FileDialogType {
/// File open dialog.
Expand Down
8 changes: 4 additions & 4 deletions druid-shell/src/hotkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ impl HotKey {
pub enum SysMods {
None,
Shift,
/// Command on macOS, and Ctrl on windows/linux
/// Command on macOS, and Ctrl on windows/linux/OpenBSD
Cmd,
/// Command + Alt on macOS, Ctrl + Alt on windows/linux
/// Command + Alt on macOS, Ctrl + Alt on windows/linux/OpenBSD
AltCmd,
/// Command + Shift on macOS, Ctrl + Shift on windows/linux
/// Command + Shift on macOS, Ctrl + Shift on windows/linux/OpenBSD
CmdShift,
/// Command + Alt + Shift on macOS, Ctrl + Alt + Shift on windows/linux
/// Command + Alt + Shift on macOS, Ctrl + Alt + Shift on windows/linux/OpenBSD
AltCmdShift,
}

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 @@ -36,7 +36,7 @@
// Rename `gtk_rs` back to `gtk`.
// This allows us to use `gtk` as the feature name.
// The `target_os` requirement is there to exclude anything `wasm` like.
#[cfg(all(target_os = "linux", feature = "gtk"))]
#[cfg(all(any(target_os = "linux", target_os = "openbsd"), feature = "gtk"))]
extern crate gtk_rs as gtk;

// Reexport the version of `image` we are using.
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

//! Platorm specific extensions.
#[cfg(any(doc, target_os = "linux"))]
#[cfg(any(doc, any(target_os = "linux", target_os = "openbsd")))]
pub mod linux;

#[cfg(any(doc, target_os = "macos"))]
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/markdown_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ fn make_menu<T: Data>(_window_id: Option<WindowId>, _app_state: &AppState, _env:
{
base = base.entry(druid::platform_menus::mac::application::default())
}
#[cfg(any(target_os = "windows", target_os = "linux"))]
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "openbsd"))]
{
base = base.entry(druid::platform_menus::win::file::default());
}
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/multiwin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ fn make_menu(_: Option<WindowId>, state: &State, _: &Env) -> Menu<State> {
{
base = druid::platform_menus::mac::menu_bar();
}
#[cfg(any(target_os = "windows", target_os = "linux"))]
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "openbsd"))]
{
base = base.entry(druid::platform_menus::win::file::default());
}
Expand Down
69 changes: 48 additions & 21 deletions druid/examples/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
There are several different kind of examples, some demonstrate one particular
Druid concept, some are tools used for testing and debugging, and
others are more complete examples of how to tie everything together.
The latter are listed separately under [showcases](##Showcases).
The latter are listed separately under [showcases](#Showcases).

## Anim
```
Expand All @@ -15,21 +15,21 @@ This example shows how to make a simple animation using `Event::AnimFrame`.
```
cargo run --example async_event
```
Demonstrates receiving data from some outside source, and updating the UI in response. This is similar to [blocking function](##Blocking Function) but here the data source is fully independent, and runs for the lifetime of the program.
Demonstrates receiving data from some outside source, and updating the UI in response. This is similar to [blocking function](#Blocking Function) but here the data source is fully independent, and runs for the lifetime of the program.

## Blocking Functions
## Blocking Function
```
cargo run --example blocking_functions
cargo run --example blocking_function
```
Sometimes you need to fetch some data from disk or from the internet,
but you should never block the UI thread with long running operations!
Instead you should run this task in a separate thread, and have it send
you the data as it arrives. This is very similar to [async event](##Async Event)
you the data as it arrives. This is very similar to [async event](#Async Event)
except the event is initiated by the main thread.

## Cursor
```
cargo run --example cursor
cargo run --example cursor --features="image png"
```
This example demonstrates how to set the cursor icon, and how to use a custom cursor.

Expand All @@ -55,12 +55,25 @@ cargo run --example hello
This shows some of the basics of druid. If you need a start of how to build an application with a text-box and some labels this is where to start.

## Hello_web
For more info and prerequistes see [druid/examples/hello_web/README.md](druid/examples/hello_web/README.md).
```
cd druid/examples/hello_web
wasm-pack build --out-dir pkg --out-name hello_web
```
[View at http://localhost:8000](http://localhost:8000].

This is an example of how to get almost any druid application can be used on the web. This is just the hello_world example but should work for all of them.

## Web
For more info and prerequistes see [druid/examples/web/README.md](druid/examples/web/README.md).
```
cd druid/examples/web
wasm-pack build --out-dir pkg --out-name web
```
[View at http://localhost:8000](http://localhost:8000].

Simple web app.

## Identity
```
cargo run --example identity
Expand Down Expand Up @@ -91,6 +104,12 @@ cargo run --example list --features="im"
```
This shows you how you could, for example, add items to lists and delete them.

## Markdown Preview
```
cargo run --example markdown_preview
```
An example of markdown preview on the left side and editable text on the right side.

## Multiple Windows
```
cargo run --example multiwin
Expand All @@ -107,7 +126,7 @@ Opening and saving files is crucial for a lot of applications. This shows you ho
```
cargo run --example panels
```
Very similar to [layout](##Layout) but it splits the screen into 2 segments
Very similar to [layout](#Layout) but it splits the screen into 2 segments

## Value Formatting

Expand Down Expand Up @@ -138,18 +157,13 @@ cargo run --example split_demo
An example of how to split a widget in 2 in various ways. This also includes having the user drag the border!!

## Sub Window
Not working, no sub-window seen?
```
cargo run --example sub_window
```

This shows you how to make a completely new window with shared state.

## Styled_text
```
cargo run --example styled_text
```
Not all text should look the same. You are able to change a lot of things, color, size, and monospace. This example shows how to change these propperties.

## Svg
```
cargo run --example svg --features="svg"
Expand All @@ -164,13 +178,25 @@ Switches are useful in many ways, this example shows how to use the druid built-

## Tabs
```
cargo run --example tabs
cargo run --example tabs --features="im"
```
Tabs allow you to seperate different portions of the UI. This example shows you how to use them in druid. similar to [view switcher](#View Switcher) but with with a different purpose.

## Text
```
cargo run --example text
```
Text shows the effects of TextAlignment and LineBreaker types.

## TextBox
```
cargo run --example textbox
```
Tabs allow you to seperate different portions of the UI. This example shows you how to use them in druid. similar to [view switcher](##View Switcher) but with with a different purpose.
Textbox demostrates some of the possible configuraitons of the TextBox widget.

## Timers
## Timer
```
cargo run --example timers
cargo run --example timer
```
Timers allow you to send events to your widgets at a certain points inthe future. This example shows how to use them.

Expand All @@ -184,7 +210,7 @@ This shows you how to make the window transparent, so the rest of the desktop sh
```
cargo run --example view_switcher
```
Very similar to [tabs](##Tabs) but this allows you to have more control over it. This allows you to switch out widgets on the fly.
Very similar to [tabs](#Tabs) but this allows you to have more control over it. This allows you to switch out widgets on the fly.

# Showcases

Expand Down Expand Up @@ -223,7 +249,7 @@ A simple implementation of Conway's game of life. You can change the evolution s

## Image
```
cargo run --example image
cargo run --example image --features "image png"
```

Image shows off all the knobs you can turn on images. You can play with them with real time results, which you to figure out what settings are best for you.
Expand All @@ -242,11 +268,12 @@ This is a showcase is scrolling through an image gradient square. The square is
cargo run --example styled_text
```

In druid you can change all kinds of styling aspects of text. This shows off some of them.
In druid you can change all kinds of styling aspects of text as not all text should look
the same. This showcases some of those things such as, color, size, and monospace.

## Widget Gallery
```
cargo run --example widget_gallery
cargo run --example widget_gallery --features="svg im image png"
```

This is a showcase of some simple widgets with their default styling. These are interactive, but you cannot change any of their styling.
1 change: 0 additions & 1 deletion druid/examples/sub_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ fn build_root_widget() -> impl Widget<HelloState> {
WindowConfig::default()
.show_titlebar(false)
.window_size(Size::new(100., 100.))
.set_position(Point::new(1000.0, 500.0))
.set_level(WindowLevel::AppWindow),
col,
data.clone(),
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn make_menu<T: Data>(_window: Option<WindowId>, _data: &AppState, _env: &Env) -
{
base = base.entry(druid::platform_menus::mac::application::default())
}
#[cfg(any(target_os = "windows", target_os = "linux"))]
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "openbsd"))]
{
base = base.entry(druid::platform_menus::win::file::default());
}
Expand Down
Loading

0 comments on commit 22ca794

Please sign in to comment.