use egui_pop_api::{Ctx, Plugin, PluginError};
use egui_pop_model::ids::PluginId;
use egui_pop_model::mount::{HostOffer, Mountable, page};
pub fn components() -> Vec<Mountable> {
let mut out = crates();
out.extend(egui_pop_api::mounts::components());
out
}
fn crates() -> Vec<Mountable> {
#[allow(
unused_mut,
reason = "without the component features nothing is added to it"
)]
let mut out = Vec::new();
#[cfg(feature = "viewport")]
out.extend(egui_pop_viewport::mounts::components());
#[cfg(feature = "views")]
out.extend(egui_pop_views::mounts::components());
#[cfg(feature = "editors")]
out.extend(egui_pop_editors::mounts::components());
out
}
pub fn hosts() -> Vec<HostOffer> {
#[allow(
unused_mut,
reason = "without the component features nothing is added to it"
)]
let mut out = egui_pop_api::mounts::hosts();
#[cfg(feature = "viewport")]
{
let at = out
.iter()
.position(|h| h.id == egui_pop_api::mounts::STORY)
.unwrap_or(out.len());
out.insert(at, egui_pop_viewport::mounts::overlay_host());
}
out
}
pub fn page() -> String {
page::render(&components(), &hosts())
}
#[derive(Debug, Default)]
pub struct MountsPlugin;
impl Plugin for MountsPlugin {
fn id(&self) -> PluginId {
PluginId::from_static("egui_pop.mounts")
}
fn title(&self) -> String {
"Mount declarations".into()
}
fn connect(&mut self, ctx: &mut Ctx<'_>) -> Result<(), PluginError> {
for m in crates() {
ctx.mountable(m);
}
#[cfg(feature = "viewport")]
ctx.host_offer(egui_pop_viewport::mounts::overlay_host());
Ok(())
}
}