Prompt Library Refinements (#13470)

TODO:

- [x] Moving the cursor out of the title editor should unselect any
selected text

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Richard <richard@zed.dev>
This commit is contained in:
Nate Butler 2024-06-25 11:43:30 -04:00 committed by GitHub
parent b014f9f017
commit 890443241d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 454 additions and 226 deletions

View file

@ -249,6 +249,11 @@ impl Clickable for Button {
self.base = self.base.on_click(handler);
self
}
fn cursor_style(mut self, cursor_style: gpui::CursorStyle) -> Self {
self.base = self.base.cursor_style(cursor_style);
self
}
}
impl FixedWidth for Button {

View file

@ -1,4 +1,4 @@
use gpui::{relative, DefiniteLength, MouseButton};
use gpui::{relative, CursorStyle, DefiniteLength, MouseButton};
use gpui::{transparent_black, AnyElement, AnyView, ClickEvent, Hsla, Rems};
use smallvec::SmallVec;
@ -344,6 +344,7 @@ pub struct ButtonLike {
size: ButtonSize,
rounding: Option<ButtonLikeRounding>,
tooltip: Option<Box<dyn Fn(&mut WindowContext) -> AnyView>>,
cursor_style: CursorStyle,
on_click: Option<Box<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>>,
children: SmallVec<[AnyElement; 2]>,
}
@ -363,6 +364,7 @@ impl ButtonLike {
rounding: Some(ButtonLikeRounding::All),
tooltip: None,
children: SmallVec::new(),
cursor_style: CursorStyle::PointingHand,
on_click: None,
layer: None,
}
@ -405,6 +407,11 @@ impl Clickable for ButtonLike {
self.on_click = Some(Box::new(handler));
self
}
fn cursor_style(mut self, cursor_style: CursorStyle) -> Self {
self.cursor_style = cursor_style;
self
}
}
impl FixedWidth for ButtonLike {

View file

@ -86,6 +86,11 @@ impl Clickable for IconButton {
self.base = self.base.on_click(handler);
self
}
fn cursor_style(mut self, cursor_style: gpui::CursorStyle) -> Self {
self.base = self.base.cursor_style(cursor_style);
self
}
}
impl FixedWidth for IconButton {

View file

@ -82,6 +82,11 @@ impl Clickable for ToggleButton {
self.base = self.base.on_click(handler);
self
}
fn cursor_style(mut self, cursor_style: gpui::CursorStyle) -> Self {
self.base = self.base.cursor_style(cursor_style);
self
}
}
impl ButtonCommon for ToggleButton {

View file

@ -1,6 +1,6 @@
use std::sync::Arc;
use gpui::ClickEvent;
use gpui::{ClickEvent, CursorStyle};
use crate::{prelude::*, Color, IconButton, IconButtonShape, IconName, IconSize};
@ -10,6 +10,7 @@ pub struct Disclosure {
is_open: bool,
selected: bool,
on_toggle: Option<Arc<dyn Fn(&ClickEvent, &mut WindowContext) + 'static>>,
cursor_style: CursorStyle,
}
impl Disclosure {
@ -19,6 +20,7 @@ impl Disclosure {
is_open,
selected: false,
on_toggle: None,
cursor_style: CursorStyle::PointingHand,
}
}
@ -43,6 +45,11 @@ impl Clickable for Disclosure {
self.on_toggle = Some(Arc::new(handler));
self
}
fn cursor_style(mut self, cursor_style: gpui::CursorStyle) -> Self {
self.cursor_style = cursor_style;
self
}
}
impl RenderOnce for Disclosure {

View file

@ -97,6 +97,9 @@ pub enum IconName {
BellOff,
BellRing,
Bolt,
Book,
BookCopy,
BookPlus,
CaseSensitive,
Check,
ChevronDown,
@ -231,6 +234,9 @@ impl IconName {
IconName::BellOff => "icons/bell_off.svg",
IconName::BellRing => "icons/bell_ring.svg",
IconName::Bolt => "icons/bolt.svg",
IconName::Book => "icons/book.svg",
IconName::BookCopy => "icons/book_copy.svg",
IconName::BookPlus => "icons/book_plus.svg",
IconName::CaseSensitive => "icons/case_insensitive.svg",
IconName::Check => "icons/check.svg",
IconName::ChevronDown => "icons/chevron_down.svg",