This commit is contained in:
Tsuki 2024-11-13 00:30:32 +08:00
parent 61930aeb02
commit 1051df0c17
17 changed files with 612 additions and 65 deletions

287
Cargo.lock generated
View File

@ -132,6 +132,12 @@ dependencies = [
"syn 1.0.109", "syn 1.0.109",
] ]
[[package]]
name = "ascii"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.4.0" version = "1.4.0"
@ -171,6 +177,12 @@ 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 = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
version = "0.10.4" version = "0.10.4"
@ -233,6 +245,36 @@ dependencies = [
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
[[package]]
name = "cocoa"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c"
dependencies = [
"bitflags 1.3.2",
"block",
"cocoa-foundation",
"core-foundation",
"core-graphics",
"foreign-types",
"libc",
"objc",
]
[[package]]
name = "cocoa-foundation"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7"
dependencies = [
"bitflags 1.3.2",
"block",
"core-foundation",
"core-graphics-types",
"libc",
"objc",
]
[[package]] [[package]]
name = "const_panic" name = "const_panic"
version = "0.2.10" version = "0.2.10"
@ -248,12 +290,46 @@ dependencies = [
"unicode-segmentation", "unicode-segmentation",
] ]
[[package]]
name = "core-foundation"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.7" version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "core-graphics"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"core-graphics-types",
"foreign-types",
"libc",
]
[[package]]
name = "core-graphics-types"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"libc",
]
[[package]] [[package]]
name = "core_extensions" name = "core_extensions"
version = "1.5.3" version = "1.5.3"
@ -366,6 +442,16 @@ dependencies = [
"dirs-sys", "dirs-sys",
] ]
[[package]]
name = "dirs-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
dependencies = [
"cfg-if",
"dirs-sys-next",
]
[[package]] [[package]]
name = "dirs-sys" name = "dirs-sys"
version = "0.4.1" version = "0.4.1"
@ -378,6 +464,17 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]] [[package]]
name = "either" name = "either"
version = "1.13.0" version = "1.13.0"
@ -390,6 +487,16 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "fdeflate" name = "fdeflate"
version = "0.3.6" version = "0.3.6"
@ -415,6 +522,33 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
[[package]]
name = "foreign-types"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
dependencies = [
"foreign-types-macros",
"foreign-types-shared",
]
[[package]]
name = "foreign-types-macros"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]]
name = "foreign-types-shared"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.31" version = "0.3.31"
@ -579,6 +713,15 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45b9886063966a0bf54a7cdb2d1b772025a2d37127669d94f9845ee4eff296fa" checksum = "45b9886063966a0bf54a7cdb2d1b772025a2d37127669d94f9845ee4eff296fa"
[[package]]
name = "home"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
dependencies = [
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "iana-time-zone" name = "iana-time-zone"
version = "0.1.61" version = "0.1.61"
@ -618,6 +761,15 @@ dependencies = [
"hashbrown 0.15.1", "hashbrown 0.15.1",
] ]
[[package]]
name = "itertools"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
dependencies = [
"either",
]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.11" version = "1.0.11"
@ -685,6 +837,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "linux-raw-sys"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.12" version = "0.4.12"
@ -969,6 +1127,15 @@ dependencies = [
"makepad-zune-inflate", "makepad-zune-inflate",
] ]
[[package]]
name = "malloc_buf"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "matrixmultiply" name = "matrixmultiply"
version = "0.3.9" version = "0.3.9"
@ -985,6 +1152,12 @@ version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.8.0" version = "0.8.0"
@ -1015,6 +1188,7 @@ dependencies = [
"log", "log",
"makepad-widgets", "makepad-widgets",
"mp_core", "mp_core",
"native-dialog",
"once_cell", "once_cell",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
@ -1090,6 +1264,29 @@ dependencies = [
"libloading 0.8.5", "libloading 0.8.5",
] ]
[[package]]
name = "native-dialog"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84e7038885d2aeab236bd60da9e159a5967b47cde3292da3b15ff1bec27c039f"
dependencies = [
"ascii",
"block",
"cocoa",
"core-foundation",
"dirs-next",
"objc",
"objc-foundation",
"objc_id",
"once_cell",
"raw-window-handle",
"thiserror",
"versions",
"wfd",
"which",
"winapi",
]
[[package]] [[package]]
name = "ndarray" name = "ndarray"
version = "0.16.1" version = "0.16.1"
@ -1106,6 +1303,16 @@ dependencies = [
"rayon", "rayon",
] ]
[[package]]
name = "nom"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]] [[package]]
name = "nu-ansi-term" name = "nu-ansi-term"
version = "0.46.0" version = "0.46.0"
@ -1143,6 +1350,35 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
"malloc_buf",
]
[[package]]
name = "objc-foundation"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
dependencies = [
"block",
"objc",
"objc_id",
]
[[package]]
name = "objc_id"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b"
dependencies = [
"objc",
]
[[package]] [[package]]
name = "object" name = "object"
version = "0.36.5" version = "0.36.5"
@ -1288,6 +1524,12 @@ dependencies = [
"abi_stable", "abi_stable",
] ]
[[package]]
name = "raw-window-handle"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
[[package]] [[package]]
name = "rawpointer" name = "rawpointer"
version = "0.2.1" version = "0.2.1"
@ -1450,6 +1692,19 @@ dependencies = [
"semver", "semver",
] ]
[[package]]
name = "rustix"
version = "0.38.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0"
dependencies = [
"bitflags 2.6.0",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.18" version = "1.0.18"
@ -1936,6 +2191,16 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "versions"
version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c73a36bc44e3039f51fbee93e39f41225f6b17b380eb70cc2aab942df06b34dd"
dependencies = [
"itertools",
"nom",
]
[[package]] [[package]]
name = "walkdir" name = "walkdir"
version = "2.5.0" version = "2.5.0"
@ -2007,6 +2272,28 @@ version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
[[package]]
name = "wfd"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e713040b67aae5bf1a0ae3e1ebba8cc29ab2b90da9aa1bff6e09031a8a41d7a8"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "which"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
dependencies = [
"either",
"home",
"once_cell",
"rustix",
]
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"

View File

@ -205,6 +205,10 @@ impl DataLoaderPlugin for ETWSLoader {
RResult::from(c) RResult::from(c)
} }
fn supported_extensions(&self) -> RVec<RStr<'static>> where {
convert_iter_to_rvec(vec!["dat".into(), "gz".into()].into_iter())
}
fn plugin_info(&self) -> radarg_plugin_interface::PluginInfo where { fn plugin_info(&self) -> radarg_plugin_interface::PluginInfo where {
radarg_plugin_interface::PluginInfo { radarg_plugin_interface::PluginInfo {
plugin_type: "DataLoader".into(), plugin_type: "DataLoader".into(),

View File

@ -9,6 +9,7 @@ glam = "0.29.2"
log = "0.4.22" log = "0.4.22"
makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "rik", version = "0.6.0" } makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "rik", version = "0.6.0" }
mp_core = { path = "../mp_core", version = "*" } mp_core = { path = "../mp_core", version = "*" }
native-dialog = "0.7.0"
once_cell = "1.20.2" once_cell = "1.20.2"
tracing = "0.1.40" tracing = "0.1.40"
tracing-subscriber = "0.3.18" tracing-subscriber = "0.3.18"

View File

@ -1,6 +1,8 @@
use makepad_widgets::makepad_micro_serde::*; use makepad_widgets::makepad_micro_serde::*;
use makepad_widgets::*; use makepad_widgets::*;
use crate::{DATAPOOL, PLUGIN_MANAGER};
live_design! { live_design! {
import makepad_widgets::base::*; import makepad_widgets::base::*;
import makepad_widgets::theme_desktop_dark::*; import makepad_widgets::theme_desktop_dark::*;
@ -19,7 +21,32 @@ live_design! {
return mix(#7,#4,self.pos.y); return mix(#7,#4,self.pos.y);
} }
}, },
body = <MainView>{} body = {
flow: Overlay
padding: 0.
spacing: 0.
modal = <Modal> {
content: {
height: 100,
width: 150,
show_bg: true,
draw_bg: {
color: #3c3c3c
}
align: {
x: 0.5,
y: 0.5
}
<Label> {
text: "Content in the modal"
}
}
}
<MainView>{}
}
} }
} }
} }
@ -35,7 +62,6 @@ pub struct App {
impl LiveRegister for App { impl LiveRegister for App {
fn live_register(_cx: &mut Cx) { fn live_register(_cx: &mut Cx) {
crate::makepad_widgets::live_design(_cx); crate::makepad_widgets::live_design(_cx);
// crate::makepad_widgets::base::live_design(_cx);
crate::app_ui::live_design(_cx); crate::app_ui::live_design(_cx);
crate::widgets::area::live_design(_cx); crate::widgets::area::live_design(_cx);
} }
@ -46,7 +72,27 @@ struct AppStateRon {
slide: usize, slide: usize,
} }
impl MatchEvent for App {} impl MatchEvent for App {
fn handle_actions(&mut self, cx: &mut Cx, actions: &Actions) {
use native_dialog::FileDialog;
let ui = self.ui.clone();
if ui.button(id!(open_modal)).clicked(&actions) {
let supported_extensions = PLUGIN_MANAGER.supported_extensions();
// let file = FileDialog::new()
// .add_filter("Supported files", &supported_extensions)
// .show_open_single_file()
// .unwrap();
// if let Some(file) = file {
// if let Ok(d) = DATAPOOL.get_or_load(file) {}
// }
ui.modal(id!(modal)).open(cx);
// ui.popup_notification(id!(test_noti)).open(cx);
}
}
}
impl AppMain for App { impl AppMain for App {
fn handle_event(&mut self, cx: &mut Cx, event: &Event) { fn handle_event(&mut self, cx: &mut Cx, event: &Event) {

View File

@ -20,12 +20,21 @@ live_design! {
} }
} }
MainView = <View> { Alert = <View> {
flow:Down,
padding: 10.
height: Fit
width: Fit
draw_bg: {
fn pixel(self) -> vec4 {
return mix(#7,#4,self.pos.y);
}
}
}
flow: Overlay, MainView = <View> {
width: Fill, width: Fill,
height: Fill height: Fill
dock = <Dock> { dock = <Dock> {
height: Fill, width: Fill height: Fill, width: Fill
@ -53,23 +62,23 @@ live_design! {
draw: { draw: {
// this example shader is ported from kishimisu's tutorial // this example shader is ported from kishimisu's tutorial
fn pixel(self) -> vec4 { fn pixel(self) -> vec4 {
let uv = self.pos - 0.5; // let uv = self.pos - 0.5;
let uv0 = uv; // let uv0 = uv;
let finalColor = vec3(0.0); // let finalColor = vec3(0.0);
let i = 0; // let i = 0;
for _i in 0..4 { // you cannot refer to _i inside the for loop; use i instead // for _i in 0..4 { // you cannot refer to _i inside the for loop; use i instead
uv = fract(uv * -1.5) - 0.5; // uv = fract(uv * -1.5) - 0.5;
let d = length(uv) * exp(-length(uv0)); // let d = length(uv) * exp(-length(uv0));
let col = Pal::iq2(length(uv0) + float(i) * .4 + self.time * .4); // let col = Pal::iq2(length(uv0) + float(i) * .4 + self.time * .4);
d = sin(d*8. + self.time) / 8.; // d = sin(d*8. + self.time) / 8.;
d = abs(d); // d = abs(d);
d = pow(0.01 / d, 1.2); // d = pow(0.01 / d, 1.2);
finalColor += col * d; // finalColor += col * d;
i = i+1; // i = i+1;
} // }
return vec4(finalColor ,1); // return vec4(finalColor ,1);
} }
} }
@ -116,7 +125,7 @@ live_design! {
slider_type: Horizontal slider_type: Horizontal
}, },
} }
<Button> { open_modal = <Button> {
text: "Click me" text: "Click me"
width: Fill width: Fill
} }
@ -158,6 +167,8 @@ live_design! {
<Text> {text: "Text Flow"} <Text> {text: "Text Flow"}
} }
} }
@ -165,6 +176,6 @@ live_design! {
} }
} };
} }

