Add Zoom button to assistant panel
This commit is contained in:
parent
a75341db97
commit
a49189a704
3 changed files with 60 additions and 1 deletions
|
@ -46,7 +46,7 @@ use util::{
|
||||||
use workspace::{
|
use workspace::{
|
||||||
dock::{DockPosition, Panel},
|
dock::{DockPosition, Panel},
|
||||||
item::Item,
|
item::Item,
|
||||||
Save, Workspace,
|
Save, ToggleZoom, Workspace,
|
||||||
};
|
};
|
||||||
|
|
||||||
const OPENAI_API_URL: &'static str = "https://api.openai.com/v1";
|
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(
|
fn render_saved_conversation(
|
||||||
&mut self,
|
&mut self,
|
||||||
index: usize,
|
index: usize,
|
||||||
|
@ -510,6 +540,7 @@ impl View for AssistantPanel {
|
||||||
.aligned()
|
.aligned()
|
||||||
.flex_float(),
|
.flex_float(),
|
||||||
)
|
)
|
||||||
|
.with_child(self.render_zoom_button(&style, cx).aligned().flex_float())
|
||||||
.contained()
|
.contained()
|
||||||
.with_style(theme.workspace.tab_bar.container)
|
.with_style(theme.workspace.tab_bar.container)
|
||||||
.expanded()
|
.expanded()
|
||||||
|
|
|
@ -995,6 +995,8 @@ pub struct TerminalStyle {
|
||||||
pub struct AssistantStyle {
|
pub struct AssistantStyle {
|
||||||
pub container: ContainerStyle,
|
pub container: ContainerStyle,
|
||||||
pub hamburger_button: IconStyle,
|
pub hamburger_button: IconStyle,
|
||||||
|
pub zoom_in_button: IconStyle,
|
||||||
|
pub zoom_out_button: IconStyle,
|
||||||
pub plus_button: IconStyle,
|
pub plus_button: IconStyle,
|
||||||
pub title: ContainedText,
|
pub title: ContainedText,
|
||||||
pub message_header: ContainerStyle,
|
pub message_header: ContainerStyle,
|
||||||
|
|
|
@ -27,6 +27,32 @@ export default function assistant(colorScheme: ColorScheme) {
|
||||||
margin: { left: 12 },
|
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: {
|
plusButton: {
|
||||||
icon: {
|
icon: {
|
||||||
color: text(layer, "sans", "default", { size: "sm" }).color,
|
color: text(layer, "sans", "default", { size: "sm" }).color,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue