mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 12:54:42 +00:00
WIP
This commit is contained in:
parent
a25f962185
commit
4cb13fb39c
3 changed files with 25 additions and 11 deletions
|
@ -7,8 +7,8 @@ use anyhow::{anyhow, Context, Result};
|
|||
use collections::HashSet;
|
||||
use futures::future::try_join_all;
|
||||
use gpui::{
|
||||
elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, RenderedView,
|
||||
Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, Subscription, Task,
|
||||
View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
};
|
||||
use language::{
|
||||
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, OffsetRangeExt, Point,
|
||||
|
@ -731,7 +731,7 @@ impl Item for Editor {
|
|||
&self,
|
||||
theme: &theme::Theme,
|
||||
cx: &AppContext,
|
||||
) -> Option<Vec<Box<dyn RenderedView>>> {
|
||||
) -> Option<Vec<Box<dyn AnyRootElement>>> {
|
||||
let cursor = self.selections.newest_anchor().head();
|
||||
let multibuffer = &self.buffer().read(cx);
|
||||
let (buffer_id, symbols) =
|
||||
|
@ -753,7 +753,7 @@ impl Item for Editor {
|
|||
|
||||
let filename_label = Label::new(filename, theme.workspace.breadcrumbs.default.text.clone());
|
||||
let mut breadcrumbs =
|
||||
vec![Box::new(filename_label.boxed() as Element<Editor>) as Box<dyn RenderedView>];
|
||||
vec![Box::new(filename_label.into_root(cx)) as Box<dyn AnyRootElement>];
|
||||
breadcrumbs.extend(symbols.into_iter().map(|symbol| {
|
||||
Box::new(
|
||||
Text::new(
|
||||
|
@ -761,8 +761,8 @@ impl Item for Editor {
|
|||
theme.workspace.breadcrumbs.default.text.clone(),
|
||||
)
|
||||
.with_highlights(symbol.highlight_ranges)
|
||||
.boxed() as Element<Editor>,
|
||||
) as Box<dyn RenderedView>
|
||||
.into_root(cx) as Element<Editor>,
|
||||
) as Box<dyn AnyRootElement>
|
||||
}));
|
||||
Some(breadcrumbs)
|
||||
}
|
||||
|
|
|
@ -128,6 +128,16 @@ pub trait Drawable<V: View> {
|
|||
}
|
||||
}
|
||||
|
||||
fn into_root(self, cx: &ViewContext<V>) -> RootElement<V>
|
||||
where
|
||||
Self: 'static + Sized,
|
||||
{
|
||||
RootElement {
|
||||
element: self.boxed(),
|
||||
view: cx.handle().downgrade(),
|
||||
}
|
||||
}
|
||||
|
||||
fn named(self, name: impl Into<Cow<'static, str>>) -> Element<V>
|
||||
where
|
||||
Self: 'static + Sized,
|
||||
|
|
|
@ -15,8 +15,8 @@ use std::{
|
|||
use anyhow::Result;
|
||||
use client::{proto, Client};
|
||||
use gpui::{
|
||||
AnyViewHandle, AppContext, Element, ModelHandle, RenderedView, Task, View, ViewContext,
|
||||
ViewHandle, WeakViewHandle,
|
||||
elements::AnyRootElement, AnyViewHandle, AppContext, Element, ModelHandle, Task, View,
|
||||
ViewContext, ViewHandle, WeakViewHandle,
|
||||
};
|
||||
use project::{Project, ProjectEntryId, ProjectPath};
|
||||
use settings::{Autosave, Settings};
|
||||
|
@ -134,7 +134,11 @@ pub trait Item: View {
|
|||
ToolbarItemLocation::Hidden
|
||||
}
|
||||
|
||||
fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>> {
|
||||
fn breadcrumbs(
|
||||
&self,
|
||||
_theme: &Theme,
|
||||
_cx: &ViewContext<Self>,
|
||||
) -> Option<Vec<Box<dyn AnyRootElement>>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -221,7 +225,7 @@ pub trait ItemHandle: 'static + fmt::Debug {
|
|||
) -> gpui::Subscription;
|
||||
fn to_searchable_item_handle(&self, cx: &AppContext) -> Option<Box<dyn SearchableItemHandle>>;
|
||||
fn breadcrumb_location(&self, cx: &AppContext) -> ToolbarItemLocation;
|
||||
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>>;
|
||||
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn AnyRootElement>>>;
|
||||
fn serialized_item_kind(&self) -> Option<&'static str>;
|
||||
fn show_toolbar(&self, cx: &AppContext) -> bool;
|
||||
}
|
||||
|
@ -591,7 +595,7 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
|
|||
self.read(cx).breadcrumb_location()
|
||||
}
|
||||
|
||||
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>> {
|
||||
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn AnyRootElement>>> {
|
||||
self.read(cx).breadcrumbs(theme, cx)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue