mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
1703 lines
90 KiB
Rust
1703 lines
90 KiB
Rust
use super::theme::*;
|
||
use super::{SteamFrameGpuiApp, TargetEditField};
|
||
use crate::config::{AppConfig, VehicleProfile};
|
||
use crate::controller::{ControlSource, GearSpeedLimits};
|
||
use crate::dome_projection::ProjectionMode;
|
||
use crate::dvr::{DvrContainer, DvrMode};
|
||
use crate::engine::LiveOpticalParams;
|
||
use crate::nomad_elrs::NomadHeadTracker;
|
||
use gpui::{
|
||
div, prelude::*, px, rgb, rgba, App, Context, ElementId, IntoElement, KeyDownEvent,
|
||
SharedString, Window,
|
||
};
|
||
|
||
impl SteamFrameGpuiApp {
|
||
pub(super) fn render_settings_view(&self, cx: &mut Context<Self>) -> impl IntoElement {
|
||
let profiles = VehicleProfile::list_all();
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.size_full()
|
||
.min_h_0()
|
||
.min_w_0()
|
||
.id("settings_view_scroll")
|
||
.overflow_y_scroll()
|
||
.bg(rgb(COLOR_SURFACE_CARD))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.rounded_xl()
|
||
.p_4()
|
||
.gap_4()
|
||
// Titre & En-tête
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.justify_between()
|
||
.items_center()
|
||
.gap_2()
|
||
.border_b_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.pb_3()
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_0p5()
|
||
.child(
|
||
div()
|
||
.text_base()
|
||
.font_weight(gpui::FontWeight::BOLD)
|
||
.text_color(rgb(COLOR_CYAN))
|
||
.child("⚙️ Paramètres et Réglages FPV"),
|
||
)
|
||
.child(
|
||
div()
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MUTED))
|
||
.child("Profils véhicules, batterie LiPo, VRX, Wi-Fi Nomad, projection VR et OSD (auto-sauvegardés)."),
|
||
),
|
||
)
|
||
.child(
|
||
div()
|
||
.id("btn_apply_settings")
|
||
.px_4()
|
||
.py_1p5()
|
||
.bg(rgb(COLOR_GREEN))
|
||
.text_color(rgb(0x000000))
|
||
.rounded_md()
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::BOLD)
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, cx| {
|
||
this.restart_engine_async("[Réglages] Application et redémarrage asynchrone du moteur FPV...");
|
||
cx.notify();
|
||
}))
|
||
.child("🔄 Appliquer & Redémarrer"),
|
||
),
|
||
)
|
||
// Carte Profils Véhicules & Batterie LiPo (application à chaud si désarmé)
|
||
.child(self.render_settings_card(
|
||
"🚗 Profils Véhicules & Batterie LiPo",
|
||
COLOR_GREEN,
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_2()
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.items_center()
|
||
.gap_2()
|
||
.children(profiles.into_iter().enumerate().map(|(idx, prof)| {
|
||
let is_active = self.cfg.active_profile.eq_ignore_ascii_case(&prof.name);
|
||
let label = format!("{} (V3:{})", prof.name, prof.gear_3_max);
|
||
let prof_clone = prof.clone();
|
||
self.render_selectable_pill(
|
||
SharedString::from(format!("pill_profile_{}", idx)),
|
||
&label,
|
||
is_active,
|
||
cx.listener(move |this, _, _, cx| {
|
||
match this.controls.apply_vehicle_profile(&prof_clone) {
|
||
Ok(()) => {
|
||
prof_clone.apply_to(&mut this.cfg);
|
||
this.profile_feedback = format!("Profil '{}' appliqué.", prof_clone.name);
|
||
}
|
||
Err(err) => {
|
||
this.profile_feedback = err;
|
||
}
|
||
}
|
||
cx.notify();
|
||
}),
|
||
)
|
||
}))
|
||
.child(
|
||
div()
|
||
.id("btn_save_custom_profile")
|
||
.px_2p5()
|
||
.py_1()
|
||
.rounded_md()
|
||
.bg(rgba(0x10b98122))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_GREEN))
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_GREEN))
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, cx| {
|
||
let name = if this.cfg.active_profile.trim().is_empty() {
|
||
"Custom".to_string()
|
||
} else {
|
||
this.cfg.active_profile.clone()
|
||
};
|
||
let p = VehicleProfile::from_config(name.clone(), &this.cfg);
|
||
match p.save_to_disk() {
|
||
Ok(path) => {
|
||
this.cfg.active_profile = name;
|
||
this.controls.save_full_config(&this.cfg);
|
||
this.profile_feedback = format!(
|
||
"Profil sauvegardé : {:?}",
|
||
path.file_name().unwrap_or_default()
|
||
);
|
||
}
|
||
Err(e) => {
|
||
this.profile_feedback = format!("Erreur sauvegarde : {}", e);
|
||
}
|
||
}
|
||
cx.notify();
|
||
}))
|
||
.child("💾 Sauvegarder profil"),
|
||
),
|
||
)
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.items_center()
|
||
.gap_2()
|
||
.child(
|
||
div()
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MUTED))
|
||
.child("Cellules LiPo :"),
|
||
)
|
||
.children(
|
||
[
|
||
(0u8, "Auto 2S-6S"),
|
||
(2, "2S"),
|
||
(3, "3S"),
|
||
(4, "4S"),
|
||
(5, "5S"),
|
||
(6, "6S"),
|
||
]
|
||
.into_iter()
|
||
.map(|(cells, lbl)| {
|
||
self.render_selectable_pill(
|
||
SharedString::from(format!("pill_lipo_{}s", cells)),
|
||
lbl,
|
||
self.cfg.battery_cells == cells,
|
||
cx.listener(move |this, _, _, cx| {
|
||
this.cfg.battery_cells = cells;
|
||
this.controls.set_battery_cells(cells);
|
||
cx.notify();
|
||
}),
|
||
)
|
||
}),
|
||
),
|
||
)
|
||
.when(!self.profile_feedback.is_empty(), |el| {
|
||
el.child(
|
||
div()
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_CYAN))
|
||
.child(self.profile_feedback.clone()),
|
||
)
|
||
}),
|
||
))
|
||
// Grille des réglages (Cartes thématiques)
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.flex_row()
|
||
.flex_wrap()
|
||
.gap_3()
|
||
// 3.1 Carte VRX Eachine Sphere Link
|
||
.child(self.render_settings_card(
|
||
"🔌 1. Récepteur VRX Sphere Link (Radxa Zero 3W)",
|
||
COLOR_CYAN,
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_3()
|
||
// Mode d'acquisition
|
||
.child(self.render_setting_row(
|
||
"Mode Acquisition Vidéo",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"pill_mode_rndis",
|
||
"USB OTG (RNDIS)",
|
||
self.cfg.usb_video_mode.eq_ignore_ascii_case("rndis"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.usb_video_mode = "rndis".into();
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_mode_uvc",
|
||
"Mini-HDMI (UVC)",
|
||
self.cfg.usb_video_mode.eq_ignore_ascii_case("uvc"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.usb_video_mode = "uvc".into();
|
||
cx.notify();
|
||
}),
|
||
)),
|
||
))
|
||
// Canal 5.8 GHz
|
||
.child(self.render_setting_row(
|
||
"Canal 5.8 GHz (RTL8812EU)",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_1p5()
|
||
.child(self.render_channel_button(149, 5745, cx))
|
||
.child(self.render_channel_button(153, 5765, cx))
|
||
.child(self.render_channel_button(157, 5785, cx))
|
||
.child(self.render_channel_button(161, 5805, cx)),
|
||
))
|
||
// Codec & Transport
|
||
.child(self.render_setting_row(
|
||
"Codec Décodage",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"pill_codec_h264",
|
||
"H.264 (Faible Latence)",
|
||
self.cfg.codec.eq_ignore_ascii_case("h264"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.codec = "h264".into();
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_codec_h265",
|
||
"H.265 (HEVC)",
|
||
self.cfg.codec.eq_ignore_ascii_case("h265"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.codec = "h265".into();
|
||
cx.notify();
|
||
}),
|
||
)),
|
||
))
|
||
// Actions matérielles
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.pt_2()
|
||
.child(
|
||
div()
|
||
.id("btn_rndis_setup")
|
||
.flex_1()
|
||
.py_1p5()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.rounded_md()
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, _| {
|
||
this.run_usb_rndis_setup();
|
||
}))
|
||
.child("⚡ Lancer setup_usb_rndis.sh"),
|
||
)
|
||
.child(
|
||
div()
|
||
.id("btn_ssh_setup")
|
||
.flex_1()
|
||
.py_1p5()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.rounded_md()
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, _| {
|
||
this.configure_radxa_ssh();
|
||
}))
|
||
.child("🔧 Config Canal par SSH"),
|
||
),
|
||
),
|
||
))
|
||
// 3.2 Carte Wi-Fi RadioMaster Nomad (ELRS)
|
||
.child(self.render_settings_card(
|
||
"📡 2. Suivi de Tête & Radio (Nomad ELRS)",
|
||
COLOR_ORANGE,
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_3()
|
||
.when_some(self.target_focus_handle.as_ref(), |d, fh| {
|
||
d.track_focus(fh).on_key_down(cx.listener(|this, ev: &KeyDownEvent, _, cx| {
|
||
this.handle_target_key_down(ev);
|
||
cx.notify();
|
||
}))
|
||
})
|
||
// Protocole
|
||
.child(self.render_setting_row(
|
||
"Protocole Wi-Fi",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"pill_proto_g29",
|
||
"G29 Hub ($HT)",
|
||
self.cfg.ht_protocol.eq_ignore_ascii_case("g29")
|
||
|| self.cfg.ht_protocol.eq_ignore_ascii_case("g29_bridge")
|
||
|| self.cfg.ht_protocol.eq_ignore_ascii_case("radxa"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.ht_protocol = "g29".into();
|
||
this.mock_tracker = None;
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_proto_msp",
|
||
"MSPv2 0x0383",
|
||
self.cfg.ht_protocol.eq_ignore_ascii_case("msp"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.ht_protocol = "msp".into();
|
||
this.mock_tracker = None;
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_proto_crsf",
|
||
"CRSF 0x16",
|
||
self.cfg.ht_protocol.eq_ignore_ascii_case("crsf"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.ht_protocol = "crsf".into();
|
||
this.mock_tracker = None;
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_proto_mavlink",
|
||
"MAVLink v1 (14555)",
|
||
self.cfg.ht_protocol.eq_ignore_ascii_case("mavlink"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.ht_protocol = "mavlink".into();
|
||
this.mock_tracker = None;
|
||
cx.notify();
|
||
}),
|
||
)),
|
||
))
|
||
// Cible UDP éditable (clic pour taper IP/hostname ou port)
|
||
.child(self.render_setting_row(
|
||
"Cible Réseau (clic pour éditer)",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.items_center()
|
||
.gap_1()
|
||
.child(
|
||
div()
|
||
.id("input_nomad_ip")
|
||
.px_2()
|
||
.py_1()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(if self.target_edit_field == Some(TargetEditField::Ip) {
|
||
rgb(COLOR_BORDER_ACTIVE)
|
||
} else {
|
||
rgb(COLOR_BORDER_SUBTLE)
|
||
})
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, window, cx| {
|
||
if this.target_edit_field == Some(TargetEditField::Port) {
|
||
this.commit_port_buf();
|
||
}
|
||
this.target_edit_field = Some(TargetEditField::Ip);
|
||
if let Some(fh) = &this.target_focus_handle {
|
||
window.focus(fh);
|
||
}
|
||
cx.notify();
|
||
}))
|
||
.child(if self.target_edit_field == Some(TargetEditField::Ip) {
|
||
format!("{}|", self.cfg.nomad_ip)
|
||
} else {
|
||
self.cfg.nomad_ip.clone()
|
||
}),
|
||
)
|
||
.child(div().text_xs().text_color(rgb(COLOR_TEXT_MUTED)).child(":"))
|
||
.child(
|
||
div()
|
||
.id("input_nomad_port")
|
||
.px_2()
|
||
.py_1()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(if self.target_edit_field == Some(TargetEditField::Port) {
|
||
rgb(COLOR_BORDER_ACTIVE)
|
||
} else {
|
||
rgb(COLOR_BORDER_SUBTLE)
|
||
})
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, window, cx| {
|
||
this.target_port_buf = this.cfg.nomad_port.to_string();
|
||
this.target_edit_field = Some(TargetEditField::Port);
|
||
if let Some(fh) = &this.target_focus_handle {
|
||
window.focus(fh);
|
||
}
|
||
cx.notify();
|
||
}))
|
||
.child(if self.target_edit_field == Some(TargetEditField::Port) {
|
||
format!("{}|", self.target_port_buf)
|
||
} else {
|
||
self.cfg.nomad_port.to_string()
|
||
}),
|
||
),
|
||
))
|
||
// Presets réseau rapides
|
||
.child(self.render_setting_row(
|
||
"Presets Cible",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"preset_radxa_g29_unified",
|
||
"Tout-en-un Radxa usb0 (192.168.1.1:14552)",
|
||
self.cfg.nomad_ip == "192.168.1.1" && self.cfg.nomad_port == 14552,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.set_nomad_target("192.168.1.1", 14552, Some("g29"));
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"preset_ap_default",
|
||
"AP Défaut (10.0.0.1:14550)",
|
||
self.cfg.nomad_ip == "10.0.0.1" && self.cfg.nomad_port == 14550,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.set_nomad_target("10.0.0.1", 14550, Some("msp"));
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"preset_local_bp",
|
||
"Backpack LAN (elrs_txbp.local:14555)",
|
||
self.cfg.nomad_ip == "elrs_txbp.local" && self.cfg.nomad_port == 14555,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.set_nomad_target("elrs_txbp.local", 14555, Some("mavlink"));
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"preset_localhost",
|
||
"Test Local (127.0.0.1:14550)",
|
||
self.cfg.nomad_ip == "127.0.0.1" && self.cfg.nomad_port == 14550,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.set_nomad_target("127.0.0.1", 14550, None);
|
||
cx.notify();
|
||
}),
|
||
)),
|
||
))
|
||
// Courses maximales
|
||
.child(self.render_setting_row(
|
||
"Débattements Max",
|
||
div()
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||
.child(format!(
|
||
"Pan : {}° | Tilt : {}° | Roll : {}°",
|
||
self.cfg.max_pan_deg, self.cfg.max_tilt_deg, self.cfg.max_roll_deg
|
||
)),
|
||
))
|
||
// Mock Manuel Pan/Tilt/Roll
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_2()
|
||
.p_2()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_BG_DARK))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.child(
|
||
div()
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||
.text_color(rgb(COLOR_ORANGE))
|
||
.child("🎛️ Mock Manuel (Envoi direct vers Nomad / Backpack)"),
|
||
)
|
||
.child(self.render_mock_axis_row(
|
||
"pan",
|
||
"Pan (Yaw)",
|
||
self.mock_pan_deg,
|
||
self.cfg.max_pan_deg,
|
||
cx,
|
||
))
|
||
.child(self.render_mock_axis_row(
|
||
"tilt",
|
||
"Tilt (Pitch)",
|
||
self.mock_tilt_deg,
|
||
self.cfg.max_tilt_deg,
|
||
cx,
|
||
))
|
||
.child(self.render_mock_axis_row(
|
||
"roll",
|
||
"Roll",
|
||
self.mock_roll_deg,
|
||
self.cfg.max_roll_deg,
|
||
cx,
|
||
))
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.pt_1()
|
||
.child(
|
||
div()
|
||
.id("btn_send_mock_manual")
|
||
.flex_1()
|
||
.py_1p5()
|
||
.px_2()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_ORANGE))
|
||
.rounded_md()
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, cx| {
|
||
this.send_mock_manual();
|
||
cx.notify();
|
||
}))
|
||
.child("📤 Envoyer Mock Manuel"),
|
||
)
|
||
.child(self.render_selectable_pill(
|
||
"pill_mock_continuous",
|
||
if self.mock_continuous {
|
||
"🔄 Continu 50 Hz : ON"
|
||
} else {
|
||
"🔄 Continu 50 Hz : OFF"
|
||
},
|
||
self.mock_continuous,
|
||
cx.listener(|this, _, _, cx| {
|
||
if this.target_edit_field == Some(TargetEditField::Port) {
|
||
this.commit_port_buf();
|
||
this.target_edit_field = None;
|
||
}
|
||
this.mock_continuous = !this.mock_continuous;
|
||
this.mock_last_send = None;
|
||
if this.mock_continuous && this.cfg.head_tracking_enabled {
|
||
this.cfg.head_tracking_enabled = false;
|
||
this.controls.set_head_tracking_enabled(false);
|
||
log::info!("[Mock Manuel] Suivi de tête moteur désactivé automatiquement pour éviter une collision UDP.");
|
||
}
|
||
cx.notify();
|
||
}),
|
||
)),
|
||
)
|
||
.when(!self.mock_status_text.is_empty(), |d| {
|
||
d.child(
|
||
div()
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_GREEN))
|
||
.child(self.mock_status_text.clone()),
|
||
)
|
||
}),
|
||
)
|
||
// Actions Nomad
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.pt_1()
|
||
.child(
|
||
div()
|
||
.id("btn_test_packet_settings")
|
||
.flex_1()
|
||
.py_1p5()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.rounded_md()
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, _| {
|
||
this.test_nomad_packet();
|
||
}))
|
||
.child("📡 Envoyer paquet neutre"),
|
||
)
|
||
.child(
|
||
div()
|
||
.id("btn_tare_settings")
|
||
.flex_1()
|
||
.py_1p5()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.rounded_md()
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, cx| {
|
||
this.controls.request_recenter();
|
||
cx.notify();
|
||
}))
|
||
.child("🎯 Réinitialiser Zéro (Tare)"),
|
||
),
|
||
),
|
||
))
|
||
// 3.2b Carte Contrôleur de Conduite (Volant G29 / Steam Controller)
|
||
.child(self.render_settings_card(
|
||
"🎮 2b. Contrôleur de Conduite (Volant G29 / Steam Controller)",
|
||
COLOR_GREEN,
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_3()
|
||
.child(self.render_setting_row(
|
||
"Source Active (bascule à chaud)",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"pill_ctrl_g29",
|
||
"🏎️ Volant Logitech G29",
|
||
self.active_control_source == ControlSource::G29,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.switch_control_source(ControlSource::G29);
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_ctrl_steam",
|
||
"🎮 Steam Controller (Boîte séq.)",
|
||
self.active_control_source == ControlSource::SteamController,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.switch_control_source(
|
||
ControlSource::SteamController,
|
||
);
|
||
cx.notify();
|
||
}),
|
||
)),
|
||
))
|
||
.when(!self.control_switch_error.is_empty(), |d| {
|
||
d.child(
|
||
div()
|
||
.px_2p5()
|
||
.py_1()
|
||
.rounded_md()
|
||
.bg(rgb(0x2a1215))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_RED))
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_RED))
|
||
.child(format!("⚠️ {}", self.control_switch_error)),
|
||
)
|
||
})
|
||
.child(self.render_setting_row(
|
||
"État Steam Controller",
|
||
div()
|
||
.text_xs()
|
||
.text_color(if self.latest_controller.connected {
|
||
rgb(COLOR_GREEN)
|
||
} else {
|
||
rgb(COLOR_TEXT_MUTED)
|
||
})
|
||
.child(if self.latest_controller.connected {
|
||
format!(
|
||
"● {} ({}) — [{}] {} • Gaz {}% • Frn {}% • Dir {:+.0}%",
|
||
self.latest_controller.device_name,
|
||
self.latest_controller.device_path,
|
||
self.latest_controller.gear_label(),
|
||
if self.latest_controller.armed {
|
||
"ARMED"
|
||
} else {
|
||
"SAFE"
|
||
},
|
||
self.latest_controller.throttle_pct,
|
||
self.latest_controller.brake_pct,
|
||
self.latest_controller.steering_norm * 100.0
|
||
)
|
||
} else {
|
||
"○ Non détecté (branchez le dongle ou allumez la manette)"
|
||
.to_string()
|
||
}),
|
||
))
|
||
.child(self.render_setting_row(
|
||
"Sens Direction Steam Controller",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.items_center()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"pill_sc_steer_normal",
|
||
"Normal (identique G29)",
|
||
!self.cfg.controller_invert_steering,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.controller_invert_steering = false;
|
||
this.controls.set_invert_steering(false);
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_sc_steer_inv",
|
||
"Inversée",
|
||
self.cfg.controller_invert_steering,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.controller_invert_steering = true;
|
||
this.controls.set_invert_steering(true);
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(
|
||
div()
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MUTED))
|
||
.child(format!(
|
||
"(Expo {:.2} • Deadzone {:.2})",
|
||
self.cfg.controller_expo,
|
||
self.cfg.controller_deadzone
|
||
)),
|
||
),
|
||
))
|
||
.child(self.render_setting_row(
|
||
"Vibrations Haptiques SC (25 Hz)",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.items_center()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"pill_sc_vib_0",
|
||
"OFF",
|
||
self.cfg.controller_vibration == 0,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.controller_vibration = 0;
|
||
this.controls.set_controller_vibration_pct(0);
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(
|
||
div()
|
||
.id("btn_sc_vib_dec")
|
||
.px_2()
|
||
.py_1()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::BOLD)
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, cx| {
|
||
let next = this.cfg.controller_vibration.saturating_sub(10);
|
||
this.cfg.controller_vibration = next;
|
||
this.controls.set_controller_vibration_pct(next);
|
||
cx.notify();
|
||
}))
|
||
.child("−10%"),
|
||
)
|
||
.child(
|
||
div()
|
||
.px_2p5()
|
||
.py_1()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_BG_DARK))
|
||
.border_1()
|
||
.border_color(if self.cfg.controller_vibration > 0 {
|
||
rgb(COLOR_CYAN)
|
||
} else {
|
||
rgb(COLOR_BORDER_SUBTLE)
|
||
})
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::BOLD)
|
||
.text_color(if self.cfg.controller_vibration > 0 {
|
||
rgb(COLOR_CYAN)
|
||
} else {
|
||
rgb(COLOR_TEXT_MUTED)
|
||
})
|
||
.child(if self.cfg.controller_vibration == 0 {
|
||
"0% (OFF)".to_string()
|
||
} else {
|
||
format!("{}%", self.cfg.controller_vibration)
|
||
}),
|
||
)
|
||
.child(
|
||
div()
|
||
.id("btn_sc_vib_inc")
|
||
.px_2()
|
||
.py_1()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::BOLD)
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, cx| {
|
||
let next = (this.cfg.controller_vibration + 10).min(100);
|
||
this.cfg.controller_vibration = next;
|
||
this.controls.set_controller_vibration_pct(next);
|
||
cx.notify();
|
||
}))
|
||
.child("+10%"),
|
||
)
|
||
.child(self.render_selectable_pill(
|
||
"pill_sc_vib_50",
|
||
"50%",
|
||
self.cfg.controller_vibration == 50,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.controller_vibration = 50;
|
||
this.controls.set_controller_vibration_pct(50);
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_sc_vib_100",
|
||
"100%",
|
||
self.cfg.controller_vibration == 100,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.controller_vibration = 100;
|
||
this.controls.set_controller_vibration_pct(100);
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(
|
||
div()
|
||
.id("btn_sc_vib_test")
|
||
.px_2p5()
|
||
.py_1()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_ORANGE))
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||
.text_color(rgb(COLOR_ORANGE))
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, cx| {
|
||
this.controls.trigger_controller_rumble_test();
|
||
cx.notify();
|
||
}))
|
||
.child("📳 Tester Vibrations"),
|
||
),
|
||
))
|
||
.child(self.render_setting_row(
|
||
"Réglage des Vitesses CRSF (G29 + Steam Controller)",
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_2()
|
||
.p_2p5()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_BG_DARK))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.child(self.render_gear_stepper_row(
|
||
"av_min",
|
||
"Seuil Gaz Avant (Min)",
|
||
self.cfg.gaz_avant_min,
|
||
COLOR_TEXT_MAIN,
|
||
|cfg, d| cfg.gaz_avant_min = cfg.gaz_avant_min.saturating_add_signed(d),
|
||
cx,
|
||
))
|
||
.child(self.render_gear_stepper_row(
|
||
"g1",
|
||
"1ère Vitesse (Manœuvre)",
|
||
self.cfg.gear_1_max,
|
||
COLOR_CYAN,
|
||
|cfg, d| cfg.gear_1_max = cfg.gear_1_max.saturating_add_signed(d),
|
||
cx,
|
||
))
|
||
.child(self.render_gear_stepper_row(
|
||
"g2",
|
||
"2ème Vitesse (Normale)",
|
||
self.cfg.gear_2_max,
|
||
COLOR_GREEN,
|
||
|cfg, d| cfg.gear_2_max = cfg.gear_2_max.saturating_add_signed(d),
|
||
cx,
|
||
))
|
||
.child(self.render_gear_stepper_row(
|
||
"g3",
|
||
"3ème Vitesse (Rapide)",
|
||
self.cfg.gear_3_max,
|
||
COLOR_ORANGE,
|
||
|cfg, d| cfg.gear_3_max = cfg.gear_3_max.saturating_add_signed(d),
|
||
cx,
|
||
))
|
||
.child(self.render_gear_stepper_row(
|
||
"ar_min",
|
||
"Seuil Gaz Arrière (Min)",
|
||
self.cfg.gaz_arriere_min,
|
||
COLOR_TEXT_MAIN,
|
||
|cfg, d| cfg.gaz_arriere_min = cfg.gaz_arriere_min.saturating_add_signed(d),
|
||
cx,
|
||
))
|
||
.child(self.render_gear_stepper_row(
|
||
"ar_max",
|
||
"Plafond Marche Arrière (R)",
|
||
self.cfg.gear_reverse_max,
|
||
COLOR_RED,
|
||
|cfg, d| cfg.gear_reverse_max = cfg.gear_reverse_max.saturating_add_signed(d),
|
||
cx,
|
||
))
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.justify_end()
|
||
.pt_1()
|
||
.child(
|
||
div()
|
||
.id("btn_gears_reset_default")
|
||
.px_2p5()
|
||
.py_1()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, cx| {
|
||
this.reset_gear_speed_limits();
|
||
cx.notify();
|
||
}))
|
||
.child("↺ Valeurs par défaut (1065 / 1100-1150-1220 / 905-800)"),
|
||
),
|
||
),
|
||
))
|
||
.child(self.render_controller_monitor(cx))
|
||
.child(
|
||
div()
|
||
.p_2()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_BG_DARK))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MUTED))
|
||
.child("Stick G : Direction | R2 : Gaz | L2 : Frein | RB/LB ou R4/L4 : Boîte R-N-1-2-3 | Menu : Armer (au N) | A : Tare | B : DVR | Y : OSD | X : Proj VR | D-Pad : Trim"),
|
||
),
|
||
))
|
||
// 3.3 Carte Projection VR Steam Frame & Optique
|
||
.child(self.render_settings_card(
|
||
"🥽 3. Projection VR & Correction Optique 140°",
|
||
COLOR_CYAN,
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_3()
|
||
// Activation / Désactivation du mode VR OpenXR
|
||
.child(self.render_setting_row(
|
||
"Affichage Casque VR (OpenXR)",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"pill_vr_on",
|
||
"🥽 Activé (Casque VR)",
|
||
!self.cfg.headless,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.set_vr_enabled(true);
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_vr_off",
|
||
"🖥️ Désactivé (Mode Bureau léger)",
|
||
self.cfg.headless,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.set_vr_enabled(false);
|
||
cx.notify();
|
||
}),
|
||
)),
|
||
))
|
||
// Mode de projection
|
||
.child(self.render_setting_row(
|
||
"Mode de Projection VR",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"pill_proj_dome",
|
||
"Dôme 140° (Equirect2)",
|
||
self.cfg.projection_mode.eq_ignore_ascii_case("dome"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.projection_mode = "dome".into();
|
||
this.controls.update_optical_params(LiveOpticalParams {
|
||
camera_fov_deg: this.cfg.camera_fov_deg,
|
||
lens_k1: this.cfg.lens_k1,
|
||
lens_k2: this.cfg.lens_k2,
|
||
screen_distance_m: this.cfg.screen_distance_m,
|
||
screen_width_m: this.cfg.screen_width_m,
|
||
projection_mode: ProjectionMode::Dome140,
|
||
});
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_proj_cyl",
|
||
"Cylindre 140°",
|
||
self.cfg.projection_mode.eq_ignore_ascii_case("cylinder"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.projection_mode = "cylinder".into();
|
||
this.controls.update_optical_params(LiveOpticalParams {
|
||
camera_fov_deg: this.cfg.camera_fov_deg,
|
||
lens_k1: this.cfg.lens_k1,
|
||
lens_k2: this.cfg.lens_k2,
|
||
screen_distance_m: this.cfg.screen_distance_m,
|
||
screen_width_m: this.cfg.screen_width_m,
|
||
projection_mode: ProjectionMode::Cylinder140,
|
||
});
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_proj_flat",
|
||
"Quad Plat",
|
||
self.cfg.projection_mode.eq_ignore_ascii_case("flat"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.projection_mode = "flat".into();
|
||
this.controls.update_optical_params(LiveOpticalParams {
|
||
camera_fov_deg: this.cfg.camera_fov_deg,
|
||
lens_k1: this.cfg.lens_k1,
|
||
lens_k2: this.cfg.lens_k2,
|
||
screen_distance_m: this.cfg.screen_distance_m,
|
||
screen_width_m: this.cfg.screen_width_m,
|
||
projection_mode: ProjectionMode::FlatQuad,
|
||
});
|
||
cx.notify();
|
||
}),
|
||
)),
|
||
))
|
||
// Champ de vision, Lentille k1/k2 et Distance virtuelle (réglables à chaud en VR)
|
||
.child(self.render_setting_row(
|
||
"Optique & Écran VR (Réglage à chaud)",
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_2()
|
||
.p_2p5()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_BG_DARK))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.child(self.render_optical_stepper_row(
|
||
"opt_fov",
|
||
"FOV Caméra",
|
||
format!("{:.0}°", self.cfg.camera_fov_deg),
|
||
|cfg, step| {
|
||
cfg.camera_fov_deg =
|
||
(cfg.camera_fov_deg + step * 5.0).clamp(70.0, 180.0);
|
||
},
|
||
cx,
|
||
))
|
||
.child(self.render_optical_stepper_row(
|
||
"opt_k1",
|
||
"Distorsion k1",
|
||
format!("{:+.2}", self.cfg.lens_k1),
|
||
|cfg, step| {
|
||
cfg.lens_k1 = (((cfg.lens_k1 + step * 0.02) * 100.0)
|
||
.round()
|
||
/ 100.0)
|
||
.clamp(-0.50, 0.50);
|
||
},
|
||
cx,
|
||
))
|
||
.child(self.render_optical_stepper_row(
|
||
"opt_k2",
|
||
"Distorsion k2",
|
||
format!("{:+.2}", self.cfg.lens_k2),
|
||
|cfg, step| {
|
||
cfg.lens_k2 = (((cfg.lens_k2 + step * 0.01) * 100.0)
|
||
.round()
|
||
/ 100.0)
|
||
.clamp(-0.25, 0.25);
|
||
},
|
||
cx,
|
||
))
|
||
.child(self.render_optical_stepper_row(
|
||
"opt_dist",
|
||
"Distance Écran",
|
||
format!("{:.1} m", self.cfg.screen_distance_m),
|
||
|cfg, step| {
|
||
cfg.screen_distance_m = (((cfg.screen_distance_m
|
||
+ step * 0.2)
|
||
* 10.0)
|
||
.round()
|
||
/ 10.0)
|
||
.clamp(0.8, 4.0);
|
||
},
|
||
cx,
|
||
)),
|
||
)),
|
||
))
|
||
// 3.4 Carte Télémétrie OSD & MAVLink
|
||
.child(self.render_settings_card(
|
||
"📊 4. Télémétrie OSD & MAVLink",
|
||
COLOR_GREEN,
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_3()
|
||
.child(self.render_setting_row(
|
||
"État Télémétrie & OSD",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"pill_telem_on",
|
||
"Activé (ON)",
|
||
self.cfg.telemetry_enabled,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.telemetry_enabled = true;
|
||
this.controls.set_telemetry_enabled(true);
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_telem_off",
|
||
"Désactivé (OFF)",
|
||
!self.cfg.telemetry_enabled,
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.telemetry_enabled = false;
|
||
this.controls.set_telemetry_enabled(false);
|
||
cx.notify();
|
||
}),
|
||
)),
|
||
))
|
||
.child(self.render_setting_row(
|
||
"Port UDP Écoute MAVLink",
|
||
div()
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||
.child(format!("0.0.0.0:{}", self.cfg.telemetry_udp_port)),
|
||
)),
|
||
))
|
||
// 3.5 Carte Enregistreur Vidéo DVR
|
||
.child(self.render_settings_card(
|
||
"🎥 5. Enregistreur Vidéo DVR",
|
||
COLOR_RED,
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_3()
|
||
// Format de conteneur
|
||
.child(self.render_setting_row(
|
||
"Format Conteneur",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"pill_dvr_mkv",
|
||
"MKV (Résistant)",
|
||
self.cfg.dvr_format.eq_ignore_ascii_case("mkv"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.dvr_format = "mkv".into();
|
||
this.controls.update_dvr_config(
|
||
this.cfg.dvr_dir.clone(),
|
||
DvrContainer::Mkv,
|
||
DvrMode::from_str(&this.cfg.dvr_mode),
|
||
);
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_dvr_mp4",
|
||
"MP4 (Standard)",
|
||
self.cfg.dvr_format.eq_ignore_ascii_case("mp4"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.dvr_format = "mp4".into();
|
||
this.controls.update_dvr_config(
|
||
this.cfg.dvr_dir.clone(),
|
||
DvrContainer::Mp4,
|
||
DvrMode::from_str(&this.cfg.dvr_mode),
|
||
);
|
||
cx.notify();
|
||
}),
|
||
)),
|
||
))
|
||
// Mode d'enregistrement
|
||
.child(self.render_setting_row(
|
||
"Mode Enregistrement",
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.gap_2()
|
||
.child(self.render_selectable_pill(
|
||
"pill_dvr_copy",
|
||
"Direct 0% CPU",
|
||
self.cfg.dvr_mode.eq_ignore_ascii_case("copy"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.dvr_mode = "copy".into();
|
||
this.controls.update_dvr_config(
|
||
this.cfg.dvr_dir.clone(),
|
||
DvrContainer::from_str(&this.cfg.dvr_format),
|
||
DvrMode::StreamCopy,
|
||
);
|
||
cx.notify();
|
||
}),
|
||
))
|
||
.child(self.render_selectable_pill(
|
||
"pill_dvr_osd",
|
||
"Avec OSD incrusté",
|
||
self.cfg.dvr_mode.eq_ignore_ascii_case("composited") || self.cfg.dvr_mode.eq_ignore_ascii_case("osd"),
|
||
cx.listener(|this, _, _, cx| {
|
||
this.cfg.dvr_mode = "composited".into();
|
||
this.controls.update_dvr_config(
|
||
this.cfg.dvr_dir.clone(),
|
||
DvrContainer::from_str(&this.cfg.dvr_format),
|
||
DvrMode::CompositedOsd,
|
||
);
|
||
cx.notify();
|
||
}),
|
||
)),
|
||
))
|
||
// Statut & Action
|
||
.child(self.render_setting_row(
|
||
"Statut DVR",
|
||
div()
|
||
.text_xs()
|
||
.text_color(if self.dvr_recording { rgb(COLOR_RED) } else { rgb(COLOR_TEXT_MUTED) })
|
||
.child(if self.dvr_recording {
|
||
let mins = self.dvr_elapsed_secs / 60;
|
||
let secs = self.dvr_elapsed_secs % 60;
|
||
let mb = self.dvr_file_size_bytes as f64 / (1024.0 * 1024.0);
|
||
format!("● ACTIF : {:02}:{:02} ({} frames, {:.1} Mo)", mins, secs, self.dvr_frames_recorded, mb)
|
||
} else {
|
||
"Inactif (Prêt à enregistrer)".to_string()
|
||
}),
|
||
))
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.pt_1()
|
||
.child(
|
||
div()
|
||
.id("btn_toggle_dvr_card")
|
||
.flex_1()
|
||
.py_1p5()
|
||
.bg(if self.dvr_recording { rgb(COLOR_RED) } else { rgb(COLOR_SURFACE_CARD) })
|
||
.border_1()
|
||
.border_color(if self.dvr_recording { rgb(COLOR_RED) } else { rgb(COLOR_BORDER_SUBTLE) })
|
||
.rounded_md()
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::BOLD)
|
||
.text_color(if self.dvr_recording { rgb(0xffffff) } else { rgb(COLOR_TEXT_MAIN) })
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(|this, _, _, cx| {
|
||
if this.dvr_recording {
|
||
this.controls.stop_dvr();
|
||
} else {
|
||
this.controls.start_dvr();
|
||
}
|
||
cx.notify();
|
||
}))
|
||
.child(if self.dvr_recording {
|
||
"⏹ Arrêter l'enregistrement DVR"
|
||
} else {
|
||
"🔴 Démarrer l'enregistrement DVR"
|
||
}),
|
||
),
|
||
),
|
||
)),
|
||
)
|
||
}
|
||
|
||
fn render_settings_card(&self, title: &str, accent_color: u32, content: impl IntoElement) -> impl IntoElement {
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.min_w(px(300.0))
|
||
.flex_1()
|
||
.overflow_hidden()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.rounded_xl()
|
||
.p_4()
|
||
.gap_3()
|
||
.child(
|
||
div()
|
||
.text_sm()
|
||
.font_weight(gpui::FontWeight::BOLD)
|
||
.text_color(rgb(accent_color))
|
||
.child(title.to_string()),
|
||
)
|
||
.child(content)
|
||
}
|
||
|
||
fn render_mock_axis_row(
|
||
&self,
|
||
axis: &'static str,
|
||
label: &str,
|
||
value_deg: f32,
|
||
max_deg: f32,
|
||
cx: &mut Context<Self>,
|
||
) -> impl IntoElement {
|
||
let crsf = NomadHeadTracker::deg_to_crsf(value_deg, max_deg);
|
||
let pwm = NomadHeadTracker::crsf_to_pwm_us(crsf);
|
||
let step_btn = |suffix: &'static str, text: &'static str, delta: f32, reset: bool| {
|
||
let id = match (axis, suffix) {
|
||
("pan", "m10") => "mock_pan_m10",
|
||
("pan", "m1") => "mock_pan_m1",
|
||
("pan", "0") => "mock_pan_0",
|
||
("pan", "p1") => "mock_pan_p1",
|
||
("pan", "p10") => "mock_pan_p10",
|
||
("tilt", "m10") => "mock_tilt_m10",
|
||
("tilt", "m1") => "mock_tilt_m1",
|
||
("tilt", "0") => "mock_tilt_0",
|
||
("tilt", "p1") => "mock_tilt_p1",
|
||
("tilt", "p10") => "mock_tilt_p10",
|
||
("roll", "m10") => "mock_roll_m10",
|
||
("roll", "m1") => "mock_roll_m1",
|
||
("roll", "0") => "mock_roll_0",
|
||
("roll", "p1") => "mock_roll_p1",
|
||
_ => "mock_roll_p10",
|
||
};
|
||
div()
|
||
.id(id)
|
||
.px_2()
|
||
.py_0p5()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.rounded_md()
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(move |this, _, _, cx| {
|
||
let (target, max_val) = match axis {
|
||
"pan" => (&mut this.mock_pan_deg, this.cfg.max_pan_deg),
|
||
"tilt" => (&mut this.mock_tilt_deg, this.cfg.max_tilt_deg),
|
||
_ => (&mut this.mock_roll_deg, this.cfg.max_roll_deg),
|
||
};
|
||
if reset {
|
||
*target = 0.0;
|
||
} else {
|
||
*target = (*target + delta).clamp(-max_val, max_val);
|
||
}
|
||
cx.notify();
|
||
}))
|
||
.child(text)
|
||
};
|
||
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.items_center()
|
||
.justify_between()
|
||
.gap_2()
|
||
.child(
|
||
div()
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||
.child(format!(
|
||
"{} : {:+.0}° (CRSF {} / {}µs)",
|
||
label, value_deg, crsf, pwm
|
||
)),
|
||
)
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.gap_1()
|
||
.child(step_btn("m10", "-10°", -10.0, false))
|
||
.child(step_btn("m1", "-1°", -1.0, false))
|
||
.child(step_btn("0", "0°", 0.0, true))
|
||
.child(step_btn("p1", "+1°", 1.0, false))
|
||
.child(step_btn("p10", "+10°", 10.0, false)),
|
||
)
|
||
}
|
||
|
||
fn apply_gear_speed_limits(&mut self) {
|
||
let sanitized = GearSpeedLimits {
|
||
forward_min: self.cfg.gaz_avant_min,
|
||
forward_max: [
|
||
self.cfg.gear_1_max,
|
||
self.cfg.gear_2_max,
|
||
self.cfg.gear_3_max,
|
||
],
|
||
reverse_min: self.cfg.gaz_arriere_min,
|
||
reverse_max: self.cfg.gear_reverse_max,
|
||
}
|
||
.sanitized();
|
||
self.cfg.gaz_avant_min = sanitized.forward_min;
|
||
self.cfg.gear_1_max = sanitized.forward_max[0];
|
||
self.cfg.gear_2_max = sanitized.forward_max[1];
|
||
self.cfg.gear_3_max = sanitized.forward_max[2];
|
||
self.cfg.gaz_arriere_min = sanitized.reverse_min;
|
||
self.cfg.gear_reverse_max = sanitized.reverse_max;
|
||
self.controls.set_gear_speed_limits(sanitized);
|
||
}
|
||
|
||
fn reset_gear_speed_limits(&mut self) {
|
||
let def = GearSpeedLimits::default();
|
||
self.cfg.gaz_avant_min = def.forward_min;
|
||
self.cfg.gear_1_max = def.forward_max[0];
|
||
self.cfg.gear_2_max = def.forward_max[1];
|
||
self.cfg.gear_3_max = def.forward_max[2];
|
||
self.cfg.gaz_arriere_min = def.reverse_min;
|
||
self.cfg.gear_reverse_max = def.reverse_max;
|
||
self.controls.set_gear_speed_limits(def);
|
||
}
|
||
|
||
fn sync_optical_params(&self) {
|
||
self.controls.update_optical_params(LiveOpticalParams {
|
||
projection_mode: ProjectionMode::from_str(&self.cfg.projection_mode),
|
||
camera_fov_deg: self.cfg.camera_fov_deg,
|
||
lens_k1: self.cfg.lens_k1,
|
||
lens_k2: self.cfg.lens_k2,
|
||
screen_distance_m: self.cfg.screen_distance_m,
|
||
screen_width_m: self.cfg.screen_width_m,
|
||
});
|
||
}
|
||
|
||
fn render_optical_stepper_row(
|
||
&self,
|
||
id_prefix: &'static str,
|
||
label: &'static str,
|
||
value_text: String,
|
||
mutator: fn(&mut AppConfig, f32),
|
||
cx: &mut Context<Self>,
|
||
) -> impl IntoElement {
|
||
let step_btn = |suffix: &'static str, txt: &'static str, step: f32| {
|
||
let btn_id = gpui::SharedString::from(format!("btn_opt_{}_{}", id_prefix, suffix));
|
||
div()
|
||
.id(btn_id)
|
||
.px_2p5()
|
||
.py_1()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::BOLD)
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(move |this, _, _, cx| {
|
||
mutator(&mut this.cfg, step);
|
||
this.sync_optical_params();
|
||
cx.notify();
|
||
}))
|
||
.child(txt)
|
||
};
|
||
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.items_center()
|
||
.justify_between()
|
||
.gap_2()
|
||
.child(
|
||
div()
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||
.child(label),
|
||
)
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.items_center()
|
||
.gap_1p5()
|
||
.child(step_btn("m2", "−−", -2.0))
|
||
.child(step_btn("m1", "−", -1.0))
|
||
.child(
|
||
div()
|
||
.w(px(64.0))
|
||
.py_0p5()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_SURFACE_CARD))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_CYAN))
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::BOLD)
|
||
.text_color(rgb(COLOR_CYAN))
|
||
.flex()
|
||
.justify_center()
|
||
.child(value_text),
|
||
)
|
||
.child(step_btn("p1", "+", 1.0))
|
||
.child(step_btn("p2", "++", 2.0)),
|
||
)
|
||
}
|
||
|
||
fn render_gear_stepper_row(
|
||
&self,
|
||
id_prefix: &'static str,
|
||
label: &'static str,
|
||
value: u16,
|
||
accent_color: u32,
|
||
mutator: fn(&mut AppConfig, i16),
|
||
cx: &mut Context<Self>,
|
||
) -> impl IntoElement {
|
||
let step_btn = |suffix: &'static str, txt: &'static str, delta: i16| {
|
||
let btn_id = gpui::SharedString::from(format!("btn_gear_{}_{}", id_prefix, suffix));
|
||
div()
|
||
.id(btn_id)
|
||
.px_2()
|
||
.py_0p5()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_SURFACE_ELEVATED))
|
||
.border_1()
|
||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::BOLD)
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(move |this, _, _, cx| {
|
||
mutator(&mut this.cfg, delta);
|
||
this.apply_gear_speed_limits();
|
||
cx.notify();
|
||
}))
|
||
.child(txt)
|
||
};
|
||
|
||
div()
|
||
.flex()
|
||
.flex_wrap()
|
||
.items_center()
|
||
.justify_between()
|
||
.gap_2()
|
||
.child(
|
||
div()
|
||
.text_xs()
|
||
.text_color(rgb(COLOR_TEXT_MAIN))
|
||
.child(label),
|
||
)
|
||
.child(
|
||
div()
|
||
.flex()
|
||
.items_center()
|
||
.gap_1p5()
|
||
.child(step_btn("m10", "−10", -10))
|
||
.child(step_btn("m5", "−5", -5))
|
||
.child(
|
||
div()
|
||
.w(px(56.0))
|
||
.py_0p5()
|
||
.rounded_md()
|
||
.bg(rgb(COLOR_SURFACE_CARD))
|
||
.border_1()
|
||
.border_color(rgb(accent_color))
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::BOLD)
|
||
.text_color(rgb(accent_color))
|
||
.flex()
|
||
.justify_center()
|
||
.child(format!("{}", value)),
|
||
)
|
||
.child(step_btn("p5", "+5", 5))
|
||
.child(step_btn("p10", "+10", 10)),
|
||
)
|
||
}
|
||
|
||
fn render_setting_row(&self, label: &str, control: impl IntoElement) -> impl IntoElement {
|
||
div()
|
||
.flex()
|
||
.flex_col()
|
||
.gap_1p5()
|
||
.child(
|
||
div()
|
||
.text_xs()
|
||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||
.text_color(rgb(COLOR_TEXT_MUTED))
|
||
.child(label.to_string()),
|
||
)
|
||
.child(control)
|
||
}
|
||
|
||
pub(super) fn render_selectable_pill(
|
||
&self,
|
||
id: impl Into<ElementId>,
|
||
label: &str,
|
||
is_selected: bool,
|
||
on_click: impl Fn(&gpui::ClickEvent, &mut Window, &mut App) + 'static,
|
||
) -> impl IntoElement {
|
||
div()
|
||
.id(id.into())
|
||
.px_3()
|
||
.py_1()
|
||
.bg(if is_selected {
|
||
rgb(0x132738)
|
||
} else {
|
||
rgb(COLOR_SURFACE_CARD)
|
||
})
|
||
.border_1()
|
||
.border_color(if is_selected {
|
||
rgb(COLOR_CYAN)
|
||
} else {
|
||
rgb(COLOR_BORDER_SUBTLE)
|
||
})
|
||
.rounded_md()
|
||
.text_xs()
|
||
.font_weight(if is_selected {
|
||
gpui::FontWeight::BOLD
|
||
} else {
|
||
gpui::FontWeight::NORMAL
|
||
})
|
||
.text_color(if is_selected {
|
||
rgb(COLOR_CYAN)
|
||
} else {
|
||
rgb(COLOR_TEXT_MUTED)
|
||
})
|
||
.cursor_pointer()
|
||
.on_click(on_click)
|
||
.child(label.to_string())
|
||
}
|
||
|
||
fn render_channel_button(&self, ch: u16, freq_mhz: u32, cx: &mut Context<Self>) -> impl IntoElement {
|
||
let is_selected = self.cfg.wifi_channel == ch;
|
||
let btn_id = match ch {
|
||
149 => "btn_ch_149",
|
||
153 => "btn_ch_153",
|
||
157 => "btn_ch_157",
|
||
_ => "btn_ch_161",
|
||
};
|
||
div()
|
||
.id(btn_id)
|
||
.flex_1()
|
||
.px_2()
|
||
.py_1()
|
||
.bg(if is_selected {
|
||
rgb(0x28190d)
|
||
} else {
|
||
rgb(COLOR_SURFACE_CARD)
|
||
})
|
||
.border_1()
|
||
.border_color(if is_selected {
|
||
rgb(COLOR_ORANGE)
|
||
} else {
|
||
rgb(COLOR_BORDER_SUBTLE)
|
||
})
|
||
.rounded_md()
|
||
.text_xs()
|
||
.text_center()
|
||
.font_weight(if is_selected {
|
||
gpui::FontWeight::BOLD
|
||
} else {
|
||
gpui::FontWeight::NORMAL
|
||
})
|
||
.text_color(if is_selected {
|
||
rgb(COLOR_ORANGE)
|
||
} else {
|
||
rgb(COLOR_TEXT_MUTED)
|
||
})
|
||
.cursor_pointer()
|
||
.on_click(cx.listener(move |this, _, _, cx| {
|
||
this.cfg.wifi_channel = ch;
|
||
cx.notify();
|
||
}))
|
||
.child(format!("CH {} ({}MHz)", ch, freq_mhz))
|
||
}
|
||
|
||
// -------------------------------------------------------------------------
|
||
// 4. Vue Télémétrie Détaillée & Jauges Vol
|
||
}
|