⎇ d3649bfd1a80153652c2a028315369bb4b184024
crates/apps/tahuantinsuyu/src/main.rs
History
Who touched what
raw
feat(tahuantinsuyu): scaffolding del estudio astrológico (10 crates + ventana 3-panes)
1//! Tahuantinsuyu — binario standalone.
2//!
3//! Boot:
4//! 1. `tahuantinsuyu_card::spawn_sidecar()` se presenta al Init brahman
5//! (fire-and-forget; si no hay Init, la app sigue standalone).
6//! 2. Abre la DB SQLite en `$XDG_DATA_HOME/tahuantinsuyu/charts.db`
7//! (fallback a `~/.local/share/tahuantinsuyu/charts.db`).
8//! 3. Levanta GPUI con [`yahweh_theme::Theme::install_default`].
9//! 4. Compone el shell: [`Shell`] dueño del tree (izq), canvas (centro)
10//! y panel (abajo). Cablea las suscripciones cross-widget.
11//!
12//! ## Layout
13//!
14//! ```text
15//! ┌───────────┬────────────────────────────────────────┐
16//! │ │ │
17//! │ tree │ canvas │
18//! │ (groups, │ (rueda / thumbnails) │
19//! │ contacts,│ │
20//! │ charts) │ │
21//! │ │ │
22//! ├───────────┴────────────────────────────────────────┤
23//! │ control panel (módulos) │
24//! └─────────────────────────────────────────────────────┘
25//! ```
26
27mod shell;
28
29use std::path::PathBuf;
30
31use gpui::{
32 App, AppContext, Application, Bounds, SharedString, TitlebarOptions, WindowBounds,
33 WindowOptions, px, size,
34};
35
36use tahuantinsuyu_store::Store;
37use yahweh_theme::Theme;
38
39use crate::shell::Shell;
40
41const DB_FILENAME: &str = "charts.db";
42const APP_TITLE: &str = "Tahuantinsuyu";
43
44fn main() {
45 // Sidecar brahman primero — si el Init está corriendo, nos presentamos.
46 tahuantinsuyu_card::spawn_sidecar();
47
48 // DB en directorio de datos del usuario.
49 let db_path = resolve_db_path();
50 let store = match Store::open(&db_path) {
51 Ok(s) => s,
52 Err(e) => {
53 eprintln!(
54 "[tahuantinsuyu] no se pudo abrir la DB en {:?}: {} — usando memoria",
55 db_path, e
56 );
57 Store::in_memory().expect("in-memory store")
58 }
59 };
60
61 Application::new().run(move |cx: &mut App| {
62 Theme::install_default(cx);
63
64 let bounds = Bounds::centered(None, size(px(1400.0), px(900.0)), cx);
65 cx.open_window(
66 WindowOptions {
67 window_bounds: Some(WindowBounds::Windowed(bounds)),
68 titlebar: Some(TitlebarOptions {
69 title: Some(SharedString::from(APP_TITLE)),
70 ..Default::default()
71 }),
72 ..Default::default()
73 },
74 move |_w, cx| cx.new(|cx| Shell::new(store.clone(), cx)),
75 )
76 .expect("open window");
77 cx.activate(true);
78 });
79}
80
81fn resolve_db_path() -> PathBuf {
82 if let Some(dirs) = directories::ProjectDirs::from("net", "gioser", "tahuantinsuyu") {
83 let dir = dirs.data_dir().to_path_buf();
84 let _ = std::fs::create_dir_all(&dir);
85 return dir.join(DB_FILENAME);
86 }
87 PathBuf::from(DB_FILENAME)
88}