78
mp/src/elements/mod.rs Normal file
View File

@ -0,0 +1,78 @@
pub mod ppi;
use std::any::{Any, TypeId};
use crate::render::data::Data;
use makepad_widgets::Cx;
macro_rules! impl_element {
($($module: ty,) +) => {
impl Ele {
pub fn bake(&self, cx: &mut Cx, data: &dyn Any) -> Data {
let type_id = self.1;
match type_id {
$(
id if id == TypeId::of::<$module>() => {
let ele = self.downcast_ref::<$module>();
ele.bake(cx, data.downcast_ref::<<$module as Element>::InputData>().unwrap())
}
) +
_ => panic!("Unknown element type"),
}
}
pub fn supported(data: &dyn Any) -> Vec<Ele> {
let mut supported = Vec::new();
$(
if let Some(data) = data.downcast_ref::<<$module as Element>::InputData>() {
if <$module as Element>::supported(data) {
supported.push(Ele::new(<$module>::new()));
}
}
) +
supported
}
}
};
}
pub trait Element: Sized {
type Shader;
type InputData;
fn bake(&self, cx: &mut Cx, data: &Self::InputData) -> Data;
fn supported(data: &Self::InputData) -> bool;
}
pub struct Ele(Box<dyn Any>, TypeId);
impl<T> From<T> for Ele
where
T: Element + 'static,
{
fn from(value: T) -> Self {
Ele::new(value)
}
}
impl Ele {
pub fn new<T: Element + 'static>(ele: T) -> Self {
Ele(Box::new(ele), TypeId::of::<T>())
}
pub fn downcast_ref<'a, T: Element + 'static>(&'a self) -> &'a T {
self.0.downcast_ref().unwrap()
}
pub fn downcast_mut<'a, T: Element + 'static>(&'a mut self) -> &'a mut T {
self.0.downcast_mut().unwrap()
}
}
impl_element!(ppi::PPI,);

26
mp/src/elements/ppi.rs Normal file
View File

@ -0,0 +1,26 @@
use crate::render::data::GridData;
use crate::shaders::ppi::PPI as Shader;
use makepad_widgets::Cx;
use mp_core::RadarGridData;
pub struct PPI {}
impl PPI {
pub fn new() -> Self {
Self {}
}
}
impl super::Element for PPI {
type Shader = Shader;
type InputData = RadarGridData;
fn bake(&self, cx: &mut Cx, data: &Self::InputData) -> crate::render::data::Data {
let mut _data = GridData::new(cx);
_data.update(cx, data);
_data.into()
}
fn supported(data: &Self::InputData) -> bool {
true
}
}

View File

@ -3,7 +3,24 @@ pub use makepad_widgets;
pub use makepad_widgets::makepad_draw; pub use makepad_widgets::makepad_draw;
pub use makepad_widgets::makepad_platform; pub use makepad_widgets::makepad_platform;
pub mod app_ui; pub mod app_ui;
pub mod elements;
pub mod render;
pub mod shaders; pub mod shaders;
pub mod widgets; pub mod widgets;
pub mod render; use mp_core::{config::Setting, datapool::DataPool, plugin_system::PluginManager};
use once_cell::sync::Lazy;
use std::env;
pub static CONFIG: Lazy<Setting> = Lazy::new(|| Setting::new());
pub static PLUGIN_MANAGER: Lazy<PluginManager> = Lazy::new(|| {
PluginManager::new(
env::current_dir().unwrap().join(
(CONFIG.common.plugins)
.as_ref()
.unwrap_or(&"loaders".into()),
),
)
.unwrap()
});
pub static DATAPOOL: Lazy<DataPool> = Lazy::new(|| DataPool::new(&PLUGIN_MANAGER, 10));

View File

@ -1,23 +1,8 @@
use log::*; use log::*;
use mp_core::{config::Setting, datapool::DataPool, plugin_system::PluginManager}; use mp::{CONFIG, DATAPOOL};
use once_cell::sync::Lazy;
use std::env; use std::env;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
static CONFIG: Lazy<Setting> = Lazy::new(|| Setting::new());
static PLUGIN_MANAGER: Lazy<PluginManager> = Lazy::new(|| {
PluginManager::new(
env::current_dir().unwrap().join(
(CONFIG.common.plugins)
.as_ref()
.unwrap_or(&"loaders".into()),
),
)
.unwrap()
});
static DATAPOOL: Lazy<DataPool> = Lazy::new(|| DataPool::new(&PLUGIN_MANAGER, 10));
// static DATA_POOL: Lazy<DataPool> = Lazy::new(|| Data);
fn main() { fn main() {
// Init logger // Init logger
// Logger Filter // Logger Filter

View File

@ -1,5 +1,9 @@
use makepad_widgets::{Cx, Texture, TextureFormat}; use makepad_widgets::{Cx, Texture, TextureFormat};
use mp_core::data::RadarGridData; use mp_core::data::RadarGridData;
pub enum Data {
GridData(GridData),
}
pub struct GridData { pub struct GridData {
texture: Texture, texture: Texture,
clear_buffer: bool, clear_buffer: bool,
@ -8,7 +12,8 @@ pub struct GridData {
impl GridData { impl GridData {
pub fn new(cx: &mut Cx) -> Self { pub fn new(cx: &mut Cx) -> Self {
let texture = Texture::new_with_format(cx, TextureFormat::Unknown); let mut texture = Texture::new_with_format(cx, TextureFormat::Unknown);
GridData { GridData {
texture, texture,
clear_buffer: true, clear_buffer: true,
@ -31,3 +36,9 @@ impl GridData {
&self.texture &self.texture
} }
} }
impl From<GridData> for Data {
fn from(data: GridData) -> Self {
Data::GridData(data)
}
}

View File

@ -1,2 +1,2 @@
pub mod camera; pub mod camera;
pub mod grid_data; pub mod data;

View File

@ -0,0 +1,63 @@
use crate::render::data::GridData;
use makepad_widgets::*;
live_design! {
ColorMap = {{ColorMap}} {
// Cameras
uniform view: mat4
uniform projection: mat4
uniform model: mat4
uniform conf: vec4
varing value: float
varing range: vec4
// Data
texture data: texture3d
// ColorMAPPER
textrue color_map: texture1d
fn get_value_at(self, pos: vec3) -> float {
return sampler3d_rt(self.data, pos).r;
}
fn vertex(self) -> vec4 {
let v = sampler2d_rt(self.data, )
}
fn pixel(self) -> vec4 {
return vec4(1., 0., 0., 1.);
}
}
}
#[repr(C)]
#[derive(Live, LiveRegister)]
pub struct ColorMap {
#[deref]
draw_vars: DrawVars,
#[live]
geometry: GeometryQuad2D,
#[calc]
pub position: Vec3,
#[calc]
pub value: f32,
}
impl LiveHook for ColorMap {
fn before_apply(&mut self, cx: &mut Cx, apply: &mut Apply, index: usize, nodes: &[LiveNode]) {
self.draw_vars
.before_apply_init_shader(cx, apply, index, nodes, &self.geometry);
}
fn after_apply(&mut self, cx: &mut Cx, apply: &mut Apply, index: usize, nodes: &[LiveNode]) {
self.draw_vars
.after_apply_update_self(cx, apply, index, nodes, &self.geometry);
}
}
impl ColorMap {}

View File

@ -1 +1,2 @@
pub mod colormap;
pub mod ppi; pub mod ppi;

View File

@ -1,27 +1,33 @@
use crate::render::grid_data::GridData; use crate::render::camera::Camera;
use crate::render::data::GridData;
use makepad_widgets::*; use makepad_widgets::*;
live_design! { live_design! {
PPI = {{PPI}} { PPI = {{PPI}} {
uniform three_d: int // Cameras
// uniform view: mat4
uniform projection: mat4
uniform model: mat4
uniform conf: vec4 uniform conf: vec4
varing pos: vec4
varing value: float
varing range: vec4
// Data // Data
texture data: texture3d texture data: texture2d
// ColorMAPPER // ColorMAPPER
textrue color_map: texture1d textrue color_map: texture2d
fn get_value_at(self, pos: vec3) -> float {
return sampler3d(self.data, pos).r;
}
fn vertex(self) -> vec4 { fn vertex(self) -> vec4 {
let v = sampler2d_rt(self.data, )
if (three_d == 1) {
return vec4(self.position,)
} else {
return vec4(self.position, 1.0);
}
} }
fn pixel(self) -> vec4 { fn pixel(self) -> vec4 {
@ -57,7 +63,7 @@ impl LiveHook for PPI {
} }
impl PPI { impl PPI {
pub fn update_draw_call_vars(&mut self, data: &GridData) { pub fn update_draw_call_vars(&mut self, camera: &Camera, data: &GridData) {
self.draw_vars.texture_slots[0] = Some(data.texture().clone()); self.draw_vars.texture_slots[0] = Some(data.texture().clone());
} }
} }

View File

@ -17,14 +17,14 @@ pub struct TArea {
layout: Layout, layout: Layout,
#[live] #[live]
time: f32, time: f32,
#[rust] // #[rust]
next_frame: NextFrame, // next_frame: NextFrame,
} }
impl LiveHook for TArea { impl LiveHook for TArea {
fn after_new_from_doc(&mut self, cx: &mut Cx) { fn after_new_from_doc(&mut self, cx: &mut Cx) {
// starts the animation cycle on startup // starts the animation cycle on startup
self.next_frame = cx.new_next_frame(); // self.next_frame = cx.new_next_frame();
} }
} }
@ -35,13 +35,13 @@ pub enum MyWidgetAction {
impl Widget for TArea { impl Widget for TArea {
fn handle_event(&mut self, cx: &mut Cx, event: &Event, _scope: &mut Scope) { fn handle_event(&mut self, cx: &mut Cx, event: &Event, _scope: &mut Scope) {
if let Some(ne) = self.next_frame.is_event(event) { // if let Some(ne) = self.next_frame.is_event(event) {
// update time to use for animation // // update time to use for animation
self.time = (ne.time * 0.001).fract() as f32; // self.time = (ne.time * 0.001).fract() as f32;
// force updates, so that we can animate in the absence of user-generated events // // force updates, so that we can animate in the absence of user-generated events
self.redraw(cx); // self.redraw(cx);
self.next_frame = cx.new_next_frame(); // self.next_frame = cx.new_next_frame();
} // }
} }
fn draw_walk(&mut self, cx: &mut Cx2d, _scope: &mut Scope, walk: Walk) -> DrawStep { fn draw_walk(&mut self, cx: &mut Cx2d, _scope: &mut Scope, walk: Walk) -> DrawStep {

View File

@ -108,4 +108,14 @@ impl PluginManager {
} }
Err(DataError::FormatError) Err(DataError::FormatError)
} }
pub fn supported_extensions(&self) -> Vec<&str> {
let strs = self
.registered_plugins
.values()
.flat_map(|p| p.supported_extensions())
.collect::<Vec<_>>();
strs.into_iter().map(|s| s.as_str()).collect()
}
} }

View File

@ -106,6 +106,7 @@ pub type PluginType = DataLoaderPlugin_TO<'static, RBox<()>>;
#[sabi_trait] #[sabi_trait]
pub trait DataLoaderPlugin: Send + Sync { pub trait DataLoaderPlugin: Send + Sync {
fn load(&self, path: RStr<'_>) -> RResult<RVec<LoadedData>, Error>; fn load(&self, path: RStr<'_>) -> RResult<RVec<LoadedData>, Error>;
fn supported_extensions(&self) -> RVec<RStr<'static>>;
fn plugin_id(&self) -> &PluginId; fn plugin_id(&self) -> &PluginId;
fn plugin_info(&self) -> PluginInfo; fn plugin_info(&self) -> PluginInfo;
} }