Files
novem/src/app.rs

60 lines
1.4 KiB
Rust
Raw Normal View History

2026-04-20 15:13:26 +01:00
use gpui::{div, prelude::*};
use crate::dashboard;
2026-04-21 11:50:04 +01:00
use crate::query;
2026-04-20 15:13:26 +01:00
use crate::theme;
use crate::titlebar;
2026-04-21 11:50:04 +01:00
use crate::{api, app};
2026-04-20 15:13:26 +01:00
pub struct Global {
pub safe_area: gpui::Bounds<gpui::Pixels>,
pub current_theme: theme::Theme,
}
pub struct Chrome {}
impl Chrome {
pub fn new(window: &mut gpui::Window, cx: &mut gpui::Context<Self>) -> Self {
cx.observe_window_appearance(window, |_, window, cx| {
2026-04-21 11:50:04 +01:00
cx.update_global::<app::Global, ()>(|global, cx| {
2026-04-20 15:13:26 +01:00
global.current_theme = window.appearance().into();
2026-04-21 11:50:04 +01:00
cx.notify();
2026-04-20 15:13:26 +01:00
});
})
.detach();
Self {}
}
}
impl gpui::Render for Chrome {
fn render(
&mut self,
_window: &mut gpui::Window,
cx: &mut gpui::Context<Self>,
) -> impl gpui::IntoElement {
2026-04-21 11:50:04 +01:00
let title_bar = cx.new(|cx| titlebar::TitleBar::new(cx));
2026-04-20 15:13:26 +01:00
let dashboard = cx.new(|_| dashboard::Screen {
text: "World".into(),
});
div()
2026-04-21 11:50:04 +01:00
.flex()
2026-04-20 15:13:26 +01:00
.flex_col()
2026-04-21 11:50:04 +01:00
.size_full()
2026-04-20 15:13:26 +01:00
.child(title_bar)
.child(dashboard)
}
}
impl gpui::Global for Global {}
pub fn current_theme<'a, E>(cx: &'a gpui::Context<E>) -> &'a theme::Theme {
&cx.global::<Global>().current_theme
}
2026-04-20 22:54:31 +01:00
pub fn query_store<'a, E>(cx: &'a gpui::Context<E>) -> &'a query::Store<api::QueryContext> {
2026-04-21 11:50:04 +01:00
cx.global::<query::Store<api::QueryContext>>()
2026-04-20 15:13:26 +01:00
}