mirror of
https://github.com/danbulant/cushy
synced 2026-06-19 22:41:10 +00:00
winit 0.30
This commit is contained in:
parent
8880fece3a
commit
46c4eb9ed8
8 changed files with 136 additions and 130 deletions
179
Cargo.lock
generated
179
Cargo.lock
generated
|
|
@ -66,9 +66,9 @@ checksum = "b072fc284b73a3e4154e2decdbaad711daca0e8fedfceb0d7b1cbe2dffb00e2b"
|
|||
|
||||
[[package]]
|
||||
name = "android-activity"
|
||||
version = "0.5.2"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289"
|
||||
checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046"
|
||||
dependencies = [
|
||||
"android-properties",
|
||||
"bitflags 2.5.0",
|
||||
|
|
@ -80,7 +80,7 @@ dependencies = [
|
|||
"log",
|
||||
"ndk",
|
||||
"ndk-context",
|
||||
"ndk-sys",
|
||||
"ndk-sys 0.6.0+11769913",
|
||||
"num_enum",
|
||||
"thiserror",
|
||||
]
|
||||
|
|
@ -109,7 +109,7 @@ checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519"
|
|||
[[package]]
|
||||
name = "appit"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/khonsulabs/appit#657493a81dfe6135f6044fd8e4254149782aa8e1"
|
||||
source = "git+https://github.com/khonsulabs/appit#14a2957d6cd4cc8d1ac6e2ba54a177eec833e8ab"
|
||||
dependencies = [
|
||||
"winit",
|
||||
]
|
||||
|
|
@ -139,7 +139,7 @@ dependencies = [
|
|||
"core-graphics",
|
||||
"image",
|
||||
"log",
|
||||
"objc2 0.5.1",
|
||||
"objc2",
|
||||
"objc2-app-kit",
|
||||
"objc2-foundation",
|
||||
"parking_lot",
|
||||
|
|
@ -293,32 +293,13 @@ version = "0.1.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
|
||||
|
||||
[[package]]
|
||||
name = "block-sys"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae85a0696e7ea3b835a453750bf002770776609115e6d25c6d2ff28a8200f7e7"
|
||||
dependencies = [
|
||||
"objc-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block2"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68"
|
||||
dependencies = [
|
||||
"block-sys",
|
||||
"objc2 0.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block2"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43ff7d91d3c1d568065b06c899777d1e48dcf76103a672a0adbc238a7f247f1e"
|
||||
dependencies = [
|
||||
"objc2 0.5.1",
|
||||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -442,6 +423,12 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
|
||||
|
||||
[[package]]
|
||||
name = "cfg_aliases"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77e53693616d3075149f4ead59bdeecd204ac6b8192d8969757601b74bddf00f"
|
||||
|
||||
[[package]]
|
||||
name = "clipboard-win"
|
||||
version = "5.3.1"
|
||||
|
|
@ -737,6 +724,12 @@ version = "1.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
|
||||
|
||||
[[package]]
|
||||
name = "dpi"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.11.0"
|
||||
|
|
@ -824,7 +817,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "figures"
|
||||
version = "0.2.2"
|
||||
source = "git+https://github.com/khonsulabs/figures#e7dcdd40a03618a42747ae729a97096dc11ba77f"
|
||||
source = "git+https://github.com/khonsulabs/figures#cadf8a2f50e465b743e8b6e8b6ccc1907d312db1"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"euclid",
|
||||
|
|
@ -1092,17 +1085,6 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
||||
|
||||
[[package]]
|
||||
name = "icrate"
|
||||
version = "0.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99d3aaff8a54577104bafdf686ff18565c3b6903ca5782a2026ef06e2c7aa319"
|
||||
dependencies = [
|
||||
"block2 0.3.0",
|
||||
"dispatch",
|
||||
"objc2 0.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.25.1"
|
||||
|
|
@ -1280,7 +1262,7 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
|||
[[package]]
|
||||
name = "kludgine"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/khonsulabs/kludgine#acbb0b647b5ba66c10af9175ec22c3a90fede0a0"
|
||||
source = "git+https://github.com/khonsulabs/kludgine#d98e0d6d2fa9e40e0c6a9d5b9b5c8079ba3a2e62"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"alot",
|
||||
|
|
@ -1587,14 +1569,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ndk"
|
||||
version = "0.8.0"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7"
|
||||
checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"jni-sys",
|
||||
"log",
|
||||
"ndk-sys",
|
||||
"ndk-sys 0.6.0+11769913",
|
||||
"num_enum",
|
||||
"raw-window-handle",
|
||||
"thiserror",
|
||||
|
|
@ -1615,6 +1597,15 @@ dependencies = [
|
|||
"jni-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk-sys"
|
||||
version = "0.6.0+11769913"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873"
|
||||
dependencies = [
|
||||
"jni-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "new_debug_unreachable"
|
||||
version = "1.0.6"
|
||||
|
|
@ -1742,16 +1733,6 @@ version = "0.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da284c198fb9b7b0603f8635185e85fbd5b64ee154b1ed406d489077de2d6d60"
|
||||
|
||||
[[package]]
|
||||
name = "objc2"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d"
|
||||
dependencies = [
|
||||
"objc-sys",
|
||||
"objc2-encode 3.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2"
|
||||
version = "0.5.1"
|
||||
|
|
@ -1759,7 +1740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "b4b25e1034d0e636cd84707ccdaa9f81243d399196b8a773946dcffec0401659"
|
||||
dependencies = [
|
||||
"objc-sys",
|
||||
"objc2-encode 4.0.1",
|
||||
"objc2-encode",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1768,8 +1749,8 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb79768a710a9a1798848179edb186d1af7e8a8679f369e4b8d201dd2a034047"
|
||||
dependencies = [
|
||||
"block2 0.5.0",
|
||||
"objc2 0.5.1",
|
||||
"block2",
|
||||
"objc2",
|
||||
"objc2-core-data",
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
|
@ -1780,17 +1761,11 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e092bc42eaf30a08844e6a076938c60751225ec81431ab89f5d1ccd9f958d6c"
|
||||
dependencies = [
|
||||
"block2 0.5.0",
|
||||
"objc2 0.5.1",
|
||||
"block2",
|
||||
"objc2",
|
||||
"objc2-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-encode"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666"
|
||||
|
||||
[[package]]
|
||||
name = "objc2-encode"
|
||||
version = "4.0.1"
|
||||
|
|
@ -1803,8 +1778,9 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfaefe14254871ea16c7d88968c0ff14ba554712a20d76421eec52f0a7fb8904"
|
||||
dependencies = [
|
||||
"block2 0.5.0",
|
||||
"objc2 0.5.1",
|
||||
"block2",
|
||||
"dispatch",
|
||||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1938,6 +1914,26 @@ dependencies = [
|
|||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3"
|
||||
dependencies = [
|
||||
"pin-project-internal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-internal"
|
||||
version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.14"
|
||||
|
|
@ -2279,15 +2275,6 @@ dependencies = [
|
|||
"font-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.4.1"
|
||||
|
|
@ -2430,9 +2417,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|||
|
||||
[[package]]
|
||||
name = "sctk-adwaita"
|
||||
version = "0.8.1"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82b2eaf3a5b264a521b988b2e73042e742df700c4f962cde845d1541adb46550"
|
||||
checksum = "7de61fa7334ee8ee1f5c3c58dcc414fb9361e7e8f5bff9d45f4d69eeb89a7169"
|
||||
dependencies = [
|
||||
"ab_glyph",
|
||||
"log",
|
||||
|
|
@ -2449,18 +2436,18 @@ checksum = "58bf37232d3bb9a2c4e641ca2a11d83b5062066f88df7fed36c28772046d65ba"
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.199"
|
||||
version = "1.0.200"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a"
|
||||
checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.199"
|
||||
version = "1.0.200"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc"
|
||||
checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -3161,9 +3148,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "web-time"
|
||||
version = "0.2.4"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0"
|
||||
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
|
|
@ -3183,7 +3170,7 @@ checksum = "32ff1bfee408e1028e2e3acbf6d32d98b08a5a059ccbf5f33305534453ba5d3e"
|
|||
dependencies = [
|
||||
"arrayvec",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"cfg_aliases 0.1.1",
|
||||
"document-features",
|
||||
"js-sys",
|
||||
"log",
|
||||
|
|
@ -3210,7 +3197,7 @@ dependencies = [
|
|||
"arrayvec",
|
||||
"bit-vec",
|
||||
"bitflags 2.5.0",
|
||||
"cfg_aliases",
|
||||
"cfg_aliases 0.1.1",
|
||||
"codespan-reporting",
|
||||
"document-features",
|
||||
"indexmap",
|
||||
|
|
@ -3240,7 +3227,7 @@ dependencies = [
|
|||
"bit-set",
|
||||
"bitflags 2.5.0",
|
||||
"block",
|
||||
"cfg_aliases",
|
||||
"cfg_aliases 0.1.1",
|
||||
"core-graphics-types",
|
||||
"d3d12",
|
||||
"glow",
|
||||
|
|
@ -3256,7 +3243,7 @@ dependencies = [
|
|||
"log",
|
||||
"metal",
|
||||
"naga",
|
||||
"ndk-sys",
|
||||
"ndk-sys 0.5.0+25.2.9519653",
|
||||
"objc",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
|
|
@ -3547,9 +3534,9 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
|||
|
||||
[[package]]
|
||||
name = "winit"
|
||||
version = "0.29.15"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d59ad965a635657faf09c8f062badd885748428933dad8e8bdd64064d92e5ca"
|
||||
checksum = "ea9e6d5d66cbf702e0dd820302144f51b69a95acdc495dd98ca280ff206562b1"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"android-activity",
|
||||
|
|
@ -3557,27 +3544,29 @@ dependencies = [
|
|||
"bitflags 2.5.0",
|
||||
"bytemuck",
|
||||
"calloop",
|
||||
"cfg_aliases",
|
||||
"cfg_aliases 0.2.0",
|
||||
"concurrent-queue",
|
||||
"core-foundation",
|
||||
"core-graphics",
|
||||
"cursor-icon",
|
||||
"icrate",
|
||||
"dpi",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"log",
|
||||
"memmap2",
|
||||
"ndk",
|
||||
"ndk-sys",
|
||||
"objc2 0.4.1",
|
||||
"once_cell",
|
||||
"objc2",
|
||||
"objc2-app-kit",
|
||||
"objc2-foundation",
|
||||
"orbclient",
|
||||
"percent-encoding",
|
||||
"pin-project",
|
||||
"raw-window-handle",
|
||||
"redox_syscall 0.3.5",
|
||||
"redox_syscall 0.4.1",
|
||||
"rustix",
|
||||
"sctk-adwaita",
|
||||
"smithay-client-toolkit",
|
||||
"smol_str",
|
||||
"tracing",
|
||||
"unicode-segmentation",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
|
|
@ -3587,7 +3576,7 @@ dependencies = [
|
|||
"wayland-protocols-plasma",
|
||||
"web-sys",
|
||||
"web-time",
|
||||
"windows-sys 0.48.0",
|
||||
"windows-sys 0.52.0",
|
||||
"x11-dl",
|
||||
"x11rb",
|
||||
"xkbcommon-dl",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use cushy::{Application, Open, PendingApp};
|
|||
const INTRO: &str = "This example demonstrates the DebugContext, which allows observing values easily throughout GUI";
|
||||
|
||||
fn main() -> cushy::Result {
|
||||
let app = PendingApp::default();
|
||||
let mut app = PendingApp::default();
|
||||
let info = DebugContext::default();
|
||||
|
||||
let window_count = Dynamic::new(0_usize);
|
||||
|
|
@ -15,11 +15,11 @@ fn main() -> cushy::Result {
|
|||
let open_window_button = "Open a Window"
|
||||
.into_button()
|
||||
.on_click({
|
||||
let app = app.as_app();
|
||||
let mut app = app.as_app();
|
||||
let info = info.clone();
|
||||
let window_count = window_count.clone();
|
||||
let total_windows = total_windows.clone();
|
||||
move |()| open_a_window(&window_count, &total_windows, &info, &app)
|
||||
move |()| open_a_window(&window_count, &total_windows, &info, &mut app)
|
||||
})
|
||||
.make_widget();
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ fn main() -> cushy::Result {
|
|||
.into_columns()
|
||||
});
|
||||
|
||||
info.clone().open(&app)?;
|
||||
info.clone().open(&mut app)?;
|
||||
|
||||
INTRO
|
||||
.and(open_window_button)
|
||||
|
|
@ -43,7 +43,7 @@ fn open_a_window(
|
|||
window_count: &Dynamic<usize>,
|
||||
total_windows: &Dynamic<usize>,
|
||||
info: &DebugContext,
|
||||
app: &dyn Application,
|
||||
app: &mut dyn Application,
|
||||
) {
|
||||
*window_count.lock() += 1;
|
||||
let window_number = total_windows.map_mut(|mut total| {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use kludgine::LazyTexture;
|
|||
fn main() -> cushy::Result {
|
||||
// To open multiple applications, we need a handle to the application. This
|
||||
// starts with the `PendingApp` type.
|
||||
let app = PendingApp::default();
|
||||
let mut app = PendingApp::default();
|
||||
// Cushy ensures it's easy to share resources between windows.
|
||||
let texture = include_texture!("assets/ferris-happy.png").expect("valid image");
|
||||
|
||||
|
|
@ -30,11 +30,11 @@ fn main() -> cushy::Result {
|
|||
.centered()
|
||||
// The other examples call run() on the widget/window. Since we're
|
||||
// opening two windows at the app's startup,
|
||||
.open(&app)?;
|
||||
.open(&mut app)?;
|
||||
|
||||
// And now let's open our first "clone" window -- the window that clicking
|
||||
// the open button on any of the windows will create.
|
||||
open_another_window(&app, &open_windows, &counter, &texture);
|
||||
open_another_window(&mut app, &open_windows, &counter, &texture);
|
||||
|
||||
// Run the application
|
||||
app.run()
|
||||
|
|
@ -47,18 +47,18 @@ fn open_window_button(
|
|||
counter: &Dynamic<usize>,
|
||||
texture: &LazyTexture,
|
||||
) -> impl MakeWidget {
|
||||
let app = app.as_app();
|
||||
let mut app = app.as_app();
|
||||
let open_windows = open_windows.clone();
|
||||
let counter = counter.clone();
|
||||
let texture = texture.clone();
|
||||
"Open Another Window".into_button().on_click(move |()| {
|
||||
open_another_window(&app, &open_windows, &counter, &texture);
|
||||
open_another_window(&mut app, &open_windows, &counter, &texture);
|
||||
})
|
||||
}
|
||||
|
||||
/// Opens another window that contains a button that opens another window.
|
||||
fn open_another_window(
|
||||
app: &impl Application,
|
||||
app: &mut impl Application,
|
||||
open_windows: &Dynamic<usize>,
|
||||
counter: &Dynamic<usize>,
|
||||
texture: &LazyTexture,
|
||||
|
|
|
|||
19
src/app.rs
19
src/app.rs
|
|
@ -41,6 +41,13 @@ impl AsApplication<AppEvent<WindowCommand>> for PendingApp {
|
|||
fn as_application(&self) -> &dyn kludgine::app::Application<AppEvent<WindowCommand>> {
|
||||
self.app.as_application()
|
||||
}
|
||||
|
||||
fn as_application_mut(&mut self) -> &mut dyn kludgine::app::Application<AppEvent<WindowCommand>>
|
||||
where
|
||||
AppEvent<WindowCommand>: kludgine::app::Message,
|
||||
{
|
||||
self.app.as_application_mut()
|
||||
}
|
||||
}
|
||||
|
||||
/// Shared resources for a GUI application.
|
||||
|
|
@ -119,6 +126,16 @@ impl AsApplication<AppEvent<WindowCommand>> for App {
|
|||
.map(AsApplication::as_application)
|
||||
.expect("no app")
|
||||
}
|
||||
|
||||
fn as_application_mut(&mut self) -> &mut dyn kludgine::app::Application<AppEvent<WindowCommand>>
|
||||
where
|
||||
AppEvent<WindowCommand>: kludgine::app::Message,
|
||||
{
|
||||
self.app
|
||||
.as_mut()
|
||||
.map(AsApplication::as_application_mut)
|
||||
.expect("no app")
|
||||
}
|
||||
}
|
||||
|
||||
/// A type that can be run as an application.
|
||||
|
|
@ -132,7 +149,7 @@ pub trait Run: Sized {
|
|||
/// A type that can be opened as a window in an application.
|
||||
pub trait Open: Sized {
|
||||
/// Opens the provided type as a window inside of `app`.
|
||||
fn open<App>(self, app: &App) -> crate::Result<Option<WindowHandle>>
|
||||
fn open<App>(self, app: &mut App) -> crate::Result<Option<WindowHandle>>
|
||||
where
|
||||
App: Application + ?Sized;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::ops::{Deref, DerefMut};
|
|||
use figures::units::{Lp, Px, UPx};
|
||||
use figures::{IntoSigned, Point, Px2D, Rect, Round, ScreenScale, Size, Zero};
|
||||
use kludgine::app::winit::event::{Ime, MouseButton, MouseScrollDelta, TouchPhase};
|
||||
use kludgine::app::winit::window::CursorIcon;
|
||||
use kludgine::app::winit::window::Cursor;
|
||||
use kludgine::cosmic_text::FamilyOwned;
|
||||
use kludgine::shapes::{Shape, StrokeOptions};
|
||||
use kludgine::{Color, Kludgine, KludgineId};
|
||||
|
|
@ -175,7 +175,7 @@ impl<'context> EventContext<'context> {
|
|||
}
|
||||
}
|
||||
self.window_mut()
|
||||
.set_cursor_icon(cursor.unwrap_or_default());
|
||||
.set_cursor(cursor.unwrap_or_default().into());
|
||||
}
|
||||
|
||||
pub(crate) fn clear_hover(&mut self) {
|
||||
|
|
@ -187,7 +187,7 @@ impl<'context> EventContext<'context> {
|
|||
old_hover.lock().as_widget().unhover(&mut old_hover_context);
|
||||
}
|
||||
|
||||
self.window_mut().set_cursor_icon(CursorIcon::Default);
|
||||
self.window_mut().set_cursor(Cursor::default());
|
||||
}
|
||||
|
||||
fn apply_pending_activation(&mut self) {
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ impl DebugContext {
|
|||
}
|
||||
|
||||
impl Open for DebugContext {
|
||||
fn open<App>(self, app: &App) -> crate::Result<Option<crate::window::WindowHandle>>
|
||||
fn open<App>(self, app: &mut App) -> crate::Result<Option<crate::window::WindowHandle>>
|
||||
where
|
||||
App: crate::Application + ?Sized,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -471,15 +471,15 @@ impl<T> Open for T
|
|||
where
|
||||
T: MakeWidget,
|
||||
{
|
||||
fn open<App>(self, app: &App) -> crate::Result<Option<crate::window::WindowHandle>>
|
||||
fn open<App>(self, app: &mut App) -> crate::Result<Option<crate::window::WindowHandle>>
|
||||
where
|
||||
App: Application + ?Sized,
|
||||
{
|
||||
Window::<WidgetInstance>::new(self.make_widget()).open(app)
|
||||
}
|
||||
|
||||
fn run_in(self, app: PendingApp) -> crate::Result {
|
||||
Window::<WidgetInstance>::new(self.make_widget()).open(&app)?;
|
||||
fn run_in(self, mut app: PendingApp) -> crate::Result {
|
||||
Window::<WidgetInstance>::new(self.make_widget()).open(&mut app)?;
|
||||
app.run()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use kludgine::app::winit::event::{
|
|||
use kludgine::app::winit::keyboard::{
|
||||
Key, KeyLocation, NamedKey, NativeKeyCode, PhysicalKey, SmolStr,
|
||||
};
|
||||
use kludgine::app::winit::window::{self, CursorIcon};
|
||||
use kludgine::app::winit::window::{self, Cursor};
|
||||
use kludgine::app::{winit, WindowBehavior as _};
|
||||
use kludgine::cosmic_text::{fontdb, Family, FamilyOwned};
|
||||
use kludgine::drawing::Drawing;
|
||||
|
|
@ -82,7 +82,7 @@ pub trait PlatformWindowImplementation {
|
|||
/// Returns the amount of time that has elapsed since the last redraw.
|
||||
fn elapsed(&self) -> Duration;
|
||||
/// Sets the current cursor icon to `cursor`.
|
||||
fn set_cursor_icon(&mut self, cursor: CursorIcon);
|
||||
fn set_cursor(&mut self, cursor: Cursor);
|
||||
/// Returns a handle for the window.
|
||||
fn handle(&self, redraw_status: InvalidationStatus) -> WindowHandle;
|
||||
/// Returns the current inner size of the window.
|
||||
|
|
@ -162,8 +162,8 @@ pub trait PlatformWindowImplementation {
|
|||
}
|
||||
|
||||
impl PlatformWindowImplementation for kludgine::app::Window<'_, WindowCommand> {
|
||||
fn set_cursor_icon(&mut self, cursor: CursorIcon) {
|
||||
self.winit().set_cursor_icon(cursor);
|
||||
fn set_cursor(&mut self, cursor: Cursor) {
|
||||
self.winit().set_cursor(cursor);
|
||||
}
|
||||
|
||||
fn inner_size(&self) -> Size<UPx> {
|
||||
|
|
@ -231,7 +231,7 @@ pub trait PlatformWindow {
|
|||
/// Returns the amount of time that has elapsed since the last redraw.
|
||||
fn elapsed(&self) -> Duration;
|
||||
/// Sets the current cursor icon to `cursor`.
|
||||
fn set_cursor_icon(&mut self, cursor: CursorIcon);
|
||||
fn set_cursor(&mut self, cursor: Cursor);
|
||||
|
||||
/// Sets the location of the cursor.
|
||||
fn set_ime_location(&self, location: Rect<Px>);
|
||||
|
|
@ -421,8 +421,8 @@ where
|
|||
self.window.set_ime_purpose(purpose);
|
||||
}
|
||||
|
||||
fn set_cursor_icon(&mut self, cursor: CursorIcon) {
|
||||
self.window.set_cursor_icon(cursor);
|
||||
fn set_cursor(&mut self, cursor: Cursor) {
|
||||
self.window.set_cursor(cursor);
|
||||
}
|
||||
|
||||
fn set_min_inner_size(&self, min_size: Option<Size<UPx>>) {
|
||||
|
|
@ -672,8 +672,8 @@ where
|
|||
{
|
||||
fn run(self) -> crate::Result {
|
||||
initialize_tracing();
|
||||
let app = PendingApp::default();
|
||||
self.open(&app)?;
|
||||
let mut app = PendingApp::default();
|
||||
self.open(&mut app)?;
|
||||
app.run()
|
||||
}
|
||||
}
|
||||
|
|
@ -682,7 +682,7 @@ impl<Behavior> Open for Window<Behavior>
|
|||
where
|
||||
Behavior: WindowBehavior,
|
||||
{
|
||||
fn open<App>(self, app: &App) -> crate::Result<Option<WindowHandle>>
|
||||
fn open<App>(self, app: &mut App) -> crate::Result<Option<WindowHandle>>
|
||||
where
|
||||
App: Application + ?Sized,
|
||||
{
|
||||
|
|
@ -718,8 +718,8 @@ where
|
|||
Ok(handle.map(|handle| self.pending.opened(handle)))
|
||||
}
|
||||
|
||||
fn run_in(self, app: PendingApp) -> crate::Result {
|
||||
self.open(&app)?;
|
||||
fn run_in(self, mut app: PendingApp) -> crate::Result {
|
||||
self.open(&mut app)?;
|
||||
app.run()
|
||||
}
|
||||
}
|
||||
|
|
@ -2351,8 +2351,8 @@ pub struct VirtualState {
|
|||
pub modifiers: Modifiers,
|
||||
/// The amount of time elapsed since the last redraw call.
|
||||
pub elapsed: Duration,
|
||||
/// The currently set cursor icon.
|
||||
pub cursor: CursorIcon,
|
||||
/// The currently set cursor.
|
||||
pub cursor: Cursor,
|
||||
/// The inner size of the virtual window.
|
||||
pub size: Size<UPx>,
|
||||
}
|
||||
|
|
@ -2364,7 +2364,7 @@ impl VirtualState {
|
|||
closed: false,
|
||||
modifiers: Modifiers::default(),
|
||||
elapsed: Duration::ZERO,
|
||||
cursor: CursorIcon::default(),
|
||||
cursor: Cursor::default(),
|
||||
size: Size::new(UPx::new(800), UPx::new(600)),
|
||||
}
|
||||
}
|
||||
|
|
@ -2440,7 +2440,7 @@ impl PlatformWindowImplementation for &mut VirtualState {
|
|||
self.elapsed
|
||||
}
|
||||
|
||||
fn set_cursor_icon(&mut self, cursor: CursorIcon) {
|
||||
fn set_cursor(&mut self, cursor: Cursor) {
|
||||
self.cursor = cursor;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue