From f404c59a78c5b033612bb548eb626467e060bd50 Mon Sep 17 00:00:00 2001 From: Ilya <47112191+ItsEeleeya@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:40:35 +0330 Subject: [PATCH 1/7] fix(desktop-gpui): anchor the mode picker capsule to its own width --- apps/desktop-gpui/src/tray/mac_mode_picker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/desktop-gpui/src/tray/mac_mode_picker.rs b/apps/desktop-gpui/src/tray/mac_mode_picker.rs index 843c9a0698f..f8a8b0f88df 100644 --- a/apps/desktop-gpui/src/tray/mac_mode_picker.rs +++ b/apps/desktop-gpui/src/tray/mac_mode_picker.rs @@ -334,7 +334,7 @@ impl ModePickerView { let bounds = self.bounds(); NSRect::new( NSPoint::new( - bounds.size.width - RIGHT_INSET - w, + picker_width() - RIGHT_INSET - w, (bounds.size.height - h) / 2.0, ), NSSize::new(w, h), From b43b7a6f1bc928722e5e04c89080e3002ea0fab1 Mon Sep 17 00:00:00 2001 From: Ilya <47112191+ItsEeleeya@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:40:37 +0330 Subject: [PATCH 2/7] =?UTF-8?q?feat(desktop-gpui):=20add=20File=20>=20Expo?= =?UTF-8?q?rt=E2=80=A6=20(=E2=87=A7=E2=8C=98E)=20to=20the=20editors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/desktop-gpui/locales/de.toml | 1 + apps/desktop-gpui/locales/en.toml | 1 + apps/desktop-gpui/locales/es.toml | 1 + apps/desktop-gpui/locales/fr.toml | 1 + apps/desktop-gpui/locales/hi.toml | 1 + apps/desktop-gpui/locales/ja.toml | 1 + apps/desktop-gpui/locales/zh-CN.toml | 1 + apps/desktop-gpui/src/editor_window.rs | 7 +++++++ apps/desktop-gpui/src/i18n/tests.rs | 1 + apps/desktop-gpui/src/menus.rs | 9 +++++++++ apps/desktop-gpui/src/screenshot_editor.rs | 5 +++++ 11 files changed, 29 insertions(+) diff --git a/apps/desktop-gpui/locales/de.toml b/apps/desktop-gpui/locales/de.toml index cb71a925e69..466d11edf60 100644 --- a/apps/desktop-gpui/locales/de.toml +++ b/apps/desktop-gpui/locales/de.toml @@ -35,6 +35,7 @@ title = "Ablage" open_file = "Datei öffnen…" open_recent = "Zuletzt geöffnet" import_media = "Medien importieren…" +export = "Exportieren…" [menu.edit] copy = "Kopieren" diff --git a/apps/desktop-gpui/locales/en.toml b/apps/desktop-gpui/locales/en.toml index a131b7e53b2..1a63d955476 100644 --- a/apps/desktop-gpui/locales/en.toml +++ b/apps/desktop-gpui/locales/en.toml @@ -35,6 +35,7 @@ title = "File" open_file = "Open File…" open_recent = "Open Recent" import_media = "Import Media…" +export = "Export…" [menu.edit] copy = "Copy" diff --git a/apps/desktop-gpui/locales/es.toml b/apps/desktop-gpui/locales/es.toml index a7f14bdb95a..aff4f1430e6 100644 --- a/apps/desktop-gpui/locales/es.toml +++ b/apps/desktop-gpui/locales/es.toml @@ -35,6 +35,7 @@ title = "Archivo" open_file = "Abrir archivo…" open_recent = "Abrir reciente" import_media = "Importar contenido…" +export = "Exportar…" [menu.edit] copy = "Copiar" diff --git a/apps/desktop-gpui/locales/fr.toml b/apps/desktop-gpui/locales/fr.toml index fc0ba2fb48d..ac5614f3337 100644 --- a/apps/desktop-gpui/locales/fr.toml +++ b/apps/desktop-gpui/locales/fr.toml @@ -35,6 +35,7 @@ title = "Fichier" open_file = "Ouvrir un fichier…" open_recent = "Ouvrir récent" import_media = "Importer des médias…" +export = "Exporter…" [menu.edit] copy = "Copier" diff --git a/apps/desktop-gpui/locales/hi.toml b/apps/desktop-gpui/locales/hi.toml index cb8580cf659..64e84a5f03e 100644 --- a/apps/desktop-gpui/locales/hi.toml +++ b/apps/desktop-gpui/locales/hi.toml @@ -35,6 +35,7 @@ title = "फ़ाइल" open_file = "फ़ाइल खोलें…" open_recent = "हाल ही में खोलें" import_media = "मीडिया इम्पोर्ट करें…" +export = "एक्सपोर्ट करें…" [menu.edit] copy = "कॉपी करें" diff --git a/apps/desktop-gpui/locales/ja.toml b/apps/desktop-gpui/locales/ja.toml index b399668f130..dcaa1c8f693 100644 --- a/apps/desktop-gpui/locales/ja.toml +++ b/apps/desktop-gpui/locales/ja.toml @@ -35,6 +35,7 @@ title = "ファイル" open_file = "ファイルを開く…" open_recent = "最近使った項目を開く" import_media = "メディアを読み込む…" +export = "書き出す…" [menu.edit] copy = "コピー" diff --git a/apps/desktop-gpui/locales/zh-CN.toml b/apps/desktop-gpui/locales/zh-CN.toml index 74f089d8082..5c14296526f 100644 --- a/apps/desktop-gpui/locales/zh-CN.toml +++ b/apps/desktop-gpui/locales/zh-CN.toml @@ -35,6 +35,7 @@ title = "文件" open_file = "打开文件…" open_recent = "打开最近使用" import_media = "导入媒体…" +export = "导出…" [menu.edit] copy = "拷贝" diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rs index 7ca98333774..1211d366813 100644 --- a/apps/desktop-gpui/src/editor_window.rs +++ b/apps/desktop-gpui/src/editor_window.rs @@ -11657,6 +11657,13 @@ impl Render for EditorWindow { .bg(self.root_bg()) .text_color(Hsla::from(theme.gray_12)) .track_focus(&self.focus) + .on_action( + cx.listener(|this, _: &crate::menus::ExportEditor, window, cx| { + if this.project_ready() { + this.open_export(window, cx); + } + }), + ) .capture_key_down(cx.listener(Self::capture_playback_key)) .on_key_down(cx.listener(Self::on_key)) // Only the cropper needs key-*up*: its nudge loop runs until every diff --git a/apps/desktop-gpui/src/i18n/tests.rs b/apps/desktop-gpui/src/i18n/tests.rs index 1d9f313b325..0ef4a83b7a1 100644 --- a/apps/desktop-gpui/src/i18n/tests.rs +++ b/apps/desktop-gpui/src/i18n/tests.rs @@ -27,6 +27,7 @@ fn english_matches_the_literals_it_replaced() { (tr::menu::file::open_file(), "Open File…".into()), (tr::menu::file::open_recent(), "Open Recent".into()), (tr::menu::file::import_media(), "Import Media…".into()), + (tr::menu::file::export(), "Export…".into()), (tr::menu::file::title(), "File".into()), (tr::menu::edit::copy(), "Copy".into()), (tr::menu::edit::cut(), "Cut".into()), diff --git a/apps/desktop-gpui/src/menus.rs b/apps/desktop-gpui/src/menus.rs index 675c96b63cb..c7269234e58 100644 --- a/apps/desktop-gpui/src/menus.rs +++ b/apps/desktop-gpui/src/menus.rs @@ -138,6 +138,9 @@ actions!( OpenSettings, OpenFile, ImportMedia, + /// File > Export… -- ⇧⌘E. Only an open editor handles it, so the item is + /// disabled everywhere else. + ExportEditor, Changelog, HelpDashboard, HelpDocs, @@ -340,6 +343,7 @@ pub(crate) fn bindings() -> Vec { KeyBinding::new("cmd-m", Minimize, None), KeyBinding::new("ctrl-cmd-f", ToggleFullscreen, None), KeyBinding::new("secondary-,", OpenSettings, None), + KeyBinding::new("shift-cmd-e", ExportEditor, None), ] } @@ -380,6 +384,8 @@ pub fn build_menus(update_status: &updates::UpdateStatus, settings_enabled: bool MenuItem::action(tr::menu::file::open_file(), OpenFile), MenuItem::action(tr::menu::file::import_media(), ImportMedia), MenuItem::separator(), + MenuItem::action(tr::menu::file::export(), ExportEditor), + MenuItem::separator(), MenuItem::action(tr::menu::file::close_window(), CloseWindow), ], }, @@ -1193,6 +1199,7 @@ mod tests { ("cmd-m", &Minimize), ("ctrl-cmd-f", &ToggleFullscreen), (settings, &OpenSettings), + ("shift-cmd-e", &ExportEditor), ]; let bindings = bindings(); assert_eq!(bindings.len(), expected.len()); @@ -1240,6 +1247,8 @@ mod tests { "Open File…".into(), "Import Media…".into(), "-".into(), + "Export…".into(), + "-".into(), "Close Window".into(), ]; assert_eq!( diff --git a/apps/desktop-gpui/src/screenshot_editor.rs b/apps/desktop-gpui/src/screenshot_editor.rs index af940970534..bee0b643388 100644 --- a/apps/desktop-gpui/src/screenshot_editor.rs +++ b/apps/desktop-gpui/src/screenshot_editor.rs @@ -4446,6 +4446,11 @@ impl Render for ScreenshotEditorWindow { .id("screenshot-editor-root") .track_focus(&self.focus) .key_context("ScreenshotEditor") + .on_action( + cx.listener(|this, _: &crate::menus::ExportEditor, window, cx| { + this.export_image(ExportDestination::File, window, cx); + }), + ) .on_key_down(cx.listener(|this, event: &gpui::KeyDownEvent, window, cx| { this.on_key(event, window, cx); })) From 8db6489b4d08d868ed0a225a19b9a3794019c450 Mon Sep 17 00:00:00 2001 From: Ilya <47112191+ItsEeleeya@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:53:43 +0330 Subject: [PATCH 3/7] =?UTF-8?q?fix(desktop-gpui):=20ignore=20File=20>=20Ex?= =?UTF-8?q?port=E2=80=A6=20while=20the=20screenshot=20crop=20dialog=20is?= =?UTF-8?q?=20open?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/desktop-gpui/src/screenshot_editor.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/desktop-gpui/src/screenshot_editor.rs b/apps/desktop-gpui/src/screenshot_editor.rs index bee0b643388..adc49b2746b 100644 --- a/apps/desktop-gpui/src/screenshot_editor.rs +++ b/apps/desktop-gpui/src/screenshot_editor.rs @@ -4448,7 +4448,9 @@ impl Render for ScreenshotEditorWindow { .key_context("ScreenshotEditor") .on_action( cx.listener(|this, _: &crate::menus::ExportEditor, window, cx| { - this.export_image(ExportDestination::File, window, cx); + if this.crop.is_none() { + this.export_image(ExportDestination::File, window, cx); + } }), ) .on_key_down(cx.listener(|this, event: &gpui::KeyDownEvent, window, cx| { From a788b3d25faa11dcb4bffda74fc903de47018f72 Mon Sep 17 00:00:00 2001 From: Ilya <47112191+ItsEeleeya@users.noreply.github.com> Date: Tue, 27 Oct 2026 20:04:52 +0330 Subject: [PATCH 4/7] =?UTF-8?q?fix(desktop-gpui):=20disable=20File=20>=20E?= =?UTF-8?q?xport=E2=80=A6=20while=20the=20screenshot=20crop=20dialog=20is?= =?UTF-8?q?=20open?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/desktop-gpui/src/screenshot_editor.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/desktop-gpui/src/screenshot_editor.rs b/apps/desktop-gpui/src/screenshot_editor.rs index adc49b2746b..f775d5d72a0 100644 --- a/apps/desktop-gpui/src/screenshot_editor.rs +++ b/apps/desktop-gpui/src/screenshot_editor.rs @@ -4446,13 +4446,13 @@ impl Render for ScreenshotEditorWindow { .id("screenshot-editor-root") .track_focus(&self.focus) .key_context("ScreenshotEditor") - .on_action( - cx.listener(|this, _: &crate::menus::ExportEditor, window, cx| { - if this.crop.is_none() { + .when(self.crop.is_none(), |root| { + root.on_action( + cx.listener(|this, _: &crate::menus::ExportEditor, window, cx| { this.export_image(ExportDestination::File, window, cx); - } - }), - ) + }), + ) + }) .on_key_down(cx.listener(|this, event: &gpui::KeyDownEvent, window, cx| { this.on_key(event, window, cx); })) From c84656da2e1f4393aa208c6feeb2c622ba5ca145 Mon Sep 17 00:00:00 2001 From: Ilya <47112191+ItsEeleeya@users.noreply.github.com> Date: Wed, 4 Nov 2026 20:54:51 +0330 Subject: [PATCH 5/7] =?UTF-8?q?fix(desktop-gpui):=20focus=20the=20screensh?= =?UTF-8?q?ot=20editor=20root=20on=20open=20so=20File=20>=20Export?= =?UTF-8?q?=E2=80=A6=20enables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/desktop-gpui/src/screenshot_editor.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/desktop-gpui/src/screenshot_editor.rs b/apps/desktop-gpui/src/screenshot_editor.rs index 1315752ade2..d03abc43774 100644 --- a/apps/desktop-gpui/src/screenshot_editor.rs +++ b/apps/desktop-gpui/src/screenshot_editor.rs @@ -1082,6 +1082,7 @@ impl ScreenshotEditorWindow { this.hex_inputs.insert(target, input); } this.init_annotation_inputs(window, cx); + window.focus(&this.focus, cx); this } From 2747fc7e9c728a619650e4510c88a1ba5caa8498 Mon Sep 17 00:00:00 2001 From: Ilya <47112191+ItsEeleeya@users.noreply.github.com> Date: Wed, 4 Nov 2026 22:04:54 +0330 Subject: [PATCH 6/7] fix(desktop-gpui): animate mode picker icon press and clear stuck presses --- apps/desktop-gpui/src/tray/mac_mode_picker.rs | 81 +++++++++++++++---- 1 file changed, 64 insertions(+), 17 deletions(-) diff --git a/apps/desktop-gpui/src/tray/mac_mode_picker.rs b/apps/desktop-gpui/src/tray/mac_mode_picker.rs index f8a8b0f88df..641c122c703 100644 --- a/apps/desktop-gpui/src/tray/mac_mode_picker.rs +++ b/apps/desktop-gpui/src/tray/mac_mode_picker.rs @@ -20,11 +20,15 @@ use objc2_app_kit::{ NSForegroundColorAttributeName, NSImage, NSImageScaling, NSImageView, NSMenu, NSMenuItem, NSStringDrawing, NSTrackingArea, NSTrackingAreaOptions, NSView, NSWindow, }; +use objc2_core_graphics::CGAffineTransformMake; use objc2_foundation::{ MainThreadMarker, NSArray, NSData, NSDictionary, NSPoint, NSRect, NSRunLoop, NSSize, NSString, - NSTimer, + NSTimer, NSValue, ns_string, +}; +use objc2_quartz_core::{ + CABasicAnimation, CALayer, CAMediaTiming, CAMediaTimingFunction, CATransaction, CATransform3D, + kCACornerCurveContinuous, kCAMediaTimingFunctionEaseOut, }; -use objc2_quartz_core::{CALayer, CATransaction, kCACornerCurveContinuous}; use super::mac::{post, set_status_mode}; use super::{TrayItem, mode_heading, mode_name, mode_picker_icon}; @@ -55,6 +59,8 @@ const PILL_RADIUS: f64 = 14.0; const CAPSULE_RADIUS: f64 = 17.0; /// Optical nudge for a pill's glyph, left of its centred position. const STUDIO_ICON_NUDGE: f64 = -1.0; +const PRESS_SCALE: f64 = 0.85; +const PRESS_DURATION: f64 = 0.25; thread_local! { /// The live picker and its menu item, read by the key hook. Set on every rebuild. @@ -103,7 +109,8 @@ struct PickerIvars { selected: Cell, focused: Cell>, flash: Cell, - pressed: Cell, + /// The pill the mouse went down on, until mouse-up. + pressed: Cell>, /// `actions` index of the first pill; pill `i` posts `tag_base + i`. tag_base: isize, capsule: RefCell>>, @@ -178,17 +185,19 @@ define_class!( #[unsafe(method(mouseExited:))] fn mouse_exited(&self, _event: &NSEvent) { - if self.ivars().pressed.get() { - return; - } + self.release_press(); self.ivars().focused.set(None); self.refresh(); } #[unsafe(method(mouseDown:))] fn mouse_down(&self, event: &NSEvent) { - self.ivars().pressed.set(true); - self.update_focus(self.pill_at(event)); + let hit = self.pill_at(event); + self.ivars().pressed.set(hit); + self.update_focus(hit); + if let Some(i) = hit { + self.set_icon_pressed(i, true); + } } #[unsafe(method(mouseDragged:))] @@ -198,7 +207,7 @@ define_class!( #[unsafe(method(mouseUp:))] fn mouse_up(&self, event: &NSEvent) { - self.ivars().pressed.set(false); + self.release_press(); // The release point chooses the pill; a release outside the menu // changes nothing, so the shown and applied modes stay in sync. match self.pill_at(event) { @@ -220,7 +229,7 @@ impl ModePickerView { selected: Cell::new(selected), focused: Cell::new(None), flash: Cell::new(false), - pressed: Cell::new(false), + pressed: Cell::new(None), tag_base, capsule: RefCell::new(None), pills: RefCell::new(Vec::new()), @@ -269,6 +278,7 @@ impl ModePickerView { view.setImage(Some(&image)); } view.setImageScaling(NSImageScaling::ScaleNone); + view.setWantsLayer(true); this.addSubview(&view); this.ivars().icons.borrow_mut().push(view); } @@ -320,12 +330,18 @@ impl ModePickerView { } fn clear_focus(&self) { - if self.ivars().pressed.get() { - return; - } + self.release_press(); self.update_focus(None); } + /// Ends any mouse press, animating its icon back to rest. Safe to call when + /// no press is active. + fn release_press(&self) { + if let Some(i) = self.ivars().pressed.replace(None) { + self.set_icon_pressed(i, false); + } + } + // -- geometry ---------------------------------------------------------- fn capsule_rect(&self) -> NSRect { @@ -394,6 +410,35 @@ impl ModePickerView { self.setNeedsDisplay(true); } + /// Scales pill `i`'s icon about its center, animated, for a press or release. + fn set_icon_pressed(&self, i: usize, pressed: bool) { + let icons = self.ivars().icons.borrow(); + let Some(layer) = icons.get(i).and_then(|icon| icon.layer()) else { + return; + }; + let scale = if pressed { PRESS_SCALE } else { 1.0 }; + let size = layer.bounds().size; + let inset_x = size.width * (1.0 - scale) / 2.0; + let inset_y = size.height * (1.0 - scale) / 2.0; + let to = CATransform3D::new_affine_transform(CGAffineTransformMake( + scale, 0.0, 0.0, scale, inset_x, inset_y, + )); + let from = + unsafe { layer.presentationLayer() }.map_or(layer.transform(), |p| p.transform()); + layer.setTransform(to); + + let anim = CABasicAnimation::animationWithKeyPath(Some(ns_string!("transform"))); + unsafe { + anim.setFromValue(Some(&NSValue::new(from))); + anim.setToValue(Some(&NSValue::new(to))); + } + anim.setDuration(PRESS_DURATION); + anim.setTimingFunction(Some(&CAMediaTimingFunction::functionWithName(unsafe { + kCAMediaTimingFunctionEaseOut + }))); + layer.addAnimation_forKey(&anim, Some(ns_string!("press"))); + } + /// The only place state becomes layer properties. fn sync(&self) { let appearance = self.effectiveAppearance(); @@ -471,17 +516,19 @@ impl ModePickerView { let shown = focused.unwrap_or(selected); let mut font = heading_font(); - if shown != selected { + let color = if shown != selected { font = italic(&font); - } + NSColor::secondaryLabelColor() + } else { + NSColor::labelColor() + }; - let secondary = NSColor::secondaryLabelColor(); let subtitle = NSString::from_str(mode_heading(PICKER_MODES[shown].0)); let attrs = NSDictionary::from_slices( &[unsafe { NSFontAttributeName }, unsafe { NSForegroundColorAttributeName }], - &[&*font as &AnyObject, &*secondary as &AnyObject], + &[&*font as &AnyObject, &*color as &AnyObject], ); let size = unsafe { subtitle.sizeWithAttributes(Some(&attrs)) }; From 05e0b907484408e47be106360590c1a692b591ec Mon Sep 17 00:00:00 2001 From: Ilya <47112191+ItsEeleeya@users.noreply.github.com> Date: Wed, 4 Nov 2026 22:21:56 +0330 Subject: [PATCH 7/7] feat(desktop-gpui): ensure mode picker view is touch compatible by being at least 36pt tall. --- apps/desktop-gpui/src/tray/mac_mode_picker.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/desktop-gpui/src/tray/mac_mode_picker.rs b/apps/desktop-gpui/src/tray/mac_mode_picker.rs index 641c122c703..c8c33feeb11 100644 --- a/apps/desktop-gpui/src/tray/mac_mode_picker.rs +++ b/apps/desktop-gpui/src/tray/mac_mode_picker.rs @@ -51,6 +51,8 @@ const PICKER_H: f64 = 41.0; const PILL_W: f64 = 42.0; const PILL_H: f64 = 29.0; const PILL_GAP: f64 = 4.0; +/// Minimum touch target height. Only the hit test uses it; the visual pill stays `PILL_H`. +const PILL_HIT_MIN_H: f64 = 36.0; const CAPSULE_PAD: f64 = 3.0; const RIGHT_INSET: f64 = 12.0; const TITLE_INSET: f64 = 18.0; @@ -381,12 +383,15 @@ impl ModePickerView { } fn pill_at_point(&self, p: NSPoint) -> Option { + let bounds = self.bounds(); (0..PICKER_MODES.len()).find(|&i| { let r = self.pill_rect(i); + let hit_h = PILL_HIT_MIN_H.max(r.size.height).min(bounds.size.height); + let hit_y = r.origin.y + r.size.height / 2.0 - hit_h / 2.0; p.x >= r.origin.x - PILL_GAP / 2.0 && p.x <= r.origin.x + r.size.width + PILL_GAP / 2.0 - && p.y >= r.origin.y - && p.y <= r.origin.y + r.size.height + && p.y >= hit_y + && p.y <= hit_y + hit_h }) }