Download kernel/src/desktop/start_menu.rs from Jaswanth-2008/AeroOS: direct link, hf CLI and curl.
- Browser
- Download file 6.62 kB
-
https://huggingface.co/Jaswanth-2008/AeroOS/resolve/main/kernel/src/desktop/start_menu.rs
- Command line
-
hf download hf://Jaswanth-2008/AeroOS/kernel/src/desktop/start_menu.rs
-
curl -L -o start_menu.rs https://huggingface.co/Jaswanth-2008/AeroOS/resolve/main/kernel/src/desktop/start_menu.rs
6.62 kB
| extern crate alloc; | |
| use crate::apps::AppType; | |
| use crate::graphics::color::Color; | |
| use crate::graphics::icons::IconType; | |
| use crate::graphics::surface::Surface; | |
| pub const START_MENU_W: usize = 420; | |
| pub const START_MENU_H: usize = 400; | |
| pub struct StartApp { | |
| pub name: &'static str, | |
| pub icon: IconType, | |
| pub app_type: AppType, | |
| pub color: Color, | |
| } | |
| pub static START_APPS: [StartApp; 8] = [ | |
| StartApp { name: "Terminal", icon: IconType::Terminal, app_type: AppType::Terminal, color: Color::ACCENT_CYAN }, | |
| StartApp { name: "Wi-Fi", icon: IconType::Network, app_type: AppType::WifiManager, color: Color::rgb(0, 198, 255) }, | |
| StartApp { name: "Explorer", icon: IconType::FileManager, app_type: AppType::FileManager, color: Color::rgb(255, 185, 0) }, | |
| StartApp { name: "Snap Store", icon: IconType::OsLogo, app_type: AppType::SnapStore, color: Color::rgb(233, 84, 32) }, | |
| StartApp { name: "Network", icon: IconType::Network, app_type: AppType::NetManager, color: Color::rgb(0, 120, 215) }, | |
| StartApp { name: "Activity", icon: IconType::TaskManager, app_type: AppType::SysInfo, color: Color::rgb(16, 124, 65) }, | |
| StartApp { name: "Notepad", icon: IconType::Editor, app_type: AppType::Editor, color: Color::rgb(0, 153, 188) }, | |
| StartApp { name: "Settings", icon: IconType::Settings, app_type: AppType::Settings, color: Color::rgb(200, 200, 200) }, | |
| ]; | |
| pub enum StartMenuClickResult { | |
| Launch(AppType), | |
| PowerRestart, | |
| InsideMenu, | |
| } | |
| pub fn get_start_menu_bounds(screen_w: usize, screen_h: usize) -> (i32, i32, usize, usize) { | |
| let start_x = ((screen_w as i32) - (START_MENU_W as i32)) / 2; | |
| let start_y = (screen_h as i32) - 44 - (START_MENU_H as i32) - 10; | |
| (start_x, start_y, START_MENU_W, START_MENU_H) | |
| } | |
| pub fn handle_start_click(mouse_x: i32, mouse_y: i32, screen_w: usize, screen_h: usize) -> Option<StartMenuClickResult> { | |
| let (sx, sy, sw, sh) = get_start_menu_bounds(screen_w, screen_h); | |
| if mouse_x < sx || mouse_x >= sx + sw as i32 || mouse_y < sy || mouse_y >= sy + sh as i32 { | |
| return None; | |
| } | |
| let rel_x = mouse_x - sx; | |
| let rel_y = mouse_y - sy; | |
| // 1. Pinned Apps Grid (y = 80..220, 2 rows of 4 columns) | |
| if rel_y >= 80 && rel_y < 220 && rel_x >= 20 && rel_x < sw as i32 - 20 { | |
| let grid_x = rel_x - 20; | |
| let col_w = (sw as i32 - 40) / 4; | |
| let col = grid_x / col_w; | |
| let grid_y = rel_y - 80; | |
| let row_h = 70; | |
| let row = grid_y / row_h; | |
| if col >= 0 && col < 4 && row >= 0 && row < 2 { | |
| let idx = (row * 4 + col) as usize; | |
| if idx < START_APPS.len() { | |
| return Some(StartMenuClickResult::Launch(START_APPS[idx].app_type)); | |
| } | |
| } | |
| } | |
| // 2. Recommended Recent items (y = 260..340) | |
| if rel_y >= 260 && rel_y < 300 { | |
| return Some(StartMenuClickResult::Launch(AppType::Editor)); | |
| } | |
| // 3. Bottom Footer (Power Button: far right of footer) | |
| let footer_y = sh as i32 - 44; | |
| if rel_y >= footer_y { | |
| if rel_x >= sw as i32 - 70 { | |
| return Some(StartMenuClickResult::PowerRestart); | |
| } | |
| } | |
| Some(StartMenuClickResult::InsideMenu) | |
| } | |
| pub fn render_start_menu(surface: &mut Surface) { | |
| let (sx, sy, sw, sh) = get_start_menu_bounds(surface.width, surface.height); | |
| // 1. Soft Drop Shadow | |
| surface.draw_drop_shadow(sx, sy, sw, sh, 16, 12); | |
| // 2. Windows 11 Acrylic Mica Surface | |
| surface.draw_rounded_rect(sx, sy, sw, sh, 12, Color::rgba(30, 34, 46, 248)); | |
| surface.draw_rect_outline(sx, sy, sw, sh, Color::rgba(255, 255, 255, 32), 1); | |
| // 3. Search Box | |
| let search_w = sw - 40; | |
| surface.draw_rounded_rect(sx + 20, sy + 18, search_w, 36, 6, Color::rgb(42, 46, 60)); | |
| surface.draw_rect_outline(sx + 20, sy + 18, search_w, 36, Color::rgba(255, 255, 255, 20), 1); | |
| surface.draw_text("Search apps, settings, and files...", sx + 34, sy + 28, Color::rgb(170, 180, 195)); | |
| // 4. "Pinned" Section Header | |
| surface.draw_text("Pinned", sx + 24, sy + 64, Color::WHITE); | |
| surface.draw_text("All apps >", sx + sw as i32 - 96, sy + 64, Color::rgb(0, 150, 255)); | |
| // 5. Pinned Apps (4 columns x 2 rows) | |
| let col_w = (sw as i32 - 40) / 4; | |
| for (idx, app) in START_APPS.iter().enumerate() { | |
| let col = (idx % 4) as i32; | |
| let row = (idx / 4) as i32; | |
| let item_x = sx + 20 + col * col_w; | |
| let item_y = sy + 84 + row * 66; | |
| // Subtle hover card | |
| surface.draw_rounded_rect(item_x + 6, item_y, col_w as usize - 12, 60, 6, Color::rgba(255, 255, 255, 6)); | |
| // App Icon | |
| let icon_x = item_x + (col_w / 2) - 8; | |
| surface.draw_icon_16(app.icon, icon_x, item_y + 10, app.color); | |
| // App Name (centered) | |
| let name_w = app.name.len() as i32 * 8; | |
| let name_x = item_x + (col_w / 2) - (name_w / 2); | |
| surface.draw_text(app.name, name_x, item_y + 36, Color::WHITE); | |
| } | |
| // 6. "Recommended" Section | |
| let rec_y = sy + 224; | |
| surface.draw_text("Recommended", sx + 24, rec_y, Color::WHITE); | |
| // Recent item 1: welcome.txt | |
| surface.draw_rounded_rect(sx + 20, rec_y + 18, (search_w / 2) - 6, 40, 6, Color::rgba(255, 255, 255, 8)); | |
| surface.draw_icon_16(IconType::Editor, sx + 28, rec_y + 30, Color::rgb(0, 153, 188)); | |
| surface.draw_text("welcome.txt", sx + 52, rec_y + 24, Color::WHITE); | |
| surface.draw_text("Recently opened", sx + 52, rec_y + 38, Color::TEXT_MUTED); | |
| // Recent item 2: network.cfg | |
| let rec2_x = sx + 20 + (search_w as i32 / 2) + 6; | |
| surface.draw_rounded_rect(rec2_x, rec_y + 18, (search_w / 2) - 6, 40, 6, Color::rgba(255, 255, 255, 8)); | |
| surface.draw_icon_16(IconType::Network, rec2_x + 8, rec_y + 30, Color::rgb(0, 120, 215)); | |
| surface.draw_text("network.cfg", rec2_x + 32, rec_y + 24, Color::WHITE); | |
| surface.draw_text("VirtIO adapter", rec2_x + 32, rec_y + 38, Color::TEXT_MUTED); | |
| // 7. User Profile & Power Bottom Bar | |
| let footer_y = sy + sh as i32 - 46; | |
| surface.draw_rect(sx, footer_y, sw, 46, Color::rgb(22, 25, 34)); | |
| surface.draw_rect(sx, footer_y, sw, 1, Color::rgba(255, 255, 255, 18)); | |
| // User Avatar circle | |
| surface.draw_rounded_rect(sx + 20, footer_y + 8, 30, 30, 15, Color::rgb(0, 120, 215)); | |
| surface.draw_text("S", sx + 31, footer_y + 14, Color::WHITE); | |
| surface.draw_text("Sunny", sx + 58, footer_y + 15, Color::WHITE); | |
| // Power / Restart Button | |
| surface.draw_rounded_rect(sx + sw as i32 - 64, footer_y + 8, 48, 30, 6, Color::rgba(255, 255, 255, 10)); | |
| surface.draw_text("Power", sx + sw as i32 - 58, footer_y + 15, Color::rgb(255, 100, 100)); | |
| } | |