Fix double border

This commit is contained in:
Nate Butler 2023-12-04 18:13:28 -05:00
parent 5bdaf0e074
commit fc16e4509a

View file

@ -27,8 +27,8 @@ use std::{
}; };
use ui::{ use ui::{
h_stack, prelude::*, right_click_menu, ButtonLike, Color, Icon, IconButton, IconElement, h_stack, prelude::*, right_click_menu, Color, Icon, IconButton, IconElement, IconSize, Label,
IconSize, Label, Tooltip, Tooltip,
}; };
use ui::{v_stack, ContextMenu}; use ui::{v_stack, ContextMenu};
use util::truncate_and_remove_front; use util::truncate_and_remove_front;
@ -1486,13 +1486,6 @@ impl Pane {
.items_center() .items_center()
.justify_center() .justify_center()
.px_5() .px_5()
// .map(|this| {
// if close_right {
// this.pl_3().pr_1()
// } else {
// this.pr_1().pr_3()
// }
// })
.h(rems(1.875)) .h(rems(1.875))
.bg(tab_bg) .bg(tab_bg)
.border_color(cx.theme().colors().border) .border_color(cx.theme().colors().border)
@ -1502,9 +1495,16 @@ impl Pane {
cx.theme().colors().text_muted cx.theme().colors().text_muted
}) })
.map(|this| { .map(|this| {
let is_first_item = ix == 0;
let is_last_item = ix == self.items.len() - 1; let is_last_item = ix == self.items.len() - 1;
match ix.cmp(&self.active_item_index) { match ix.cmp(&self.active_item_index) {
cmp::Ordering::Less => this.border_l().mr_px().border_b(), cmp::Ordering::Less => {
if is_first_item {
this.ml_px().mr_px().border_b()
} else {
this.border_l().mr_px().border_b()
}
}
cmp::Ordering::Greater => { cmp::Ordering::Greater => {
if is_last_item { if is_last_item {
this.mr_px().ml_px().border_b() this.mr_px().ml_px().border_b()
@ -1542,24 +1542,18 @@ impl Pane {
right_click_menu(ix).trigger(tab).menu(|cx| { right_click_menu(ix).trigger(tab).menu(|cx| {
ContextMenu::build(cx, |menu, cx| { ContextMenu::build(cx, |menu, cx| {
menu.action( menu.action(
"Close Active Item", "Close",
CloseActiveItem { save_intent: None }.boxed_clone(), CloseActiveItem { save_intent: None }.boxed_clone(),
cx, cx,
) )
.action("Close Inactive Items", CloseInactiveItems.boxed_clone(), cx) .action("Close Others", CloseInactiveItems.boxed_clone(), cx)
.action("Close Clean Items", CloseCleanItems.boxed_clone(), cx) .separator()
.action("Close Left", CloseItemsToTheLeft.boxed_clone(), cx)
.action("Close Right", CloseItemsToTheRight.boxed_clone(), cx)
.separator()
.action("Close Clean", CloseCleanItems.boxed_clone(), cx)
.action( .action(
"Close Items To The Left", "Close All",
CloseItemsToTheLeft.boxed_clone(),
cx,
)
.action(
"Close Items To The Right",
CloseItemsToTheRight.boxed_clone(),
cx,
)
.action(
"Close All Items",
CloseAllItems { save_intent: None }.boxed_clone(), CloseAllItems { save_intent: None }.boxed_clone(),
cx, cx,
) )
@ -1582,30 +1576,29 @@ impl Pane {
// Left Side // Left Side
.child( .child(
h_stack() h_stack()
.px_2()
.flex() .flex()
.flex_none() .flex_none()
.gap_1() .gap_1()
.px_1()
.border_b()
.border_r()
.border_color(cx.theme().colors().border)
// Nav Buttons // Nav Buttons
.child( .child(
div().border().border_color(gpui::red()).child( IconButton::new("navigate_backward", Icon::ArrowLeft)
IconButton::new("navigate_backward", Icon::ArrowLeft) .on_click({
.on_click({ let view = cx.view().clone();
let view = cx.view().clone(); move |_, cx| view.update(cx, Self::navigate_backward)
move |_, cx| view.update(cx, Self::navigate_backward) })
}) .disabled(!self.can_navigate_backward()),
.disabled(!self.can_navigate_backward()),
),
) )
.child( .child(
div().border().border_color(gpui::red()).child( IconButton::new("navigate_forward", Icon::ArrowRight)
IconButton::new("navigate_forward", Icon::ArrowRight) .on_click({
.on_click({ let view = cx.view().clone();
let view = cx.view().clone(); move |_, cx| view.update(cx, Self::navigate_backward)
move |_, cx| view.update(cx, Self::navigate_backward) })
}) .disabled(!self.can_navigate_forward()),
.disabled(!self.can_navigate_forward()),
),
), ),
) )
.child( .child(
@ -1621,86 +1614,60 @@ impl Pane {
) )
// Right Side // Right Side
.child( .child(
div() h_stack()
.px_1()
.flex() .flex()
.flex_none() .flex_none()
.gap_2() .gap_1()
// Nav Buttons .px_1()
.border_b()
.border_l()
.border_color(cx.theme().colors().border)
.child( .child(
div() div()
.flex() .flex()
.items_center() .items_center()
.gap_px() .gap_px()
.child( .child(IconButton::new("plus", Icon::Plus).on_click(cx.listener(
div() |this, _, cx| {
.bg(gpui::blue()) let menu = ContextMenu::build(cx, |menu, cx| {
.border() menu.action("New File", NewFile.boxed_clone(), cx)
.border_color(gpui::red()) .action(
.child(IconButton::new("plus", Icon::Plus).on_click( "New Terminal",
cx.listener(|this, _, cx| { NewCenterTerminal.boxed_clone(),
let menu = ContextMenu::build(cx, |menu, cx| { cx,
menu.action("New File", NewFile.boxed_clone(), cx)
.action(
"New Terminal",
NewCenterTerminal.boxed_clone(),
cx,
)
.action(
"New Search",
NewSearch.boxed_clone(),
cx,
)
});
cx.subscribe(
&menu,
|this, _, event: &DismissEvent, cx| {
this.focus(cx);
this.new_item_menu = None;
},
) )
.detach(); .action("New Search", NewSearch.boxed_clone(), cx)
this.new_item_menu = Some(menu); });
}), cx.subscribe(&menu, |this, _, event: &DismissEvent, cx| {
)) this.focus(cx);
.when_some(self.new_item_menu.as_ref(), |el, new_item_menu| { this.new_item_menu = None;
el.child(Self::render_menu_overlay(new_item_menu)) })
}), .detach();
) this.new_item_menu = Some(menu);
.child( },
div() )))
.border() .when_some(self.new_item_menu.as_ref(), |el, new_item_menu| {
.border_color(gpui::red()) el.child(Self::render_menu_overlay(new_item_menu))
.child(IconButton::new("split", Icon::Split).on_click( })
cx.listener(|this, _, cx| { .child(IconButton::new("split", Icon::Split).on_click(cx.listener(
let menu = ContextMenu::build(cx, |menu, cx| { |this, _, cx| {
menu.action( let menu = ContextMenu::build(cx, |menu, cx| {
"Split Right", menu.action("Split Right", SplitRight.boxed_clone(), cx)
SplitRight.boxed_clone(), .action("Split Left", SplitLeft.boxed_clone(), cx)
cx, .action("Split Up", SplitUp.boxed_clone(), cx)
) .action("Split Down", SplitDown.boxed_clone(), cx)
.action("Split Left", SplitLeft.boxed_clone(), cx) });
.action("Split Up", SplitUp.boxed_clone(), cx) cx.subscribe(&menu, |this, _, event: &DismissEvent, cx| {
.action("Split Down", SplitDown.boxed_clone(), cx) this.focus(cx);
}); this.split_item_menu = None;
cx.subscribe( })
&menu, .detach();
|this, _, event: &DismissEvent, cx| { this.split_item_menu = Some(menu);
this.focus(cx); },
this.split_item_menu = None; )))
}, .when_some(self.split_item_menu.as_ref(), |el, split_item_menu| {
) el.child(Self::render_menu_overlay(split_item_menu))
.detach(); }),
this.split_item_menu = Some(menu);
}),
))
.when_some(
self.split_item_menu.as_ref(),
|el, split_item_menu| {
el.child(Self::render_menu_overlay(split_item_menu))
},
),
),
), ),
) )
} }