Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add Zoom button to assistant panel
Nathan Soboa49189a7048d
diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rsindex 14d84d054b8..c8e3dce862d 100644--- a/crates/ai/src/assistant.rs+++ b/crates/ai/src/assistant.rs@@ -46,7 +46,7 @@ use util::{use workspace::{dock::{DockPosition, Panel},item::Item,- Save, Workspace,+ Save, ToggleZoom, Workspace,};const OPENAI_API_URL: &'static str = "https://api.openai.com/v1";@@ -364,6 +364,36 @@ impl AssistantPanel {})}+ fn render_zoom_button(+ &self,+ style: &AssistantStyle,+ cx: &mut ViewContext<Self>,+ ) -> impl Element<Self> {+ enum ToggleZoomButton {}++ let style = if self.zoomed {+ &style.zoom_out_button+ } else {+ &style.zoom_in_button+ };++ MouseEventHandler::<ToggleZoomButton, _>::new(0, cx, |_, _| {+ Svg::for_style(style.icon.clone())+ .contained()+ .with_style(style.container)+ })+ .with_cursor_style(CursorStyle::PointingHand)+ .on_click(MouseButton::Left, |_, this, cx| {+ if this.zoomed {+ cx.emit(AssistantPanelEvent::ZoomOut)+ } else {+ this.has_focus = true; // Hack: Because focus_in is processed last, we need to set this here.+ cx.focus_self();+ cx.emit(AssistantPanelEvent::ZoomIn);+ }+ })+ }+fn render_saved_conversation(&mut self,index: usize,@@ -510,6 +540,7 @@ impl View for AssistantPanel {.aligned().flex_float(),)+ .with_child(self.render_zoom_button(&style, cx).aligned().flex_float()).contained().with_style(theme.workspace.tab_bar.container).expanded()diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rsindex 72976ad82bc..71473364798 100644--- a/crates/theme/src/theme.rs+++ b/crates/theme/src/theme.rs@@ -995,6 +995,8 @@ pub struct TerminalStyle {pub struct AssistantStyle {pub container: ContainerStyle,pub hamburger_button: IconStyle,+ pub zoom_in_button: IconStyle,+ pub zoom_out_button: IconStyle,pub plus_button: IconStyle,pub title: ContainedText,pub message_header: ContainerStyle,diff --git a/styles/src/styleTree/assistant.ts b/styles/src/styleTree/assistant.tsindex dc5be7dbb58..e4e342eb015 100644--- a/styles/src/styleTree/assistant.ts+++ b/styles/src/styleTree/assistant.ts@@ -27,6 +27,32 @@ export default function assistant(colorScheme: ColorScheme) {margin: { left: 12 },}},+ zoomInButton: {+ icon: {+ color: text(layer, "sans", "default", { size: "sm" }).color,+ asset: "icons/maximize_8.svg",+ dimensions: {+ width: 12,+ height: 12,+ },+ },+ container: {+ margin: { right: 12 },+ }+ },+ zoomOutButton: {+ icon: {+ color: text(layer, "sans", "default", { size: "sm" }).color,+ asset: "icons/minimize_8.svg",+ dimensions: {+ width: 12,+ height: 12,+ },+ },+ container: {+ margin: { right: 12 },+ }+ },plusButton: {icon: {color: text(layer, "sans", "default", { size: "sm" }).color,