mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-24 17:28:40 +00:00
Show quote selection button
This commit is contained in:
parent
e723686b72
commit
723c8b98b3
4 changed files with 45 additions and 1 deletions
1
assets/icons/quote_15.svg
Normal file
1
assets/icons/quote_15.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.42503 3.44136C10.0561 3.23654 10.7837 3.2402 11.3792 3.54623C12.7532 4.25224 13.3477 6.07191 12.7946 8C12.5465 8.8649 12.1102 9.70472 11.1861 10.5524C10.262 11.4 8.98034 11.9 8.38571 11.9C8.17269 11.9 8 11.7321 8 11.525C8 11.3179 8.17644 11.15 8.38571 11.15C9.06497 11.15 9.67189 10.7804 10.3906 10.236C10.9406 9.8193 11.3701 9.28633 11.608 8.82191C12.0628 7.93367 12.0782 6.68174 11.3433 6.34901C10.9904 6.73455 10.5295 6.95946 9.97725 6.95946C8.7773 6.95946 8.0701 5.99412 8.10051 5.12009C8.12957 4.28474 8.66032 3.68954 9.42503 3.44136ZM3.42503 3.44136C4.05614 3.23654 4.78366 3.2402 5.37923 3.54623C6.7532 4.25224 7.34766 6.07191 6.79462 8C6.54654 8.8649 6.11019 9.70472 5.1861 10.5524C4.26201 11.4 2.98034 11.9 2.38571 11.9C2.17269 11.9 2 11.7321 2 11.525C2 11.3179 2.17644 11.15 2.38571 11.15C3.06497 11.15 3.67189 10.7804 4.39058 10.236C4.94065 9.8193 5.37014 9.28633 5.60797 8.82191C6.06282 7.93367 6.07821 6.68174 5.3433 6.34901C4.99037 6.73455 4.52948 6.95946 3.97725 6.95946C2.7773 6.95946 2.0701 5.99412 2.10051 5.12009C2.12957 4.28474 2.66032 3.68954 3.42503 3.44136Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>
|
After Width: | Height: | Size: 1.2 KiB |
|
@ -111,6 +111,7 @@ pub enum AssistantPanelEvent {
|
|||
}
|
||||
|
||||
pub struct AssistantPanel {
|
||||
workspace: WeakViewHandle<Workspace>,
|
||||
width: Option<f32>,
|
||||
height: Option<f32>,
|
||||
active_editor_index: Option<usize>,
|
||||
|
@ -143,6 +144,7 @@ impl AssistantPanel {
|
|||
.unwrap_or_default();
|
||||
|
||||
// TODO: deserialize state.
|
||||
let workspace_handle = workspace.clone();
|
||||
workspace.update(&mut cx, |workspace, cx| {
|
||||
cx.add_view::<Self, _>(|cx| {
|
||||
const CONVERSATION_WATCH_DURATION: Duration = Duration::from_millis(100);
|
||||
|
@ -171,6 +173,7 @@ impl AssistantPanel {
|
|||
toolbar
|
||||
});
|
||||
let mut this = Self {
|
||||
workspace: workspace_handle,
|
||||
active_editor_index: Default::default(),
|
||||
prev_active_editor_index: Default::default(),
|
||||
editors: Default::default(),
|
||||
|
@ -364,6 +367,7 @@ impl AssistantPanel {
|
|||
if self.active_editor().is_some() {
|
||||
vec![
|
||||
Self::render_split_button(&style.split_button, cx).into_any(),
|
||||
Self::render_quote_button(&style.quote_button, cx).into_any(),
|
||||
Self::render_assist_button(&style.assist_button, cx).into_any(),
|
||||
]
|
||||
} else {
|
||||
|
@ -413,6 +417,31 @@ impl AssistantPanel {
|
|||
)
|
||||
}
|
||||
|
||||
fn render_quote_button(style: &IconStyle, cx: &mut ViewContext<Self>) -> impl Element<Self> {
|
||||
let tooltip_style = theme::current(cx).tooltip.clone();
|
||||
Svg::for_style(style.icon.clone())
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.mouse::<QuoteSelection>(0)
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
.on_click(MouseButton::Left, |_, this: &mut Self, cx| {
|
||||
if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
cx.window_context().defer(move |cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
ConversationEditor::quote_selection(workspace, &Default::default(), cx)
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
.with_tooltip::<QuoteSelection>(
|
||||
1,
|
||||
"Assist".into(),
|
||||
Some(Box::new(QuoteSelection)),
|
||||
tooltip_style,
|
||||
cx,
|
||||
)
|
||||
}
|
||||
|
||||
fn render_plus_button(style: &IconStyle) -> impl Element<Self> {
|
||||
enum AddConversation {}
|
||||
Svg::for_style(style.icon.clone())
|
||||
|
|
|
@ -996,6 +996,7 @@ pub struct AssistantStyle {
|
|||
pub hamburger_button: IconStyle,
|
||||
pub split_button: IconStyle,
|
||||
pub assist_button: IconStyle,
|
||||
pub quote_button: IconStyle,
|
||||
pub zoom_in_button: IconStyle,
|
||||
pub zoom_out_button: IconStyle,
|
||||
pub plus_button: IconStyle,
|
||||
|
|
|
@ -41,6 +41,19 @@ export default function assistant(colorScheme: ColorScheme) {
|
|||
margin: { left: 12 },
|
||||
}
|
||||
},
|
||||
quoteButton: {
|
||||
icon: {
|
||||
color: text(layer, "sans", "default", { size: "sm" }).color,
|
||||
asset: "icons/quote_15.svg",
|
||||
dimensions: {
|
||||
width: 15,
|
||||
height: 15,
|
||||
},
|
||||
},
|
||||
container: {
|
||||
margin: { left: 12 },
|
||||
}
|
||||
},
|
||||
assistButton: {
|
||||
icon: {
|
||||
color: text(layer, "sans", "default", { size: "sm" }).color,
|
||||
|
@ -51,7 +64,7 @@ export default function assistant(colorScheme: ColorScheme) {
|
|||
},
|
||||
},
|
||||
container: {
|
||||
margin: { left: 12, right: 12 },
|
||||
margin: { left: 12, right: 24 },
|
||||
}
|
||||
},
|
||||
zoomInButton: {
|
||||
|
|
Loading…
Reference in a new issue