mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
Show split button at the right edge of the tab bar
This commit is contained in:
parent
e55e69caba
commit
c87efb0dbc
3 changed files with 45 additions and 8 deletions
|
@ -40,6 +40,7 @@ pub struct Workspace {
|
||||||
pub titlebar: Titlebar,
|
pub titlebar: Titlebar,
|
||||||
pub tab: Tab,
|
pub tab: Tab,
|
||||||
pub active_tab: Tab,
|
pub active_tab: Tab,
|
||||||
|
pub pane_button: Interactive<IconButton>,
|
||||||
pub pane_divider: Border,
|
pub pane_divider: Border,
|
||||||
pub leader_border_opacity: f32,
|
pub leader_border_opacity: f32,
|
||||||
pub leader_border_width: f32,
|
pub leader_border_width: f32,
|
||||||
|
|
|
@ -800,13 +800,13 @@ impl Pane {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_tabs(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
fn render_tabs(&mut self, cx: &mut RenderContext<Self>) -> impl Element {
|
||||||
let theme = cx.global::<Settings>().theme.clone();
|
let theme = cx.global::<Settings>().theme.clone();
|
||||||
|
|
||||||
enum Tabs {}
|
enum Tabs {}
|
||||||
enum Tab {}
|
enum Tab {}
|
||||||
let pane = cx.handle();
|
let pane = cx.handle();
|
||||||
let tabs = MouseEventHandler::new::<Tabs, _, _>(0, cx, |mouse_state, cx| {
|
MouseEventHandler::new::<Tabs, _, _>(0, cx, |mouse_state, cx| {
|
||||||
let autoscroll = if mem::take(&mut self.autoscroll) {
|
let autoscroll = if mem::take(&mut self.autoscroll) {
|
||||||
Some(self.active_item_index)
|
Some(self.active_item_index)
|
||||||
} else {
|
} else {
|
||||||
|
@ -941,11 +941,7 @@ impl Pane {
|
||||||
);
|
);
|
||||||
|
|
||||||
row.boxed()
|
row.boxed()
|
||||||
});
|
})
|
||||||
|
|
||||||
ConstrainedBox::new(tabs.boxed())
|
|
||||||
.with_height(theme.workspace.tab.height)
|
|
||||||
.named("tabs")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,11 +955,39 @@ impl View for Pane {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
||||||
|
enum SplitIcon {}
|
||||||
|
|
||||||
let this = cx.handle();
|
let this = cx.handle();
|
||||||
|
|
||||||
EventHandler::new(if let Some(active_item) = self.active_item() {
|
EventHandler::new(if let Some(active_item) = self.active_item() {
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_child(self.render_tabs(cx))
|
.with_child(
|
||||||
|
Flex::row()
|
||||||
|
.with_child(self.render_tabs(cx).flex(1., true).named("tabs"))
|
||||||
|
.with_child(
|
||||||
|
MouseEventHandler::new::<SplitIcon, _, _>(0, cx, |mouse_state, cx| {
|
||||||
|
let theme = &cx.global::<Settings>().theme.workspace;
|
||||||
|
let style = theme.pane_button.style_for(mouse_state, false);
|
||||||
|
Svg::new("icons/split.svg")
|
||||||
|
.with_color(style.color)
|
||||||
|
.constrained()
|
||||||
|
.with_width(style.icon_width)
|
||||||
|
.aligned()
|
||||||
|
.contained()
|
||||||
|
.with_style(style.container)
|
||||||
|
.constrained()
|
||||||
|
.with_width(style.button_width)
|
||||||
|
.with_height(style.button_width)
|
||||||
|
.aligned()
|
||||||
|
.boxed()
|
||||||
|
})
|
||||||
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
|
.boxed(),
|
||||||
|
)
|
||||||
|
.constrained()
|
||||||
|
.with_height(cx.global::<Settings>().theme.workspace.tab.height)
|
||||||
|
.boxed(),
|
||||||
|
)
|
||||||
.with_child(ChildView::new(&self.toolbar).boxed())
|
.with_child(ChildView::new(&self.toolbar).boxed())
|
||||||
.with_child(ChildView::new(active_item).flex(1., true).boxed())
|
.with_child(ChildView::new(active_item).flex(1., true).boxed())
|
||||||
.boxed()
|
.boxed()
|
||||||
|
|
|
@ -55,6 +55,18 @@ export default function workspace(theme: Theme) {
|
||||||
leaderBorderWidth: 2.0,
|
leaderBorderWidth: 2.0,
|
||||||
tab,
|
tab,
|
||||||
activeTab,
|
activeTab,
|
||||||
|
paneButton: {
|
||||||
|
color: iconColor(theme, "secondary"),
|
||||||
|
border: {
|
||||||
|
...tab.border
|
||||||
|
},
|
||||||
|
iconWidth: 14,
|
||||||
|
buttonWidth: tab.height,
|
||||||
|
hover: {
|
||||||
|
color: iconColor(theme, "active"),
|
||||||
|
background: backgroundColor(theme, 300),
|
||||||
|
}
|
||||||
|
},
|
||||||
modal: {
|
modal: {
|
||||||
margin: {
|
margin: {
|
||||||
bottom: 52,
|
bottom: 52,
|
||||||
|
|
Loading…
Reference in a new issue