Files
SteamFrame-FPV-Control-Center/src/ui/cockpit.rs
T

247 lines
9.9 KiB
Rust

use super::theme::*;
use super::SteamFrameGpuiApp;
use gpui::{div, img, prelude::*, rgb, rgba, Context, IntoElement};
impl SteamFrameGpuiApp {
pub(super) fn render_cockpit_view(&self, cx: &mut Context<Self>) -> impl IntoElement {
div()
.flex()
.flex_col()
.size_full()
.min_h_0()
.min_w_0()
.relative()
.bg(rgb(0x030508))
.border_1()
.border_color(rgb(COLOR_BORDER_SUBTLE))
.rounded_xl()
.overflow_hidden()
.items_center()
.justify_center()
// 2.1 Flux Vidéo (cadrage proportionnel intégral sans rognage)
.child(if let Some(ref img_src) = self.current_render_image {
div()
.flex()
.items_center()
.justify_center()
.size_full()
.min_h_0()
.min_w_0()
.child(
img(img_src.clone())
.size_full()
.object_fit(gpui::ObjectFit::Contain),
)
} else {
div()
.flex()
.flex_col()
.items_center()
.gap_3()
.child(
div()
.text_xl()
.font_weight(gpui::FontWeight::BOLD)
.text_color(rgb(COLOR_CYAN))
.child("🥽 En attente du flux Eachine Sphere Link..."),
)
.child(
div()
.text_xs()
.text_color(rgb(COLOR_TEXT_MUTED))
.child("Réception active sur UDP 0.0.0.0:5600 (H.264 Raw direct)"),
)
.child(
div()
.flex()
.flex_wrap()
.justify_center()
.gap_2()
.pt_2()
.child(
div()
.px_3()
.py_1p5()
.bg(rgb(COLOR_SURFACE_CARD))
.border_1()
.border_color(rgb(COLOR_BORDER_SUBTLE))
.rounded_lg()
.text_xs()
.child("1. Branchez le câble USB-C OTG ou Mini-HDMI"),
)
.child(
div()
.px_3()
.py_1p5()
.bg(rgb(COLOR_SURFACE_CARD))
.border_1()
.border_color(rgb(COLOR_BORDER_SUBTLE))
.rounded_lg()
.text_xs()
.child("2. Vérifiez le canal 5.8 GHz (Canal 161)"),
),
)
})
// 2.2 Overlay Supérieur Gauche (FPS & Trames)
.child(
div()
.absolute()
.top_3()
.left_3()
.flex()
.gap_2()
.child(
div()
.px_2p5()
.py_1()
.bg(rgba(0x0a101abb))
.border_1()
.border_color(if self.video_fps > 0.1 {
rgb(COLOR_GREEN)
} else {
rgb(COLOR_ORANGE)
})
.rounded_md()
.text_xs()
.font_weight(gpui::FontWeight::BOLD)
.text_color(if self.video_fps > 0.1 {
rgb(COLOR_GREEN)
} else {
rgb(COLOR_ORANGE)
})
.child(if self.video_fps > 0.1 {
format!("{:.1} FPS", self.video_fps)
} else {
"⚠️ RECHERCHE SIGNAL".to_string()
}),
)
.child(
div()
.px_2p5()
.py_1()
.bg(rgba(0x0a101abb))
.border_1()
.border_color(rgb(COLOR_BORDER_SUBTLE))
.rounded_md()
.text_xs()
.text_color(rgb(COLOR_TEXT_MUTED))
.child(format!("{} trames", self.video_frames_total)),
),
)
// 2.3 Overlay Supérieur Droit (VR & Format)
.child(
div()
.absolute()
.top_3()
.right_3()
.flex()
.gap_2()
.child(
div()
.px_2p5()
.py_1()
.bg(rgba(0x0a101abb))
.border_1()
.border_color(rgb(COLOR_BORDER_SUBTLE))
.rounded_md()
.text_xs()
.text_color(rgb(COLOR_CYAN))
.child(format!(
"{} • {}",
self.cfg.vrx_video_profile,
self.cfg.projection_mode.to_uppercase()
)),
)
.child(
div()
.id("btn_toggle_hud")
.px_2p5()
.py_1()
.bg(rgba(0x0a101abb))
.border_1()
.border_color(rgb(COLOR_BORDER_SUBTLE))
.rounded_md()
.text_xs()
.text_color(rgb(COLOR_TEXT_MUTED))
.cursor_pointer()
.on_click(cx.listener(|this, _, _, cx| {
this.show_hud_overlay = !this.show_hud_overlay;
cx.notify();
}))
.child(if self.show_hud_overlay {
"👁️ HUD ON"
} else {
"👁️ HUD OFF"
}),
),
)
// 2.4 Bandeau Flottant Inférieur (HUD Télémetrie & Suivi Tête discret)
.child(if self.show_hud_overlay {
div()
.absolute()
.bottom_3()
.flex()
.items_center()
.gap_3()
.px_4()
.py_1p5()
.bg(rgba(0x090e18ee))
.border_1()
.border_color(rgb(COLOR_BORDER_SUBTLE))
.rounded_full()
.text_xs()
.child(
div()
.text_color(rgb(COLOR_GREEN))
.child(format!("🔋 {:.1} V", self.latest_telem.battery_voltage_v)),
)
.child(
div()
.text_color(rgb(COLOR_TEXT_MUTED))
.child("•"),
)
.child(
div()
.text_color(rgb(COLOR_CYAN))
.child(format!("📶 LQ {}%", self.latest_telem.link_quality_pct)),
)
.child(
div()
.text_color(rgb(COLOR_TEXT_MUTED))
.child("•"),
)
.child(
div()
.text_color(rgb(COLOR_TEXT_MAIN))
.child(format!(
"🚀 {:.0} km/h • ⛰️ {:.0} m",
self.latest_telem.groundspeed_ms * 3.6,
self.latest_telem.altitude_m
)),
)
.child(
div()
.text_color(rgb(COLOR_TEXT_MUTED))
.child("•"),
)
.child(
div()
.text_color(rgb(COLOR_ORANGE))
.child(format!(
"🎯 P:{:+.0}° T:{:+.0}° R:{:+.0}°",
self.latest_pose.pan_deg,
self.latest_pose.tilt_deg,
self.latest_pose.roll_deg
)),
)
.into_any_element()
} else {
div().into_any_element()
})
}
// -------------------------------------------------------------------------
// 3. Vue Réglages (Menus Déroulants & Paramètres Configurables)
// -------------------------------------------------------------------------
}