Show maximize/minimize icon for panes and terminal panel

This commit is contained in:
Antonio Scandurra 2023-05-24 11:00:12 +02:00
parent 9575ffc1e3
commit 1a353ad25d
2 changed files with 45 additions and 18 deletions

View file

@ -62,24 +62,37 @@ impl TerminalPanel {
item.handle.act_as::<TerminalView>(cx).is_some() item.handle.act_as::<TerminalView>(cx).is_some()
}) })
}); });
pane.set_render_tab_bar_buttons(cx, move |_, cx| { pane.set_render_tab_bar_buttons(cx, move |pane, cx| {
let this = weak_self.clone(); let this = weak_self.clone();
Pane::render_tab_bar_button( Flex::row()
0, .with_child(Pane::render_tab_bar_button(
"icons/plus_12.svg", 0,
cx, "icons/plus_12.svg",
move |_, cx| { cx,
let this = this.clone(); move |_, cx| {
cx.window_context().defer(move |cx| { let this = this.clone();
if let Some(this) = this.upgrade(cx) { cx.window_context().defer(move |cx| {
this.update(cx, |this, cx| { if let Some(this) = this.upgrade(cx) {
this.add_terminal(&Default::default(), cx); this.update(cx, |this, cx| {
}); this.add_terminal(&Default::default(), cx);
} });
}) }
}, })
None, },
) None,
))
.with_child(Pane::render_tab_bar_button(
1,
if pane.is_zoomed() {
"icons/minimize_8.svg"
} else {
"icons/maximize_8.svg"
},
cx,
move |pane, cx| pane.toggle_zoom(&Default::default(), cx),
None,
))
.into_any()
}); });
pane pane
}); });

View file

@ -291,13 +291,24 @@ impl Pane {
.handle_if_kind(TabBarContextMenuKind::New), .handle_if_kind(TabBarContextMenuKind::New),
)) ))
.with_child(Self::render_tab_bar_button( .with_child(Self::render_tab_bar_button(
2, 1,
"icons/split_12.svg", "icons/split_12.svg",
cx, cx,
|pane, cx| pane.deploy_split_menu(cx), |pane, cx| pane.deploy_split_menu(cx),
pane.tab_bar_context_menu pane.tab_bar_context_menu
.handle_if_kind(TabBarContextMenuKind::Split), .handle_if_kind(TabBarContextMenuKind::Split),
)) ))
.with_child(Pane::render_tab_bar_button(
2,
if pane.is_zoomed() {
"icons/minimize_8.svg"
} else {
"icons/maximize_8.svg"
},
cx,
move |pane, cx| pane.toggle_zoom(&Default::default(), cx),
None,
))
.into_any() .into_any()
}), }),
} }
@ -684,6 +695,9 @@ impl Pane {
if self.zoomed { if self.zoomed {
cx.emit(Event::ZoomOut); cx.emit(Event::ZoomOut);
} else if !self.items.is_empty() { } else if !self.items.is_empty() {
if !self.has_focus {
cx.focus_self();
}
cx.emit(Event::ZoomIn); cx.emit(Event::ZoomIn);
} }
} }