Windows shell replacement in Rust: taskbar, file manager, NTFS search, task manager, disk cleaner. One installer exe.
Rust
Ruby style; rust-explorer: pin folders to Quick access
Lemxy2989c14e2dff
diff --git a/README.md b/README.mdindex 578ddd4..aeb5d2e 100644--- a/README.md+++ b/README.md@@ -60,6 +60,7 @@ The gear at the left end of the bar opens **Style**. The choice applies at once| **Floating dock** | A pill-shaped bar in the middle; maximized windows get the whole screen, the dock slides away over them and comes back at the bottom edge || **Tiling** | A thin bar at the top, amber accent, rounded like Normal; "Tile the windows" puts the open windows side by side || **White road** | Light ivory with gold: faint low-poly triangles, some traced in gold, behind the bar, its panels and rust-settings |+| **Ruby** | Deep garnet with a bright ruby accent: a smooth top-to-bottom gradient with a soft gloss, behind the bar and its panels |The choice is stored in `%ProgramData%\WinRust\style.txt`.diff --git a/README.ru.md b/README.ru.mdindex e6ac42e..11b15c7 100644--- a/README.ru.md+++ b/README.ru.md@@ -60,6 +60,7 @@| **Плавающий док** | Панель-пилюля по центру; развёрнутые окна занимают весь экран, док уезжает из-под них и возвращается у нижнего края || **Тайлинг** | Тонкая панель сверху, янтарный акцент, скругления как в Обычном; «Разложить окна плиткой» ставит открытые окна рядом || **Белая дорога** | Цвет слоновой кости с золотом: еле заметные треугольники, часть с золотой обводкой, за панелью, её окошками и rust-settings |+| **Рубин** | Глубокий гранатовый цвет с ярким рубиновым акцентом: плавный градиент сверху вниз с мягким глянцем, за панелью и её окошками |Выбор хранится в `%ProgramData%\WinRust\style.txt`.diff --git a/common/src/style.rs b/common/src/style.rsindex 81c4fc4..babe073 100644--- a/common/src/style.rs+++ b/common/src/style.rs@@ -13,9 +13,10 @@ pub enum Style {Dock, // the bar is a floating pill in the middleTiling, // a thin status strip at the top, windows side by sideRoad, // "White road": light ivory, faint triangles in the background+ Ruby, // deep ruby, a smooth glossy gradient}-pub const ALL: [Style; 5] = [Style::Normal, Style::Terminal, Style::Dock, Style::Tiling, Style::Road];+pub const ALL: [Style; 6] = [Style::Normal, Style::Terminal, Style::Dock, Style::Tiling, Style::Road, Style::Ruby];impl Style {pub fn name(self) -> &'static str {@@ -25,6 +26,7 @@ impl Style {Style::Dock => "dock",Style::Tiling => "tiling",Style::Road => "road",+ Style::Ruby => "ruby",}}/// Unknown or empty text (no file yet, a hand edit) is the normal style.@@ -141,7 +143,7 @@ pub const fn rgb(r: u8, g: u8, b: u8) -> u32 {}/// In the order of `ALL`. Neutral, low-contrast surfaces and one restrained accent (the look of macOS / modern fintech apps).-pub const PALS: [Pal; 5] = [+pub const PALS: [Pal; 6] = [// normal: graphite with the Apple system bluePal { bg: rgb(22, 22, 24), line: rgb(46, 46, 50), hover: rgb(36, 36, 40), active: rgb(44, 44, 49), accent: rgb(10, 132, 255), text: rgb(245, 245, 247), dim: rgb(142, 142, 147) },// terminal: green on black@@ -152,6 +154,8 @@ pub const PALS: [Pal; 5] = [Pal { bg: rgb(16, 17, 20), line: rgb(38, 40, 46), hover: rgb(27, 29, 34), active: rgb(35, 37, 43), accent: rgb(245, 182, 82), text: rgb(224, 226, 231), dim: rgb(120, 125, 138) },// white road: warm ivory with goldPal { bg: rgb(247, 245, 240), line: rgb(226, 220, 207), hover: rgb(238, 233, 222), active: rgb(232, 225, 210), accent: rgb(176, 134, 52), text: rgb(28, 26, 22), dim: rgb(124, 117, 104) },+ // ruby: deep garnet surfaces, a bright ruby accent, warm rose-white text+ Pal { bg: rgb(26, 7, 13), line: rgb(72, 22, 36), hover: rgb(46, 13, 24), active: rgb(60, 17, 31), accent: rgb(232, 52, 84), text: rgb(252, 238, 241), dim: rgb(178, 126, 139) },];/// Status colours shared by every style (Apple's dark-mode system green, yellow, red).@@ -170,7 +174,7 @@ pub fn card() -> u32 {/// Text and glyphs drawn on an accent fill.pub fn on_accent() -> u32 {- if style().light() { rgb(255, 255, 255) } else { pal().bg }+ if style().light() || style() == Style::Ruby { rgb(255, 255, 255) } else { pal().bg }}/// `a` moved toward `b` by `t` (0..1), per channel.@@ -186,7 +190,8 @@ pub fn mix(a: u32, b: u32, t: f32) -> u32 {/// Does nothing in the other styles. Needs GDI+ started (GdiplusStartup) by the program.pub unsafe fn backdrop(dc: windows_sys::Win32::Graphics::Gdi::HDC, r: windows_sys::Win32::Foundation::RECT, scale: f32) {use windows_sys::Win32::Graphics::GdiPlus::*;- if !style().light() {+ let ruby = style() == Style::Ruby;+ if !style().light() && !ruby {return;}let mut g: *mut GpGraphics = std::ptr::null_mut();@@ -194,6 +199,23 @@ pub unsafe fn backdrop(dc: windows_sys::Win32::Graphics::Gdi::HDC, r: windows_syreturn;}let argb = |c: u32, a: f32| ((a.clamp(0.0, 1.0) * 255.0) as u32) << 24 | (c & 255) << 16 | (c & 0xFF00) | (c >> 16 & 255);+ if ruby {+ // smooth: a vertical ruby gradient (lighter on top, near-black garnet below) and a soft gloss over the upper third+ let (x, y, w, h) = (r.left, r.top, (r.right - r.left).max(1), (r.bottom - r.top).max(1));+ unsafe {+ GdipSetSmoothingMode(g, SmoothingModeAntiAlias);+ let mut br: *mut GpLineGradient = std::ptr::null_mut();+ GdipCreateLineBrushI(&Point { X: x, Y: y }, &Point { X: x, Y: y + h }, argb(mix(pal().bg, rgb(150, 18, 42), 0.62), 1.0), argb(mix(pal().bg, rgb(0, 0, 0), 0.25), 1.0), WrapModeTileFlipXY, &mut br);+ GdipFillRectangleI(g, br as *mut GpBrush, x, y, w, h);+ GdipDeleteBrush(br as *mut GpBrush);+ let gh = (h / 3).max(1);+ GdipCreateLineBrushI(&Point { X: x, Y: y }, &Point { X: x, Y: y + gh }, argb(rgb(255, 255, 255), 0.09), argb(rgb(255, 255, 255), 0.0), WrapModeTileFlipXY, &mut br);+ GdipFillRectangleI(g, br as *mut GpBrush, x, y, w, gh);+ GdipDeleteBrush(br as *mut GpBrush);+ GdipDeleteGraphics(g);+ }+ return;+ }let (x0, y0, w, h) = (r.left as f32, r.top as f32, (r.right - r.left) as f32, (r.bottom - r.top) as f32);let s = 58.0 * scale.max(0.5);let (cols, rows) = ((w / s) as i32 + 2, (h / (s * 0.866)) as i32 + 2);diff --git a/plugins/rust-explorer/src/main.rs b/plugins/rust-explorer/src/main.rsindex 9bbf93c..c2df009 100644--- a/plugins/rust-explorer/src/main.rs+++ b/plugins/rust-explorer/src/main.rs@@ -156,6 +156,7 @@ fn paste(h: HWND, dir: &PathBuf) {const MENU_ZIP: u32 = 0x9001;const MENU_EXTRACT: u32 = 0x9002;+const MENU_PIN: u32 = 0x9003;/// The shell menu for the selection, with our "Compress to ZIP" / "Extract here" on top.fn item_menu(h: HWND, dir: &Path, paths: &[PathBuf]) {@@ -163,8 +164,10 @@ fn item_menu(h: HWND, dir: &Path, paths: &[PathBuf]) {if paths.iter().all(|p| p.is_file() && jobs::is_archive(p)) {extra.insert(0, (MENU_EXTRACT, "Extract here"));}+ if let [p] = paths { if p.is_dir() { extra.push((MENU_PIN, if ui::pins().contains(p) { "Unpin from Quick access" } else { "Pin to Quick access" })); } }let picked = sh::show(h, paths, if jobs::busy() { &[] } else { &extra }).ok().flatten();match picked {+ Some(MENU_PIN) => ui::toggle_pin(&paths[0]),Some(MENU_ZIP) => {let base = if paths.len() == 1 { paths[0].file_stem().unwrap_or_default().to_string_lossy().into_owned() } else { dir.file_name().map_or("Archive".into(), |n| n.to_string_lossy().into_owned()) };let dest = jobs::free_name(dir, &format!("{base}.zip"), false);diff --git a/plugins/rust-explorer/src/ui.rs b/plugins/rust-explorer/src/ui.rsindex 7ee9dd2..5a2d716 100644--- a/plugins/rust-explorer/src/ui.rs+++ b/plugins/rust-explorer/src/ui.rs@@ -698,6 +698,18 @@ pub unsafe extern "system" fn proc(h: HWND, m: u32, wp: WPARAM, lp: LPARAM) -> Lif BRUSH.get() == 0 { BRUSH.set(CreateSolidBrush(pill()) as isize); }return BRUSH.get();}+ WM_RBUTTONUP => {+ // right click on a pinned folder: unpin it+ if let Some(p) = nav_hit(y).and_then(nav_path).filter(|p| pins().contains(p)) {+ let menu = CreatePopupMenu();+ AppendMenuW(menu, MF_STRING, 1, w("Unpin from Quick access").as_ptr());+ let mut pt: POINT = std::mem::zeroed();+ GetCursorPos(&mut pt);+ let id = TrackPopupMenu(menu, TPM_RETURNCMD | TPM_RIGHTBUTTON, pt.x, pt.y, 0, h, ptr::null());+ DestroyMenu(menu);+ if id == 1 { toggle_pin(&p); }+ }+ }_ => return DefWindowProcW(h, m, wp, lp),}0@@ -724,6 +736,25 @@ thread_local! {static NAVHOT: Cell<i32> = const { Cell::new(-1) };}+/// Folders the user pinned to Quick access: %APPDATA%\WinRust\rust-explorer-pins.txt, one path per line.+fn pins_file() -> Option<PathBuf> { env::var_os("APPDATA").map(|a| PathBuf::from(a).join("WinRust").join("rust-explorer-pins.txt")) }++pub fn pins() -> Vec<PathBuf> {+ pins_file().and_then(|f| fs::read_to_string(f).ok()).map(|s| s.lines().map(str::trim).filter(|l| !l.is_empty()).map(PathBuf::from).collect()).unwrap_or_default()+}++/// Pins `p` (or unpins it when already pinned) and rebuilds the left pane.+pub fn toggle_pin(p: &Path) {+ let mut v = pins();+ if let Some(i) = v.iter().position(|x| x == p) { v.remove(i); } else { v.push(p.to_path_buf()); }+ if let Some(f) = pins_file() {+ if let Some(d) = f.parent() { let _ = fs::create_dir_all(d); }+ let _ = fs::write(f, v.iter().map(|x| x.to_string_lossy().into_owned()).collect::<Vec<_>>().join("\n"));+ }+ let h = NAVWND.get() as HWND;+ if !h.is_null() { nav_init(h); nav_dirty(); }+}+pub fn nav_init(h: HWND) {NAVWND.set(h as isize);let home = PathBuf::from(env::var_os("USERPROFILE").unwrap_or_default());@@ -734,6 +765,9 @@ pub fn nav_init(h: HWND) {let Some(p) = crate::sh::known_dir(id).filter(|p| p.is_dir()) else { continue };v.push(NavItem { title: t.into(), path: p, glyph: g, cap: None });}+ for p in pins() {+ if p.is_dir() { v.push(NavItem { title: p.file_name().map_or_else(|| p.to_string_lossy().into_owned(), |n| n.to_string_lossy().into_owned()), path: p, glyph: "\u{E718}", cap: None }); }+ }v.push(head("This PC"));unsafe {use windows_sys::Win32::Storage::FileSystem::{GetDiskFreeSpaceExW, GetDriveTypeW, GetLogicalDrives, GetVolumeInformationW};diff --git a/plugins/topbar/src/main.rs b/plugins/topbar/src/main.rsindex f7dd586..ac7cec8 100644--- a/plugins/topbar/src/main.rs+++ b/plugins/topbar/src/main.rs@@ -2295,7 +2295,7 @@ unsafe fn open_launcher() -> bool {/// The gear's menu: the UI style (saved for the other WinRust programs) and putting the windows side by side.unsafe fn style_menu() {let bar = BAR.load(Relaxed) as HWND;- let names = [t!("Обычный", "Normal"), t!("Терминал", "Terminal"), t!("Плавающий док", "Floating dock"), t!("Тайлинг", "Tiling"), t!("Белая дорога", "White road")];+ let names = [t!("Обычный", "Normal"), t!("Терминал", "Terminal"), t!("Плавающий док", "Floating dock"), t!("Тайлинг", "Tiling"), t!("Белая дорога", "White road"), t!("Рубин", "Ruby")];let mut items: Vec<fly::MItem> = i18n::style::ALL.iter().zip(names).map(|(&s, n)| fly::MItem::new(n).on(s == style())).collect();items.push(fly::MItem::new(t!("Разложить окна плиткой", "Tile the windows")).sep());items.push(fly::MItem::new(t!("Скрывать панель автоматически", "Hide the bar automatically")).on(i18n::style::autohide()));