Making its visuals and positioning more consistent with the same button in the settings UI. Release Notes: - N/A
Unified · Split
| @@ -26,9 +26,9 @@ use project::{CompletionDisplayOptions, Project}; · 25 unmodified lines | ||
| 26 | 26 | use settings::{BaseKeymap, KeybindSource, KeymapFile, Settings as _, SettingsAssets}; |
| 27 | 27 | use ui::{ |
| 28 | 28 | ActiveTheme as _, App, Banner, BorrowAppContext, ContextMenu, IconButtonShape, Indicator, |
| 29 | − Modal, ModalFooter, ModalHeader, ParentElement as _, Render, Section, SharedString, | |
| 30 | − Styled as _, Table, TableColumnWidths, TableInteractionState, TableResizeBehavior, Tooltip, | |
| 31 | − Window, prelude::*, right_click_menu, | |
| 29 | + Modal, ModalFooter, ModalHeader, ParentElement as _, PopoverMenu, Render, Section, | |
| 30 | + SharedString, Styled as _, Table, TableColumnWidths, TableInteractionState, | |
| 31 | + TableResizeBehavior, Tooltip, Window, prelude::*, | |
| 32 | 32 | }; |
| 33 | 33 | use ui_input::SingleLineInput; |
| 34 | 34 | use util::ResultExt; |
| @@ -1663,56 +1663,61 @@ impl Render for KeymapEditor { · 1628 unmodified lines | ||
| 1663 | 1663 | }), |
| 1664 | 1664 | ) |
| 1665 | 1665 | .child( |
| 1666 | − div() | |
| 1667 | − .ml_1() | |
| 1666 | + h_flex() | |
| 1667 | + .w_full() | |
| 1668 | 1668 | .pl_2() |
| 1669 | − .border_l_1() | |
| 1670 | − .border_color(cx.theme().colors().border_variant) | |
| 1669 | + .gap_1() | |
| 1670 | + .justify_end() | |
| 1671 | 1671 | .child( |
| 1672 | − right_click_menu("open-keymap-menu") | |
| 1673 | − .menu(|window, cx| { | |
| 1674 | − ContextMenu::build(window, cx, |menu, _, _| { | |
| 1675 | − menu.header("Open Keymap JSON") | |
| 1676 | − .action( | |
| 1677 | − "User", | |
| 1678 | − zed_actions::OpenKeymap.boxed_clone(), | |
| 1679 | − ) | |
| 1672 | + PopoverMenu::new("open-keymap-menu") | |
| 1673 | + .menu(move |window, cx| { | |
| 1674 | + Some(ContextMenu::build(window, cx, |menu, _, _| { | |
| 1675 | + menu.header("View Default...") | |
| 1680 | 1676 | .action( |
| 1681 | − "Zed Default", | |
| 1677 | + "Zed Key Bindings", | |
| 1682 | 1678 | zed_actions::OpenDefaultKeymap |
| 1683 | 1679 | .boxed_clone(), |
| 1684 | 1680 | ) |
| 1685 | 1681 | .action( |
| 1686 | − "Vim Default", | |
| 1682 | + "Vim Bindings", | |
| 1687 | 1683 | vim::OpenDefaultKeymap.boxed_clone(), |
| 1688 | 1684 | ) |
| 1689 | − }) | |
| 1685 | + })) | |
| 1686 | + }) | |
| 1687 | + .anchor(gpui::Corner::TopRight) | |
| 1688 | + .offset(gpui::Point { | |
| 1689 | + x: px(0.0), | |
| 1690 | + y: px(2.0), | |
| 1690 | 1691 | }) |
| 1691 | − .anchor(gpui::Corner::TopLeft) | |
| 1692 | − .trigger(|open, _, _| { | |
| 1692 | + .trigger_with_tooltip( | |
| 1693 | 1693 | IconButton::new( |
| 1694 | 1694 | "OpenKeymapJsonButton", |
| 1695 | − IconName::Json, | |
| 1695 | + IconName::Ellipsis, | |
| 1696 | 1696 | ) |
| 1697 | − .icon_size(IconSize::Small) | |
| 1698 | − .when(!open, |this| { | |
| 1699 | − this.tooltip(move |window, cx| { | |
| 1700 | − Tooltip::with_meta( | |
| 1701 | − "Open keymap.json", | |
| 1702 | − Some(&zed_actions::OpenKeymap), | |
| 1703 | − "Right click to view more options", | |
| 1697 | + .icon_size(IconSize::Small), | |
| 1698 | + { | |
| 1699 | + let focus_handle = focus_handle.clone(); | |
| 1700 | + move |window, cx| { | |
| 1701 | + Tooltip::for_action_in( | |
| 1702 | + "View Default...", | |
| 1703 | + &zed_actions::OpenKeymap, | |
| 1704 | + &focus_handle, | |
| 1704 | 1705 | window, |
| 1705 | 1706 | cx, |
| 1706 | 1707 | ) |
| 1707 | − }) | |
| 1708 | − }) | |
| 1709 | − .on_click(|_, window, cx| { | |
| 1710 | − window.dispatch_action( | |
| 1711 | − zed_actions::OpenKeymap.boxed_clone(), | |
| 1712 | − cx, | |
| 1713 | − ); | |
| 1714 | − }) | |
| 1715 | − }), | |
| 1708 | + } | |
| 1709 | + }, | |
| 1710 | + ), | |
| 1711 | + ) | |
| 1712 | + .child( | |
| 1713 | + Button::new("edit-in-json", "Edit in keymap.json") | |
| 1714 | + .style(ButtonStyle::Outlined) | |
| 1715 | + .on_click(|_, window, cx| { | |
| 1716 | + window.dispatch_action( | |
| 1717 | + zed_actions::OpenKeymap.boxed_clone(), | |
| 1718 | + cx, | |
| 1719 | + ); | |
| 1720 | + }) | |
| 1716 | 1721 | ), |
| 1717 | 1722 | ) |
| 1718 | 1723 | ), |