chore(tahuantinsuyu): fase 28 — limpieza de warnings y dead_code

- Reemplaza `Context<Self>` por `Context<'_, Self>` (y la misma
  fórmula para `Context<TahuantinsuyuTree>`) en tree/panel/canvas:
  60 warnings de "hidden lifetime parameters are deprecated" → 0.
- Borra `TREE_WIDTH` y `PANEL_HEIGHT` (constantes muertas) y el
  campo `main_split` del shell (vive como child de outer_split,
  no necesita retención aparte).
- Quita `yahweh-bus` de tahuantinsuyu — el `bus: Entity<AppBus>`
  estaba con `#[allow(dead_code)]` sin cablear. Cuando lo
  necesitemos para coordinación cross-app lo reagregamos.
- Suprime imports `Module` (panel), `AppContext` (canvas) y
  prefija el `cx` no usado en `on_jog_down`.
- Marca `BrahmanStatus::Offline.reason` y `Shell.tree` con
  `#[allow(dead_code)]` documentando por qué se retienen
  (logs y subscripciones).

Workspace ahora compila limpio salvo un warning conocido de
`eternal-validation` (variable `sin_i` sin usar — fuera de
brahman).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
sergio
2026-05-18 00:28:17 +00:00
parent a4d1e0dc17
commit 2192c29d4f
6 changed files with 77 additions and 81 deletions
Generated
-1
View File
@@ -10917,7 +10917,6 @@ dependencies = [
"tahuantinsuyu-store", "tahuantinsuyu-store",
"tahuantinsuyu-theme", "tahuantinsuyu-theme",
"tahuantinsuyu-tree", "tahuantinsuyu-tree",
"yahweh-bus",
"yahweh-core", "yahweh-core",
"yahweh-theme", "yahweh-theme",
"yahweh-widget-container-core", "yahweh-widget-container-core",
-1
View File
@@ -17,7 +17,6 @@ tahuantinsuyu-theme = { path = "../../modules/tahuantinsuyu/tahuantinsuyu-theme"
tahuantinsuyu-tree = { path = "../../modules/tahuantinsuyu/tahuantinsuyu-tree" } tahuantinsuyu-tree = { path = "../../modules/tahuantinsuyu/tahuantinsuyu-tree" }
brahman-sidecar = { path = "../../shared/brahman-sidecar" } brahman-sidecar = { path = "../../shared/brahman-sidecar" }
yahweh-bus = { workspace = true }
yahweh-core = { workspace = true } yahweh-core = { workspace = true }
yahweh-theme = { workspace = true } yahweh-theme = { workspace = true }
yahweh-widget-theme-switcher = { path = "../../modules/ui_engine/widgets/theme-switcher" } yahweh-widget-theme-switcher = { path = "../../modules/ui_engine/widgets/theme-switcher" }
+15 -17
View File
@@ -39,16 +39,12 @@ use tahuantinsuyu_model::{Chart, ChartId, ModuleState, TreeSelection};
use tahuantinsuyu_panel::{ChartOption, ControlPanel, PanelEvent}; use tahuantinsuyu_panel::{ChartOption, ControlPanel, PanelEvent};
use tahuantinsuyu_store::Store; use tahuantinsuyu_store::Store;
use tahuantinsuyu_tree::{parse_city_atlas_tsv, TahuantinsuyuTree, TreeEvent}; use tahuantinsuyu_tree::{parse_city_atlas_tsv, TahuantinsuyuTree, TreeEvent};
use yahweh_bus::AppBus;
use yahweh_core::{LayoutDirection, NodeId}; use yahweh_core::{LayoutDirection, NodeId};
use yahweh_theme::Theme; use yahweh_theme::Theme;
use yahweh_widget_container_core::ChildSlot; use yahweh_widget_container_core::ChildSlot;
use yahweh_widget_splitter::SplitContainer; use yahweh_widget_splitter::SplitContainer;
use yahweh_widget_theme_switcher::theme_switcher; use yahweh_widget_theme_switcher::theme_switcher;
const TREE_WIDTH: f32 = 280.0;
const PANEL_HEIGHT: f32 = 180.0;
/// Status del broker brahman tal como lo vimos en el último ping. /// Status del broker brahman tal como lo vimos en el último ping.
/// Se refresca cada 30 segundos desde un background task. /// Se refresca cada 30 segundos desde un background task.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@@ -58,22 +54,28 @@ pub enum BrahmanStatus {
/// Connect OK al broker, devolvió la lista de sessions activas. /// Connect OK al broker, devolvió la lista de sessions activas.
Connected { session_count: usize }, Connected { session_count: usize },
/// Connect falló — broker no escucha en el socket o tomó timeout. /// Connect falló — broker no escucha en el socket o tomó timeout.
Offline { reason: String }, /// `reason` se incluye para diagnóstico en logs aunque la UI hoy
/// muestra solo "offline".
Offline {
#[allow(dead_code)]
reason: String,
},
} }
pub struct Shell { pub struct Shell {
store: Store, store: Store,
/// El árbol vive como child de `outer_split` (vía AnyView clone),
/// pero retenemos el Entity acá para que las subscripciones
/// registradas en `new` sigan vivas — al droppear el último handle,
/// gpui cancela los suscriptores.
#[allow(dead_code)] #[allow(dead_code)]
bus: Entity<AppBus>,
tree: Entity<TahuantinsuyuTree>, tree: Entity<TahuantinsuyuTree>,
canvas: Entity<AstrologyCanvas>, canvas: Entity<AstrologyCanvas>,
panel: Entity<ControlPanel>, panel: Entity<ControlPanel>,
/// Splitter horizontal entre tree (izq) y canvas (der). El divisor /// Splitter vertical entre el main_row (arriba — tree + canvas) y
/// es draggable — el flex se persiste in-memory mientras la app /// el panel de control (abajo). El splitter horizontal interno se
/// está abierta. /// arma en `new` y queda referenciado vía `outer_split` (es uno de
main_split: Entity<SplitContainer>, /// sus children), sin necesidad de retenerlo aparte.
/// Splitter vertical entre el main_row (arriba) y el panel de
/// control (abajo).
outer_split: Entity<SplitContainer>, outer_split: Entity<SplitContainer>,
/// Último estado conocido del broker brahman — refrescado cada /// Último estado conocido del broker brahman — refrescado cada
/// 30s desde el background task. /// 30s desde el background task.
@@ -95,7 +97,6 @@ impl Shell {
pub fn new(store: Store, cx: &mut Context<Self>) -> Self { pub fn new(store: Store, cx: &mut Context<Self>) -> Self {
cx.observe_global::<Theme>(|_, cx| cx.notify()).detach(); cx.observe_global::<Theme>(|_, cx| cx.notify()).detach();
let bus = cx.new(|_| AppBus);
let tree = cx.new(|cx| { let tree = cx.new(|cx| {
let mut t = TahuantinsuyuTree::new(store.clone(), cx); let mut t = TahuantinsuyuTree::new(store.clone(), cx);
// Si hay un atlas custom en $XDG_DATA_HOME/tahuantinsuyu/ // Si hay un atlas custom en $XDG_DATA_HOME/tahuantinsuyu/
@@ -169,13 +170,11 @@ impl Shell {
sc sc
}); });
let mut shell = Self { let shell = Self {
store, store,
bus,
tree, tree,
canvas, canvas,
panel, panel,
main_split,
outer_split, outer_split,
brahman_status: BrahmanStatus::Pending, brahman_status: BrahmanStatus::Pending,
current_chart: None, current_chart: None,
@@ -818,7 +817,6 @@ impl Shell {
// header con switch (vs. el toggle por-control de hoy). // header con switch (vs. el toggle por-control de hoy).
} }
} }
let _ = (&self.store, &self.tree, &self.bus);
} }
} }
@@ -34,7 +34,7 @@ use std::collections::HashMap;
use std::f32::consts::PI; use std::f32::consts::PI;
use gpui::{ use gpui::{
AppContext, Bounds, Context, EventEmitter, FocusHandle, Focusable, Hsla, IntoElement, Bounds, Context, EventEmitter, FocusHandle, Focusable, Hsla, IntoElement,
KeyDownEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, KeyDownEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement,
PathBuilder, Pixels, Point, Render, SharedString, Styled, Window, canvas, div, hsla, PathBuilder, Pixels, Point, Render, SharedString, Styled, Window, canvas, div, hsla,
linear_color_stop, linear_gradient, point, prelude::*, px, linear_color_stop, linear_gradient, point, prelude::*, px,
@@ -218,7 +218,7 @@ impl Focusable for AstrologyCanvas {
} }
impl AstrologyCanvas { impl AstrologyCanvas {
pub fn new(cx: &mut Context<Self>) -> Self { pub fn new(cx: &mut Context<'_, Self>) -> Self {
cx.observe_global::<Theme>(|_, cx| cx.notify()).detach(); cx.observe_global::<Theme>(|_, cx| cx.notify()).detach();
Self { Self {
state: CanvasState::default(), state: CanvasState::default(),
@@ -230,17 +230,17 @@ impl AstrologyCanvas {
&self.state &self.state
} }
pub fn set_mode(&mut self, mode: CanvasMode, cx: &mut Context<Self>) { pub fn set_mode(&mut self, mode: CanvasMode, cx: &mut Context<'_, Self>) {
self.state.mode = mode; self.state.mode = mode;
cx.notify(); cx.notify();
} }
pub fn set_layer_visible(&mut self, kind: LayerKind, visible: bool, cx: &mut Context<Self>) { pub fn set_layer_visible(&mut self, kind: LayerKind, visible: bool, cx: &mut Context<'_, Self>) {
self.state.layer_visibility.insert(kind, visible); self.state.layer_visibility.insert(kind, visible);
cx.notify(); cx.notify();
} }
pub fn toggle_layer(&mut self, kind: LayerKind, cx: &mut Context<Self>) { pub fn toggle_layer(&mut self, kind: LayerKind, cx: &mut Context<'_, Self>) {
let current = self.state.is_layer_visible(kind); let current = self.state.is_layer_visible(kind);
self.set_layer_visible(kind, !current, cx); self.set_layer_visible(kind, !current, cx);
cx.emit(CanvasEvent::LayerVisibilityChanged { cx.emit(CanvasEvent::LayerVisibilityChanged {
@@ -249,7 +249,7 @@ impl AstrologyCanvas {
}); });
} }
pub fn reset_time_offset(&mut self, cx: &mut Context<Self>) { pub fn reset_time_offset(&mut self, cx: &mut Context<'_, Self>) {
if self.state.time_offset_minutes != 0 || self.state.view_rotation_deg != 0.0 { if self.state.time_offset_minutes != 0 || self.state.view_rotation_deg != 0.0 {
self.state.time_offset_minutes = 0; self.state.time_offset_minutes = 0;
self.state.view_rotation_deg = 0.0; self.state.view_rotation_deg = 0.0;
@@ -258,7 +258,7 @@ impl AstrologyCanvas {
} }
} }
pub fn set_view_rotation(&mut self, deg: f32, cx: &mut Context<Self>) { pub fn set_view_rotation(&mut self, deg: f32, cx: &mut Context<'_, Self>) {
self.state.view_rotation_deg = deg.rem_euclid(360.0); self.state.view_rotation_deg = deg.rem_euclid(360.0);
cx.notify(); cx.notify();
} }
@@ -269,7 +269,7 @@ impl AstrologyCanvas {
&mut self, &mut self,
position: Point<Pixels>, position: Point<Pixels>,
bounds: Bounds<Pixels>, bounds: Bounds<Pixels>,
cx: &mut Context<Self>, _cx: &mut Context<'_, Self>,
) { ) {
let (cx_px, cy_px) = bounds_center(bounds); let (cx_px, cy_px) = bounds_center(bounds);
let mx: f32 = position.x.into(); let mx: f32 = position.x.into();
@@ -294,7 +294,7 @@ impl AstrologyCanvas {
&mut self, &mut self,
position: Point<Pixels>, position: Point<Pixels>,
bounds: Bounds<Pixels>, bounds: Bounds<Pixels>,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
let Some(jog) = self.state.drag_jog.as_mut() else { let Some(jog) = self.state.drag_jog.as_mut() else {
return; return;
@@ -327,7 +327,7 @@ impl AstrologyCanvas {
&mut self, &mut self,
position: Point<Pixels>, position: Point<Pixels>,
bounds: Bounds<Pixels>, bounds: Bounds<Pixels>,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
let CanvasMode::Wheel { render } = &self.state.mode else { let CanvasMode::Wheel { render } = &self.state.mode else {
if self.state.hover.take().is_some() { if self.state.hover.take().is_some() {
@@ -494,7 +494,7 @@ impl AstrologyCanvas {
} }
} }
fn on_jog_up(&mut self, cx: &mut Context<Self>) { fn on_jog_up(&mut self, cx: &mut Context<'_, Self>) {
let Some(jog) = self.state.drag_jog.take() else { let Some(jog) = self.state.drag_jog.take() else {
return; return;
}; };
@@ -516,7 +516,7 @@ impl AstrologyCanvas {
} }
} }
fn on_key_down(&mut self, event: &KeyDownEvent, _w: &mut Window, cx: &mut Context<Self>) { fn on_key_down(&mut self, event: &KeyDownEvent, _w: &mut Window, cx: &mut Context<'_, Self>) {
let key = event.keystroke.key.as_str(); let key = event.keystroke.key.as_str();
let kind = match key { let kind = match key {
"d" | "D" => LayerKind::SignDial, "d" | "D" => LayerKind::SignDial,
@@ -558,7 +558,7 @@ fn bounds_center(bounds: Bounds<Pixels>) -> (f32, f32) {
// ===================================================================== // =====================================================================
impl Render for AstrologyCanvas { impl Render for AstrologyCanvas {
fn render(&mut self, _w: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, _w: &mut Window, cx: &mut Context<'_, Self>) -> impl IntoElement {
let theme = Theme::global(cx).clone(); let theme = Theme::global(cx).clone();
let palette = AstroPalette::for_theme(&theme); let palette = AstroPalette::for_theme(&theme);
let entity = cx.entity(); let entity = cx.entity();
@@ -30,7 +30,7 @@ use gpui::{
}; };
use tahuantinsuyu_model::ChartKind; use tahuantinsuyu_model::ChartKind;
use tahuantinsuyu_modules::{Control, Module, Registry, SelectOption}; use tahuantinsuyu_modules::{Control, Registry, SelectOption};
use yahweh_theme::Theme; use yahweh_theme::Theme;
// ===================================================================== // =====================================================================
@@ -101,7 +101,7 @@ pub struct ControlPanel {
impl EventEmitter<PanelEvent> for ControlPanel {} impl EventEmitter<PanelEvent> for ControlPanel {}
impl ControlPanel { impl ControlPanel {
pub fn new(cx: &mut Context<Self>) -> Self { pub fn new(cx: &mut Context<'_, Self>) -> Self {
cx.observe_global::<Theme>(|_, cx| cx.notify()).detach(); cx.observe_global::<Theme>(|_, cx| cx.notify()).detach();
Self { Self {
active_kind: None, active_kind: None,
@@ -134,13 +134,13 @@ impl ControlPanel {
.unwrap_or(false) .unwrap_or(false)
} }
fn toggle_collapsed(&mut self, module_id: String, cx: &mut Context<Self>) { fn toggle_collapsed(&mut self, module_id: String, cx: &mut Context<'_, Self>) {
let current = self.is_collapsed(&module_id); let current = self.is_collapsed(&module_id);
self.collapse_overrides.insert(module_id, !current); self.collapse_overrides.insert(module_id, !current);
cx.notify(); cx.notify();
} }
pub fn set_active_kind(&mut self, kind: Option<ChartKind>, cx: &mut Context<Self>) { pub fn set_active_kind(&mut self, kind: Option<ChartKind>, cx: &mut Context<'_, Self>) {
if self.active_kind != kind { if self.active_kind != kind {
if let Some(k) = kind { if let Some(k) = kind {
for m in self.registry.for_kind(k) { for m in self.registry.for_kind(k) {
@@ -180,7 +180,7 @@ impl ControlPanel {
/// Setea un toggle desde afuera (sin emitir evento). Usado por el /// Setea un toggle desde afuera (sin emitir evento). Usado por el
/// shell para sincronizar cuando el canvas se autotoggleó via hotkey. /// shell para sincronizar cuando el canvas se autotoggleó via hotkey.
pub fn set_toggle(&mut self, module_id: &str, key: &str, value: bool, cx: &mut Context<Self>) { pub fn set_toggle(&mut self, module_id: &str, key: &str, value: bool, cx: &mut Context<'_, Self>) {
self.toggle_state self.toggle_state
.insert((module_id.to_string(), key.to_string()), value); .insert((module_id.to_string(), key.to_string()), value);
cx.notify(); cx.notify();
@@ -189,7 +189,7 @@ impl ControlPanel {
/// Setea un slider desde afuera (sin emitir evento). El shell la /// Setea un slider desde afuera (sin emitir evento). El shell la
/// usa, por ejemplo, para inicializar `progression.target_age_years` /// usa, por ejemplo, para inicializar `progression.target_age_years`
/// con la edad actual del sujeto al cargar una carta nueva. /// con la edad actual del sujeto al cargar una carta nueva.
pub fn set_slider(&mut self, module_id: &str, key: &str, value: f64, cx: &mut Context<Self>) { pub fn set_slider(&mut self, module_id: &str, key: &str, value: f64, cx: &mut Context<'_, Self>) {
self.slider_state self.slider_state
.insert((module_id.to_string(), key.to_string()), value); .insert((module_id.to_string(), key.to_string()), value);
cx.notify(); cx.notify();
@@ -199,7 +199,7 @@ impl ControlPanel {
/// `Control::ChartPicker`. El shell la llama cada vez que la /// `Control::ChartPicker`. El shell la llama cada vez que la
/// jerarquía de cartas cambia (crear/borrar) para que el dropdown /// jerarquía de cartas cambia (crear/borrar) para que el dropdown
/// quede al día sin necesidad de re-instanciar el panel. /// quede al día sin necesidad de re-instanciar el panel.
pub fn set_chart_options(&mut self, options: Vec<ChartOption>, cx: &mut Context<Self>) { pub fn set_chart_options(&mut self, options: Vec<ChartOption>, cx: &mut Context<'_, Self>) {
self.chart_options = options; self.chart_options = options;
cx.notify(); cx.notify();
} }
@@ -212,7 +212,7 @@ impl ControlPanel {
module_id: &str, module_id: &str,
key: &str, key: &str,
value: Option<String>, value: Option<String>,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
self.string_state self.string_state
.insert((module_id.to_string(), key.to_string()), value); .insert((module_id.to_string(), key.to_string()), value);
@@ -226,14 +226,14 @@ impl ControlPanel {
module_id: &str, module_id: &str,
key: &str, key: &str,
chart_id: Option<String>, chart_id: Option<String>,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
self.set_string(module_id, key, chart_id, cx); self.set_string(module_id, key, chart_id, cx);
} }
// ----- internos: handlers ----- // ----- internos: handlers -----
fn on_toggle_click(&mut self, module_id: String, key: String, cx: &mut Context<Self>) { fn on_toggle_click(&mut self, module_id: String, key: String, cx: &mut Context<'_, Self>) {
let entry = self let entry = self
.toggle_state .toggle_state
.entry((module_id.clone(), key.clone())) .entry((module_id.clone(), key.clone()))
@@ -256,7 +256,7 @@ impl ControlPanel {
max: f64, max: f64,
bounds: Bounds<Pixels>, bounds: Bounds<Pixels>,
position: Point<Pixels>, position: Point<Pixels>,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
self.slider_drag = Some(SliderDrag { self.slider_drag = Some(SliderDrag {
module_id: module_id.clone(), module_id: module_id.clone(),
@@ -271,20 +271,20 @@ impl ControlPanel {
&mut self, &mut self,
bounds: Bounds<Pixels>, bounds: Bounds<Pixels>,
position: Point<Pixels>, position: Point<Pixels>,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
if self.slider_drag.is_some() { if self.slider_drag.is_some() {
self.apply_slider_position(bounds, position, cx); self.apply_slider_position(bounds, position, cx);
} }
} }
fn end_slider_drag(&mut self, cx: &mut Context<Self>) { fn end_slider_drag(&mut self, cx: &mut Context<'_, Self>) {
if self.slider_drag.take().is_some() { if self.slider_drag.take().is_some() {
cx.notify(); cx.notify();
} }
} }
fn toggle_dropdown_open(&mut self, module_id: String, key: String, cx: &mut Context<Self>) { fn toggle_dropdown_open(&mut self, module_id: String, key: String, cx: &mut Context<'_, Self>) {
let key_pair = (module_id, key); let key_pair = (module_id, key);
let new_state = match self.dropdown_open.as_ref() { let new_state = match self.dropdown_open.as_ref() {
Some(open) if open == &key_pair => None, Some(open) if open == &key_pair => None,
@@ -299,7 +299,7 @@ impl ControlPanel {
module_id: String, module_id: String,
key: String, key: String,
value: Option<String>, value: Option<String>,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
self.string_state self.string_state
.insert((module_id.clone(), key.clone()), value.clone()); .insert((module_id.clone(), key.clone()), value.clone());
@@ -320,7 +320,7 @@ impl ControlPanel {
&mut self, &mut self,
bounds: Bounds<Pixels>, bounds: Bounds<Pixels>,
position: Point<Pixels>, position: Point<Pixels>,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
let Some(drag) = self.slider_drag.as_ref().cloned() else { let Some(drag) = self.slider_drag.as_ref().cloned() else {
return; return;
@@ -354,7 +354,7 @@ const SLIDER_TRACK_H: f32 = 8.0;
const SLIDER_THUMB: f32 = 12.0; const SLIDER_THUMB: f32 = 12.0;
impl Render for ControlPanel { impl Render for ControlPanel {
fn render(&mut self, _w: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, _w: &mut Window, cx: &mut Context<'_, Self>) -> impl IntoElement {
let theme = Theme::global(cx).clone(); let theme = Theme::global(cx).clone();
let modules: Vec<(String, String, String, Vec<Control>)> = match self.active_kind { let modules: Vec<(String, String, String, Vec<Control>)> = match self.active_kind {
Some(k) => self Some(k) => self
@@ -438,7 +438,7 @@ impl ControlPanel {
label: &str, label: &str,
description: &str, description: &str,
controls: &[Control], controls: &[Control],
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) -> gpui::Div { ) -> gpui::Div {
let collapsed = self.is_collapsed(module_id); let collapsed = self.is_collapsed(module_id);
let chevron = if collapsed { "" } else { "" }; let chevron = if collapsed { "" } else { "" };
@@ -510,7 +510,7 @@ impl ControlPanel {
theme: &Theme, theme: &Theme,
module_id: &str, module_id: &str,
c: &Control, c: &Control,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) -> gpui::Div { ) -> gpui::Div {
match c { match c {
Control::Toggle { Control::Toggle {
@@ -548,7 +548,7 @@ impl ControlPanel {
label: &str, label: &str,
default: bool, default: bool,
hotkey: Option<&str>, hotkey: Option<&str>,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) -> gpui::Div { ) -> gpui::Div {
let active = self let active = self
.toggle_state .toggle_state
@@ -606,7 +606,7 @@ impl ControlPanel {
min: f64, min: f64,
max: f64, max: f64,
default: f64, default: f64,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) -> gpui::Div { ) -> gpui::Div {
let value = self let value = self
.slider_state .slider_state
@@ -750,7 +750,7 @@ impl ControlPanel {
module_id: &str, module_id: &str,
key: &str, key: &str,
label: &str, label: &str,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) -> gpui::Div { ) -> gpui::Div {
let options: Vec<(String, String)> = self let options: Vec<(String, String)> = self
.chart_options .chart_options
@@ -777,7 +777,7 @@ impl ControlPanel {
label: &str, label: &str,
options: &[SelectOption], options: &[SelectOption],
default: &str, default: &str,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) -> gpui::Div { ) -> gpui::Div {
let opts: Vec<(String, String)> = options let opts: Vec<(String, String)> = options
.iter() .iter()
@@ -801,7 +801,7 @@ impl ControlPanel {
placeholder: &str, placeholder: &str,
options: &[(String, String)], options: &[(String, String)],
include_auto: bool, include_auto: bool,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) -> gpui::Div { ) -> gpui::Div {
let current_value = self let current_value = self
.string_state .string_state
@@ -877,7 +877,7 @@ impl ControlPanel {
key: &str, key: &str,
options: &[(String, String)], options: &[(String, String)],
include_auto: bool, include_auto: bool,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) -> gpui::Div { ) -> gpui::Div {
let mut popup = div() let mut popup = div()
.absolute() .absolute()
@@ -330,7 +330,7 @@ pub fn parse_city_atlas_tsv(content: &str) -> Vec<CityPreset> {
impl EventEmitter<TreeEvent> for TahuantinsuyuTree {} impl EventEmitter<TreeEvent> for TahuantinsuyuTree {}
impl TahuantinsuyuTree { impl TahuantinsuyuTree {
pub fn new(store: Store, cx: &mut Context<Self>) -> Self { pub fn new(store: Store, cx: &mut Context<'_, Self>) -> Self {
cx.observe_global::<Theme>(|_, cx| cx.notify()).detach(); cx.observe_global::<Theme>(|_, cx| cx.notify()).detach();
let inner = cx.new(|cx| TreeView::new("tahuantinsuyu-tree", cx)); let inner = cx.new(|cx| TreeView::new("tahuantinsuyu-tree", cx));
@@ -373,14 +373,14 @@ impl TahuantinsuyuTree {
/// Reemplaza el atlas de ciudades del dropdown. La app llama esto /// Reemplaza el atlas de ciudades del dropdown. La app llama esto
/// al boot si encuentra un archivo TSV custom en disco. /// al boot si encuentra un archivo TSV custom en disco.
pub fn set_city_atlas(&mut self, atlas: Vec<CityPreset>, cx: &mut Context<Self>) { pub fn set_city_atlas(&mut self, atlas: Vec<CityPreset>, cx: &mut Context<'_, Self>) {
if !atlas.is_empty() { if !atlas.is_empty() {
self.city_atlas = atlas; self.city_atlas = atlas;
cx.notify(); cx.notify();
} }
} }
pub fn refresh(&mut self, cx: &mut Context<Self>) { pub fn refresh(&mut self, cx: &mut Context<'_, Self>) {
let mut rows = Vec::new(); let mut rows = Vec::new();
self.append_groups(None, 0, &mut rows); self.append_groups(None, 0, &mut rows);
self.append_contacts(None, 0, &mut rows); self.append_contacts(None, 0, &mut rows);
@@ -391,7 +391,7 @@ impl TahuantinsuyuTree {
/// Cuando hay filtro, expande automáticamente los ancestros que /// Cuando hay filtro, expande automáticamente los ancestros que
/// contienen matches para que el usuario vea los resultados sin /// contienen matches para que el usuario vea los resultados sin
/// tener que clickear chevrons. /// tener que clickear chevrons.
fn set_search_filter(&mut self, filter: String, cx: &mut Context<Self>) { fn set_search_filter(&mut self, filter: String, cx: &mut Context<'_, Self>) {
self.search_filter = filter.trim().to_lowercase(); self.search_filter = filter.trim().to_lowercase();
if !self.search_filter.is_empty() { if !self.search_filter.is_empty() {
self.auto_expand_matches(); self.auto_expand_matches();
@@ -584,7 +584,7 @@ impl TahuantinsuyuTree {
} }
} }
fn on_inner(&mut self, ev: &InnerTreeEvent, cx: &mut Context<Self>) { fn on_inner(&mut self, ev: &InnerTreeEvent, cx: &mut Context<'_, Self>) {
match ev { match ev {
InnerTreeEvent::ChevronToggled(id) => { InnerTreeEvent::ChevronToggled(id) => {
let s = id.as_str().to_string(); let s = id.as_str().to_string();
@@ -626,20 +626,20 @@ impl TahuantinsuyuTree {
// Acciones del menú // Acciones del menú
// ----------------------------------------------------------------- // -----------------------------------------------------------------
fn close_menu(&mut self, cx: &mut Context<Self>) { fn close_menu(&mut self, cx: &mut Context<'_, Self>) {
if self.menu.take().is_some() { if self.menu.take().is_some() {
cx.notify(); cx.notify();
} }
} }
fn close_modal(&mut self, cx: &mut Context<Self>) { fn close_modal(&mut self, cx: &mut Context<'_, Self>) {
if self.modal.take().is_some() { if self.modal.take().is_some() {
self.city_picker_open = false; self.city_picker_open = false;
cx.notify(); cx.notify();
} }
} }
fn toggle_city_picker(&mut self, cx: &mut Context<Self>) { fn toggle_city_picker(&mut self, cx: &mut Context<'_, Self>) {
self.city_picker_open = !self.city_picker_open; self.city_picker_open = !self.city_picker_open;
cx.notify(); cx.notify();
} }
@@ -647,7 +647,7 @@ impl TahuantinsuyuTree {
/// Aplica un city preset al ChartForm activo (CreateChart o /// Aplica un city preset al ChartForm activo (CreateChart o
/// EditChart). Setea place, lat, lon, tz_offset_min vía /// EditChart). Setea place, lat, lon, tz_offset_min vía
/// `TextInput::set_text` y cierra el picker. /// `TextInput::set_text` y cierra el picker.
fn apply_city_preset(&mut self, preset: &CityPreset, cx: &mut Context<Self>) { fn apply_city_preset(&mut self, preset: &CityPreset, cx: &mut Context<'_, Self>) {
let form = match self.modal.as_mut() { let form = match self.modal.as_mut() {
Some(Modal::CreateChart { form, .. }) => form, Some(Modal::CreateChart { form, .. }) => form,
Some(Modal::EditChart { form, .. }) => form, Some(Modal::EditChart { form, .. }) => form,
@@ -677,7 +677,7 @@ impl TahuantinsuyuTree {
&mut self, &mut self,
parent: Option<GroupId>, parent: Option<GroupId>,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
let input = self.make_input("Nombre del grupo", "", window, cx); let input = self.make_input("Nombre del grupo", "", window, cx);
self.modal = Some(Modal::CreateGroup { parent, input }); self.modal = Some(Modal::CreateGroup { parent, input });
@@ -688,7 +688,7 @@ impl TahuantinsuyuTree {
&mut self, &mut self,
group: Option<GroupId>, group: Option<GroupId>,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
let input = self.make_input("Nombre del contacto", "", window, cx); let input = self.make_input("Nombre del contacto", "", window, cx);
self.modal = Some(Modal::CreateContact { group, input }); self.modal = Some(Modal::CreateContact { group, input });
@@ -699,7 +699,7 @@ impl TahuantinsuyuTree {
&mut self, &mut self,
id: ChartId, id: ChartId,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
// Cargar la carta existente; si no se puede, fallamos en silencio. // Cargar la carta existente; si no se puede, fallamos en silencio.
let chart = match self.store.get_chart(id) { let chart = match self.store.get_chart(id) {
@@ -751,7 +751,7 @@ impl TahuantinsuyuTree {
&mut self, &mut self,
contact: ContactId, contact: ContactId,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
// Pre-cargamos el nombre del contacto en el campo "Sujeto" del // Pre-cargamos el nombre del contacto en el campo "Sujeto" del
// form como conveniencia — la mayoría de las cartas se nombran // form como conveniencia — la mayoría de las cartas se nombran
@@ -795,7 +795,7 @@ impl TahuantinsuyuTree {
self.close_menu(cx); self.close_menu(cx);
} }
fn open_rename(&mut self, target: MenuTarget, window: &mut Window, cx: &mut Context<Self>) { fn open_rename(&mut self, target: MenuTarget, window: &mut Window, cx: &mut Context<'_, Self>) {
let modal = match target { let modal = match target {
MenuTarget::Group(id) => { MenuTarget::Group(id) => {
let current = self let current = self
@@ -847,7 +847,7 @@ impl TahuantinsuyuTree {
placeholder: &str, placeholder: &str,
initial: &str, initial: &str,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) -> Entity<TextInput> { ) -> Entity<TextInput> {
let placeholder = placeholder.to_string(); let placeholder = placeholder.to_string();
let input = cx.new(|cx| { let input = cx.new(|cx| {
@@ -862,14 +862,14 @@ impl TahuantinsuyuTree {
input input
} }
fn on_input_event(&mut self, ev: &TextInputEvent, cx: &mut Context<Self>) { fn on_input_event(&mut self, ev: &TextInputEvent, cx: &mut Context<'_, Self>) {
match ev { match ev {
TextInputEvent::Cancelled => self.close_modal(cx), TextInputEvent::Cancelled => self.close_modal(cx),
TextInputEvent::Confirmed(value) => self.submit_modal(value.clone(), cx), TextInputEvent::Confirmed(value) => self.submit_modal(value.clone(), cx),
} }
} }
fn submit_modal(&mut self, value: String, cx: &mut Context<Self>) { fn submit_modal(&mut self, value: String, cx: &mut Context<'_, Self>) {
let trimmed = value.trim().to_string(); let trimmed = value.trim().to_string();
// Tomamos ownership del modal — si el submit falla en mitad, // Tomamos ownership del modal — si el submit falla en mitad,
// lo restablecemos. Esto evita un borrow-mut sobre self.modal. // lo restablecemos. Esto evita un borrow-mut sobre self.modal.
@@ -1012,7 +1012,7 @@ impl TahuantinsuyuTree {
} }
} }
fn after_mutation(&mut self, cx: &mut Context<Self>) { fn after_mutation(&mut self, cx: &mut Context<'_, Self>) {
self.modal = None; self.modal = None;
self.refresh(cx); self.refresh(cx);
cx.emit(TreeEvent::HierarchyChanged); cx.emit(TreeEvent::HierarchyChanged);
@@ -1023,7 +1023,7 @@ impl TahuantinsuyuTree {
&mut self, &mut self,
target: MenuTarget, target: MenuTarget,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) { ) {
let (label, kind) = match target { let (label, kind) = match target {
MenuTarget::Group(_) => ("este grupo (incluye sus subgrupos y contactos)", "group"), MenuTarget::Group(_) => ("este grupo (incluye sus subgrupos y contactos)", "group"),
@@ -1072,7 +1072,7 @@ impl TahuantinsuyuTree {
fn build_chart_from_form( fn build_chart_from_form(
form: &ChartForm, form: &ChartForm,
cx: &mut Context<TahuantinsuyuTree>, cx: &mut Context<'_, TahuantinsuyuTree>,
) -> Result<(StoredBirthData, String), String> { ) -> Result<(StoredBirthData, String), String> {
let name = form.name.read(cx).text().trim().to_string(); let name = form.name.read(cx).text().trim().to_string();
let place = form.place.read(cx).text().trim().to_string(); let place = form.place.read(cx).text().trim().to_string();
@@ -1208,7 +1208,7 @@ fn parse_row(id: &RowId) -> Option<TreeSelection> {
const MENU_WIDTH: f32 = 220.0; const MENU_WIDTH: f32 = 220.0;
impl Render for TahuantinsuyuTree { impl Render for TahuantinsuyuTree {
fn render(&mut self, _w: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, _w: &mut Window, cx: &mut Context<'_, Self>) -> impl IntoElement {
let theme = Theme::global(cx).clone(); let theme = Theme::global(cx).clone();
let search_bar = div() let search_bar = div()
.px(px(6.0)) .px(px(6.0))
@@ -1242,7 +1242,7 @@ impl TahuantinsuyuTree {
&self, &self,
theme: &Theme, theme: &Theme,
menu: MenuState, menu: MenuState,
cx: &mut Context<Self>, cx: &mut Context<'_, Self>,
) -> impl IntoElement { ) -> impl IntoElement {
let mut items = div() let mut items = div()
.flex() .flex()
@@ -1353,7 +1353,7 @@ impl TahuantinsuyuTree {
.child(items) .child(items)
} }
fn render_modal(&self, theme: &Theme, cx: &mut Context<Self>) -> impl IntoElement { fn render_modal(&self, theme: &Theme, cx: &mut Context<'_, Self>) -> impl IntoElement {
let modal = self.modal.as_ref().expect("render_modal sin modal activo"); let modal = self.modal.as_ref().expect("render_modal sin modal activo");
let inner = match modal { let inner = match modal {
Modal::RenameGroup { input, .. } Modal::RenameGroup { input, .. }
@@ -1454,7 +1454,7 @@ fn render_chart_form(
title: &str, title: &str,
form: &ChartForm, form: &ChartForm,
error: Option<SharedString>, error: Option<SharedString>,
cx: &mut Context<TahuantinsuyuTree>, cx: &mut Context<'_, TahuantinsuyuTree>,
) -> gpui::Div { ) -> gpui::Div {
let labeled = |label: &'static str, input: Entity<TextInput>| -> gpui::Div { let labeled = |label: &'static str, input: Entity<TextInput>| -> gpui::Div {
div() div()