start building ui + optimize build time for debug
This commit is contained in:
parent
de45368463
commit
b448c40e54
243
Cargo.lock
generated
243
Cargo.lock
generated
@ -1363,6 +1363,17 @@ version = "3.16.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "buns"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "75f1d46ab84e22a81b97efa9ee5f22a3f3508edf23a0203904f213b4faf32fe2"
|
||||||
|
dependencies = [
|
||||||
|
"deki_proc",
|
||||||
|
"extension-traits",
|
||||||
|
"maflow",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytemuck"
|
name = "bytemuck"
|
||||||
version = "1.20.0"
|
version = "1.20.0"
|
||||||
@ -1615,6 +1626,15 @@ dependencies = [
|
|||||||
"const_soft_float",
|
"const_soft_float",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "convert_case"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-segmentation",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation"
|
name = "core-foundation"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
@ -1810,6 +1830,77 @@ version = "2.6.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2"
|
checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deki"
|
||||||
|
version = "0.2.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d99371f8ebec1287967d7316c45cc22490db154e695c40dc697640f5ad07a221"
|
||||||
|
dependencies = [
|
||||||
|
"deki_core",
|
||||||
|
"deki_derive",
|
||||||
|
"deki_lerp",
|
||||||
|
"deki_macros",
|
||||||
|
"deki_proc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deki_core"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6b95a4595bf7b9f83a550c7f3daee5fa03ab7113f8ac9db49cbe91f282089c3a"
|
||||||
|
dependencies = [
|
||||||
|
"buns",
|
||||||
|
"derive-new",
|
||||||
|
"derive_more",
|
||||||
|
"extension-traits",
|
||||||
|
"fastapprox",
|
||||||
|
"fastrand",
|
||||||
|
"maflow",
|
||||||
|
"type_cell",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deki_derive"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7812924b99c75f34230c3cff26a07e0d4253f56b84865d5e3f3750ff0dcb1db6"
|
||||||
|
dependencies = [
|
||||||
|
"derive_preset",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deki_lerp"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b64245eb17aca538ee0fb665909b324eb9219f6df57b029af5c1c53aaada0be5"
|
||||||
|
dependencies = [
|
||||||
|
"deki_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deki_macros"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "058a36abf7e6c386334e058279c3aecc80bb8bd56f4254837d0f9c4eeafaaaa4"
|
||||||
|
dependencies = [
|
||||||
|
"deki_core",
|
||||||
|
"deki_proc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deki_proc"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "47ae1da716b4b85978363cefa6963d63d0896ce9e4295b12c4a1636ad264dee3"
|
||||||
|
dependencies = [
|
||||||
|
"convert_case",
|
||||||
|
"extension-traits",
|
||||||
|
"maflow",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.90",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "delaunator"
|
name = "delaunator"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
@ -1819,6 +1910,17 @@ dependencies = [
|
|||||||
"robust",
|
"robust",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "derive-new"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2cdc8d50f426189eef89dac62fabfa0abb27d5cc008f25bf4156a0203325becc"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.90",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive_more"
|
name = "derive_more"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
@ -1834,12 +1936,23 @@ version = "1.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
|
checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"convert_case",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.90",
|
"syn 2.0.90",
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "derive_preset"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c676aecfc734fb672c8bf150b6984da6397d05a269a6bbe7308d6ddc91edf7e"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dispatch"
|
name = "dispatch"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@ -2056,6 +2169,41 @@ dependencies = [
|
|||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ext-trait"
|
||||||
|
version = "2.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "703090345f7d5de48379b391c9dfe69967a3c1694730a3e53bf4c905f71069c0"
|
||||||
|
dependencies = [
|
||||||
|
"ext-trait-proc_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ext-trait-proc_macros"
|
||||||
|
version = "2.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd9f3f15f123dee4e8a6b14f033ba22904a48c5935505dc07225ce440e640d8b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 1.0.109",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "extension-traits"
|
||||||
|
version = "2.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "360cbc11ebc403c8ebb731dfb4d3950835d40d3d9a20f0e89a27b17e991d0863"
|
||||||
|
dependencies = [
|
||||||
|
"ext-trait",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastapprox"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9dfa3c0fd35278e839805680f4c2f673ca71eb91068115b4a611e71429bc0c46"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.3.0"
|
version = "2.3.0"
|
||||||
@ -2150,6 +2298,7 @@ dependencies = [
|
|||||||
"console_log",
|
"console_log",
|
||||||
"getrandom",
|
"getrandom",
|
||||||
"log",
|
"log",
|
||||||
|
"mevy",
|
||||||
"noise",
|
"noise",
|
||||||
"rand",
|
"rand",
|
||||||
"voronoice",
|
"voronoice",
|
||||||
@ -2759,6 +2908,12 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "maflow"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "102d5acb8c2bd7b07a6e5cd3b7f73bc5cd401a96d8f78df86464afa62b962fde"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "malloc_buf"
|
name = "malloc_buf"
|
||||||
version = "0.0.6"
|
version = "0.0.6"
|
||||||
@ -2807,6 +2962,84 @@ dependencies = [
|
|||||||
"paste",
|
"paste",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mevy"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8802cdd2c9767abb83234d4b016917ab08cdb7fdae97a3a3e0a28a5f80febbd5"
|
||||||
|
dependencies = [
|
||||||
|
"mevy_core",
|
||||||
|
"mevy_ecs",
|
||||||
|
"mevy_ui",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mevy_core"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a388e5018afe90d85cd6e925a8c99a361e503b07aae760d70a432bdd1ab86172"
|
||||||
|
dependencies = [
|
||||||
|
"deki",
|
||||||
|
"mevy_core_syntax 0.1.1",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mevy_core_syntax"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2bece892cccb973e88cd8c4b686e2525a6f2a5e839e0870ac00e3d8fdd952e0e"
|
||||||
|
dependencies = [
|
||||||
|
"deki",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mevy_core_syntax"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4915267a4ed798a3e9ef2fd1fff1b2cb5d1f356c5d131036e0ecddeae15ee267"
|
||||||
|
dependencies = [
|
||||||
|
"deki",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mevy_ecs"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "407781ab6299ae18ebb9734a4db17ec6a865a31e196c2af926d16e552410f76f"
|
||||||
|
dependencies = [
|
||||||
|
"mevy_ecs_syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mevy_ecs_syntax"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be2b6d34fd01773ec549d05350d66141e8e2651f5123c41f8828306c8121f6e3"
|
||||||
|
dependencies = [
|
||||||
|
"deki",
|
||||||
|
"mevy_core_syntax 0.2.2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mevy_ui"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bcea8c31c0895195aeb830b0edd650d7d0af71bec43721a9ace7723fed3b693c"
|
||||||
|
dependencies = [
|
||||||
|
"deki",
|
||||||
|
"mevy_ui_syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mevy_ui_syntax"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a4cb9b2bb1c24ff7b13aecf3003849b6d6d3f4593b1ef321a8708ed431518d2a"
|
||||||
|
dependencies = [
|
||||||
|
"deki",
|
||||||
|
"mevy_core_syntax 0.2.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "minimal-lexical"
|
name = "minimal-lexical"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
@ -4240,6 +4473,16 @@ version = "0.24.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5be21190ff5d38e8b4a2d3b6a3ae57f612cc39c96e83cedeaf7abc338a8bac4a"
|
checksum = "5be21190ff5d38e8b4a2d3b6a3ae57f612cc39c96e83cedeaf7abc338a8bac4a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "type_cell"
|
||||||
|
version = "0.3.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f6d985656e9b8900f54ed89cce2fccf14f6c1e079f1a519635a3ba3c4a896e1e"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"paste",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typeid"
|
name = "typeid"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
|
11
Cargo.toml
11
Cargo.toml
@ -7,9 +7,7 @@ edition = "2021"
|
|||||||
name = "forestiles"
|
name = "forestiles"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
crate-type=[
|
crate-type=[
|
||||||
"staticlib",
|
"cdylib"
|
||||||
"cdylib",
|
|
||||||
"rlib"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
@ -40,6 +38,7 @@ bevy-inspector-egui = { version = "0.28", default-features = false, features = [
|
|||||||
"bevy_render",
|
"bevy_render",
|
||||||
"egui_open_url"
|
"egui_open_url"
|
||||||
]}
|
]}
|
||||||
|
mevy = "0.1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
rand = { version = "0.8", features = ["small_rng"] }
|
rand = { version = "0.8", features = ["small_rng"] }
|
||||||
voronoice = "0.2"
|
voronoice = "0.2"
|
||||||
@ -66,11 +65,11 @@ android_logger = "0.14"
|
|||||||
opt-level = 1
|
opt-level = 1
|
||||||
|
|
||||||
# Enable a large amount of optimization in the dev profile for dependencies.
|
# Enable a large amount of optimization in the dev profile for dependencies.
|
||||||
[profile.dev.package."*"]
|
# [profile.dev.package."*"]
|
||||||
opt-level = 3
|
# opt-level = 1
|
||||||
|
|
||||||
[package.metadata.android]
|
[package.metadata.android]
|
||||||
package = "org.forestiles.example"
|
package = "org.forestiles.game"
|
||||||
apk_name = "forestiles"
|
apk_name = "forestiles"
|
||||||
strip = "strip"
|
strip = "strip"
|
||||||
# see https://github.com/rust-mobile/cargo-apk
|
# see https://github.com/rust-mobile/cargo-apk
|
||||||
|
72
src/ui.rs
72
src/ui.rs
@ -1,6 +1,6 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use mevy::*;
|
||||||
use bevy::{input::mouse::MouseWheel, math::{NormedVectorSpace, VectorSpace}, picking::{focus::HoverMap, pointer::PointerId}, prelude::*, utils::HashMap, window::PrimaryWindow};
|
use bevy::{input::mouse::MouseWheel, math::{NormedVectorSpace, VectorSpace}, picking::{focus::HoverMap, pointer::PointerId}, prelude::*, utils::{dbg, HashMap}, window::PrimaryWindow};
|
||||||
|
|
||||||
use crate::map::{self, MapMarker};
|
use crate::map::{self, MapMarker};
|
||||||
|
|
||||||
@ -12,55 +12,46 @@ impl bevy::prelude::Plugin for Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component, Debug)]
|
||||||
struct PointersDragging(HashMap<PointerId, Vec2>);
|
struct PointersDragging(HashMap<PointerId, Vec2>);
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct MapUIComponent;
|
pub struct MapUIComponent;
|
||||||
|
|
||||||
fn setup(
|
fn setup(
|
||||||
mut cmds: Commands
|
mut world: Commands
|
||||||
) {
|
) {
|
||||||
cmds.spawn((
|
spawn!{
|
||||||
Node {
|
Node {width: 100%, height: 100%, display: Display::Block, flex_direction: FlexDirection::Column, !};
|
||||||
width: Val::Percent(100.0),
|
PointersDragging(HashMap::new());
|
||||||
height: Val::Percent(100.0),
|
MapUIComponent;
|
||||||
align_items: AlignItems::Center,
|
.observe(move |trigger: Trigger<Pointer<DragStart>>, mut ptrs: Query<&mut PointersDragging>| {
|
||||||
justify_content: JustifyContent::Center,
|
if trigger.button == PointerButton::Primary {
|
||||||
..default()
|
if let Ok(mut ptrs) = ptrs.get_mut(trigger.target) {
|
||||||
},
|
ptrs.0.insert(trigger.pointer_id, trigger.pointer_location.position);
|
||||||
PickingBehavior {
|
|
||||||
should_block_lower: false,
|
|
||||||
is_hoverable: true
|
|
||||||
},
|
|
||||||
MapUIComponent,
|
|
||||||
PointersDragging(HashMap::new())
|
|
||||||
)).observe(|trigger: Trigger<Pointer<DragStart>>, mut ptrs: Query<&mut PointersDragging>| {
|
|
||||||
let event = trigger.event();
|
|
||||||
// dbg!(event);
|
|
||||||
if event.button == PointerButton::Primary {
|
|
||||||
ptrs.get_mut(event.target).unwrap().0.insert(event.pointer_id, event.pointer_location.position);
|
|
||||||
}
|
}
|
||||||
}).observe(|trigger: Trigger<Pointer<DragEnd>>, mut ptrs: Query<&mut PointersDragging>| {
|
|
||||||
let event = trigger.event();
|
|
||||||
// dbg!(event);
|
|
||||||
if event.button == PointerButton::Primary {
|
|
||||||
ptrs.get_mut(event.target).unwrap().0.remove(&event.pointer_id);
|
|
||||||
}
|
}
|
||||||
}).observe(|
|
});
|
||||||
|
.observe(move |trigger: Trigger<Pointer<DragEnd>>, mut ptrs: Query<&mut PointersDragging>| {
|
||||||
|
if trigger.button == PointerButton::Primary {
|
||||||
|
ptrs.single_mut().0.remove(&trigger.pointer_id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
.observe(|
|
||||||
trigger: Trigger<Pointer<Drag>>,
|
trigger: Trigger<Pointer<Drag>>,
|
||||||
mut ptrs: Query<&mut PointersDragging>,
|
mut ptrs: Query<&mut PointersDragging>,
|
||||||
mut cam: Query<&mut Transform, With<Camera2d>>,
|
mut cam: Query<&mut Transform, With<Camera2d>>,
|
||||||
| {
|
| {
|
||||||
let event = trigger.event();
|
if trigger.button == PointerButton::Primary {
|
||||||
// dbg!(event);
|
let mut ptrs = ptrs.single_mut();
|
||||||
if event.button == PointerButton::Primary {
|
if !ptrs.0.contains_key(&trigger.pointer_id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let mut cam = cam.single_mut();
|
let mut cam = cam.single_mut();
|
||||||
let mut ptrs = ptrs.get_mut(event.target).unwrap();
|
|
||||||
|
|
||||||
let old_midpoint = ptrs.0.values().fold(Vec2::ZERO, |acc, pos| acc + (pos/ptrs.0.len() as f32));
|
let old_midpoint = ptrs.0.values().fold(Vec2::ZERO, |acc, pos| acc + (pos/ptrs.0.len() as f32));
|
||||||
let old_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (old_midpoint-pos).norm());
|
let old_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (old_midpoint-pos).norm());
|
||||||
ptrs.0.insert(event.pointer_id, event.pointer_location.position);
|
ptrs.0.insert(trigger.pointer_id, trigger.pointer_location.position);
|
||||||
let new_midpoint = ptrs.0.values().fold(Vec2::ZERO, |acc, pos| acc + (pos/ptrs.0.len() as f32));
|
let new_midpoint = ptrs.0.values().fold(Vec2::ZERO, |acc, pos| acc + (pos/ptrs.0.len() as f32));
|
||||||
let new_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (new_midpoint-pos).norm());
|
let new_d_to_midpoint = ptrs.0.values().fold(0., |acc, pos| acc + (new_midpoint-pos).norm());
|
||||||
|
|
||||||
@ -74,6 +65,19 @@ fn setup(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
[
|
||||||
|
Node{
|
||||||
|
width:100%,
|
||||||
|
align_self: AlignSelf::FlexEnd,
|
||||||
|
!};
|
||||||
|
Button;
|
||||||
|
BorderColor(#F00);
|
||||||
|
BackgroundColor(#77767b);
|
||||||
|
[
|
||||||
|
Text::new("Button")
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
// Spawn all ui elements as children of this one
|
// Spawn all ui elements as children of this one
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user