2026-01-29 11:45:24 +05:30
|
|
|
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
|
|
|
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
|
|
|
|
2026-02-22 00:28:30 +05:30
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
2026-01-26 23:27:50 +05:30
|
|
|
use gpui::*;
|
2026-01-27 22:51:03 +05:30
|
|
|
use gpui_component::Root;
|
2026-02-22 00:28:30 +05:30
|
|
|
use gpui_component::{Theme, ThemeMode, ThemeSet};
|
2026-01-27 22:51:03 +05:30
|
|
|
use ui::rootview::ApplicationRoot;
|
2026-01-26 23:27:50 +05:30
|
|
|
|
|
|
|
|
mod device;
|
2026-02-20 22:29:39 +05:30
|
|
|
pub mod error;
|
2026-01-28 23:36:15 +05:30
|
|
|
pub mod logging;
|
2026-01-26 23:27:50 +05:30
|
|
|
mod ui;
|
|
|
|
|
|
|
|
|
|
fn main() {
|
2026-01-28 23:36:15 +05:30
|
|
|
logging::logger_init();
|
2026-01-28 17:29:07 +05:30
|
|
|
let app = Application::new().with_assets(ui::assets::Assets);
|
2026-01-26 23:27:50 +05:30
|
|
|
|
2026-01-28 17:29:07 +05:30
|
|
|
app.run(move |cx| {
|
|
|
|
|
gpui_component::init(cx);
|
|
|
|
|
Theme::change(ThemeMode::Dark, None, cx);
|
2026-01-26 23:27:50 +05:30
|
|
|
|
2026-02-22 00:28:30 +05:30
|
|
|
let theme_json = include_str!("../themes/picoforge-zinc.json");
|
|
|
|
|
if let Ok(theme_set) = serde_json::from_str::<ThemeSet>(theme_json) {
|
|
|
|
|
for config in theme_set.themes {
|
|
|
|
|
if config.mode == ThemeMode::Dark {
|
|
|
|
|
let config = Rc::new(config);
|
|
|
|
|
Theme::global_mut(cx).apply_config(&config);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-28 17:29:07 +05:30
|
|
|
cx.activate(true);
|
2026-01-26 23:27:50 +05:30
|
|
|
|
2026-02-18 16:40:51 +05:30
|
|
|
let mut window_size = size(px(1344.0), px(756.0));
|
2026-01-27 22:51:03 +05:30
|
|
|
|
2026-01-28 17:29:07 +05:30
|
|
|
// Basically, make sure that the window is max to max 85 percent size of the actual
|
|
|
|
|
// monitor/display, so the window does not get too big on small monitors.
|
|
|
|
|
if let Some(display) = cx.primary_display() {
|
|
|
|
|
let display_size = display.bounds().size;
|
2026-01-27 22:51:03 +05:30
|
|
|
|
2026-01-28 17:29:07 +05:30
|
|
|
window_size.width = window_size.width.min(display_size.width * 0.85);
|
|
|
|
|
window_size.height = window_size.height.min(display_size.height * 0.85);
|
|
|
|
|
}
|
2026-01-27 22:51:03 +05:30
|
|
|
|
2026-01-28 17:29:07 +05:30
|
|
|
let window_bounds = Bounds::centered(None, window_size, cx);
|
2026-01-26 23:27:50 +05:30
|
|
|
|
2026-01-28 17:29:07 +05:30
|
|
|
cx.spawn(async move |cx| {
|
|
|
|
|
let window_options = WindowOptions {
|
|
|
|
|
app_id: Some("in.suyogtandel.picoforge".into()),
|
2026-01-27 22:51:03 +05:30
|
|
|
|
2026-01-28 17:29:07 +05:30
|
|
|
window_bounds: Some(WindowBounds::Windowed(window_bounds)),
|
2026-01-27 22:51:03 +05:30
|
|
|
|
2026-01-28 17:29:07 +05:30
|
|
|
titlebar: Some(TitlebarOptions {
|
|
|
|
|
title: Some("PicoForge".into()),
|
|
|
|
|
appears_transparent: true,
|
|
|
|
|
// TODO: This option needs to be tested and adjusted on macos
|
|
|
|
|
traffic_light_position: Some(gpui::point(px(12.0), px(12.0))),
|
|
|
|
|
}),
|
2026-01-27 22:51:03 +05:30
|
|
|
|
2026-02-19 21:48:08 +05:30
|
|
|
// Render our own window decorations(shadows and resize attack area) for linux/bsd.
|
2026-01-28 17:29:07 +05:30
|
|
|
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
|
|
|
|
window_background: gpui::WindowBackgroundAppearance::Transparent,
|
|
|
|
|
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
|
|
|
|
window_decorations: Some(gpui::WindowDecorations::Client),
|
2026-01-27 22:51:03 +05:30
|
|
|
|
2026-01-28 17:29:07 +05:30
|
|
|
window_min_size: Some(gpui::Size {
|
2026-01-29 10:09:45 +05:30
|
|
|
width: px(450.),
|
|
|
|
|
height: px(200.),
|
2026-01-28 17:29:07 +05:30
|
|
|
}),
|
|
|
|
|
kind: WindowKind::Normal,
|
|
|
|
|
..Default::default()
|
|
|
|
|
};
|
2026-01-26 23:27:50 +05:30
|
|
|
|
2026-01-28 17:29:07 +05:30
|
|
|
cx.open_window(window_options, |window, cx| {
|
2026-02-20 22:29:39 +05:30
|
|
|
let view = cx.new(ApplicationRoot::new);
|
2026-01-28 17:29:07 +05:30
|
|
|
cx.new(|cx| Root::new(view, window, cx))
|
|
|
|
|
})?;
|
2026-01-26 23:27:50 +05:30
|
|
|
|
2026-01-28 17:29:07 +05:30
|
|
|
Ok::<_, anyhow::Error>(())
|
|
|
|
|
})
|
|
|
|
|
.detach();
|
|
|
|
|
});
|
2026-01-26 23:27:50 +05:30
|
|
|
}
|