Ely-built primitives plus gallery demos for every chapter-one entry, including gpui natives. The gallery now scripts real input by posting NSEvents to its own queue and shoots each interaction in both modes. Codex gpt-6-astra (max): three rounds; the last finding, a two-line doc comment, was fixed after the three-review cap.
77 lines
2.3 KiB
Rust
77 lines
2.3 KiB
Rust
mod capture;
|
|
mod pages;
|
|
mod probe;
|
|
mod script;
|
|
mod shell;
|
|
mod ui;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use anyhow::{Context as _, Result, bail};
|
|
use ely_gpui_component::Assets;
|
|
use gpui::{
|
|
App, AppContext, Application, Bounds, KeyBinding, TitlebarOptions, WindowBounds, WindowOptions,
|
|
actions, point, px, size,
|
|
};
|
|
|
|
actions!(gallery, [Quit]);
|
|
|
|
struct Args {
|
|
page: usize,
|
|
capture: Option<PathBuf>,
|
|
}
|
|
|
|
fn parse_args() -> Result<Args> {
|
|
let mut args = Args {
|
|
page: 0,
|
|
capture: None,
|
|
};
|
|
let mut iter = std::env::args().skip(1);
|
|
while let Some(flag) = iter.next() {
|
|
let value = iter
|
|
.next()
|
|
.with_context(|| format!("{flag} needs a value"))?;
|
|
match flag.as_str() {
|
|
"--page" => {
|
|
args.page = pages::find(&value).with_context(|| format!("no page {value}"))?
|
|
}
|
|
"--capture" => args.capture = Some(PathBuf::from(value)),
|
|
other => bail!("unknown flag {other}"),
|
|
}
|
|
}
|
|
Ok(args)
|
|
}
|
|
|
|
fn main() -> Result<()> {
|
|
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
|
|
let args = parse_args()?;
|
|
Application::new()
|
|
.with_assets(Assets)
|
|
.run(move |cx: &mut App| {
|
|
ely_gpui_component::init(cx);
|
|
cx.bind_keys([KeyBinding::new("cmd-q", Quit, None)]);
|
|
cx.on_action(|_: &Quit, cx| cx.quit());
|
|
let bounds = Bounds::centered(None, size(px(1280.0), px(820.0)), cx);
|
|
let options = WindowOptions {
|
|
window_bounds: Some(WindowBounds::Windowed(bounds)),
|
|
titlebar: Some(TitlebarOptions {
|
|
title: Some("Ely".into()),
|
|
appears_transparent: true,
|
|
traffic_light_position: Some(point(px(16.0), px(18.0))),
|
|
}),
|
|
window_min_size: Some(size(px(880.0), px(560.0))),
|
|
..Default::default()
|
|
};
|
|
let window = cx
|
|
.open_window(options, |window, cx| {
|
|
cx.new(|cx| shell::Gallery::new(args.page, window, cx))
|
|
})
|
|
.expect("gallery window failed to open");
|
|
cx.activate(true);
|
|
if let Some(dir) = args.capture {
|
|
capture::run(window, dir, cx);
|
|
}
|
|
});
|
|
Ok(())
|
|
}
|