Merge branch 'project-diagnostics-pinned-tab' into style-project-diagnostics
This commit is contained in:
commit
c9b4bb78f2
13 changed files with 118 additions and 70 deletions
|
@ -70,8 +70,6 @@ pub enum Event {
|
|||
Split(SplitDirection),
|
||||
}
|
||||
|
||||
const MAX_TAB_TITLE_LEN: usize = 24;
|
||||
|
||||
pub struct Pane {
|
||||
item_views: Vec<(usize, Box<dyn ItemViewHandle>)>,
|
||||
active_item_index: usize,
|
||||
|
@ -79,6 +77,11 @@ pub struct Pane {
|
|||
nav_history: Rc<RefCell<NavHistory>>,
|
||||
}
|
||||
|
||||
// #[derive(Debug, Eq, PartialEq)]
|
||||
// pub struct State {
|
||||
// pub tabs: Vec<TabState>,
|
||||
// }
|
||||
|
||||
pub struct ItemNavHistory {
|
||||
history: Rc<RefCell<NavHistory>>,
|
||||
item_view: Rc<dyn WeakItemViewHandle>,
|
||||
|
@ -373,15 +376,12 @@ impl Pane {
|
|||
let is_active = ix == self.active_item_index;
|
||||
|
||||
row.add_child({
|
||||
let mut title = item_view.title(cx);
|
||||
if title.len() > MAX_TAB_TITLE_LEN {
|
||||
let mut truncated_len = MAX_TAB_TITLE_LEN;
|
||||
while !title.is_char_boundary(truncated_len) {
|
||||
truncated_len -= 1;
|
||||
}
|
||||
title.truncate(truncated_len);
|
||||
title.push('…');
|
||||
}
|
||||
let tab_style = if is_active {
|
||||
theme.workspace.active_tab.clone()
|
||||
} else {
|
||||
theme.workspace.tab.clone()
|
||||
};
|
||||
let title = item_view.tab_content(&tab_style, cx);
|
||||
|
||||
let mut style = if is_active {
|
||||
theme.workspace.active_tab.clone()
|
||||
|
@ -430,29 +430,16 @@ impl Pane {
|
|||
.boxed(),
|
||||
)
|
||||
.with_child(
|
||||
Container::new(
|
||||
Align::new(
|
||||
Label::new(
|
||||
title,
|
||||
if is_active {
|
||||
theme.workspace.active_tab.label.clone()
|
||||
} else {
|
||||
theme.workspace.tab.label.clone()
|
||||
},
|
||||
)
|
||||
.boxed(),
|
||||
)
|
||||
.boxed(),
|
||||
)
|
||||
.with_style(ContainerStyle {
|
||||
margin: Margin {
|
||||
left: style.spacing,
|
||||
right: style.spacing,
|
||||
Container::new(Align::new(title).boxed())
|
||||
.with_style(ContainerStyle {
|
||||
margin: Margin {
|
||||
left: style.spacing,
|
||||
right: style.spacing,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
.boxed(),
|
||||
})
|
||||
.boxed(),
|
||||
)
|
||||
.with_child(
|
||||
Align::new(
|
||||
|
|
|
@ -155,7 +155,7 @@ pub trait ItemView: View {
|
|||
fn deactivated(&mut self, _: &mut ViewContext<Self>) {}
|
||||
fn navigate(&mut self, _: Box<dyn Any>, _: &mut ViewContext<Self>) {}
|
||||
fn item_handle(&self, cx: &AppContext) -> Self::ItemHandle;
|
||||
fn title(&self, cx: &AppContext) -> String;
|
||||
fn tab_content(&self, style: &theme::Tab, cx: &AppContext) -> ElementBox;
|
||||
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
|
||||
fn clone_on_split(&self, _: &mut ViewContext<Self>) -> Option<Self>
|
||||
where
|
||||
|
@ -223,7 +223,7 @@ pub trait WeakItemHandle {
|
|||
|
||||
pub trait ItemViewHandle: 'static {
|
||||
fn item_handle(&self, cx: &AppContext) -> Box<dyn ItemHandle>;
|
||||
fn title(&self, cx: &AppContext) -> String;
|
||||
fn tab_content(&self, style: &theme::Tab, cx: &AppContext) -> ElementBox;
|
||||
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
|
||||
fn boxed_clone(&self) -> Box<dyn ItemViewHandle>;
|
||||
fn clone_on_split(&self, cx: &mut MutableAppContext) -> Option<Box<dyn ItemViewHandle>>;
|
||||
|
@ -358,8 +358,8 @@ impl<T: ItemView> ItemViewHandle for ViewHandle<T> {
|
|||
Box::new(self.read(cx).item_handle(cx))
|
||||
}
|
||||
|
||||
fn title(&self, cx: &AppContext) -> String {
|
||||
self.read(cx).title(cx)
|
||||
fn tab_content(&self, style: &theme::Tab, cx: &AppContext) -> ElementBox {
|
||||
self.read(cx).tab_content(style, cx)
|
||||
}
|
||||
|
||||
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue