1use egui_pop_api::{Ctx, Plugin, PluginError};
14use egui_pop_model::ids::PluginId;
15use egui_pop_model::mount::{HostOffer, Mountable, page};
16
17pub fn components() -> Vec<Mountable> {
20 let mut out = crates();
21 out.extend(egui_pop_api::mounts::components());
22 out
23}
24
25fn crates() -> Vec<Mountable> {
28 #[allow(
29 unused_mut,
30 reason = "without the component features nothing is added to it"
31 )]
32 let mut out = Vec::new();
33 #[cfg(feature = "viewport")]
34 out.extend(egui_pop_viewport::mounts::components());
35 #[cfg(feature = "views")]
36 out.extend(egui_pop_views::mounts::components());
37 #[cfg(feature = "editors")]
38 out.extend(egui_pop_editors::mounts::components());
39 out
40}
41
42pub fn hosts() -> Vec<HostOffer> {
45 #[allow(
46 unused_mut,
47 reason = "without the component features nothing is added to it"
48 )]
49 let mut out = egui_pop_api::mounts::hosts();
50 #[cfg(feature = "viewport")]
51 {
52 let at = out
53 .iter()
54 .position(|h| h.id == egui_pop_api::mounts::STORY)
55 .unwrap_or(out.len());
56 out.insert(at, egui_pop_viewport::mounts::overlay_host());
57 }
58 out
59}
60
61pub fn page() -> String {
63 page::render(&components(), &hosts())
64}
65
66#[derive(Debug, Default)]
69pub struct MountsPlugin;
70
71impl Plugin for MountsPlugin {
72 fn id(&self) -> PluginId {
73 PluginId::from_static("egui_pop.mounts")
74 }
75
76 fn title(&self) -> String {
77 "Mount declarations".into()
78 }
79
80 fn connect(&mut self, ctx: &mut Ctx<'_>) -> Result<(), PluginError> {
81 for m in crates() {
82 ctx.mountable(m);
83 }
84 #[cfg(feature = "viewport")]
85 ctx.host_offer(egui_pop_viewport::mounts::overlay_host());
86 Ok(())
87 }
88}