WIP: start search2

This commit is contained in:
Piotr Osiewicz
2023-11-13 20:38:37 +01:00
parent 7a454bed22
commit dfd68d4cb8
18 changed files with 5115 additions and 43 deletions
+1 -1
View File
@@ -1909,7 +1909,7 @@ impl Render for Pane {
v_stack()
.size_full()
.child(self.render_tab_bar(cx))
.child(div() /* todo!(toolbar) */)
.child(self.toolbar.clone())
.child(if let Some(item) = self.active_item() {
div().flex_1().child(item.to_any())
} else {
+11 -12
View File
@@ -1,7 +1,8 @@
use std::{any::Any, sync::Arc};
use gpui::{
AnyView, AppContext, EventEmitter, Subscription, Task, View, ViewContext, WindowContext,
AnyView, AppContext, EventEmitter, Subscription, Task, View, ViewContext, WeakView,
WindowContext,
};
use project2::search::SearchQuery;
@@ -129,8 +130,7 @@ pub trait SearchableItemHandle: ItemHandle {
// todo!("here is where we need to use AnyWeakView");
impl<T: SearchableItem> SearchableItemHandle for View<T> {
fn downgrade(&self) -> Box<dyn WeakSearchableItemHandle> {
// Box::new(self.downgrade())
todo!()
Box::new(self.downgrade())
}
fn boxed_clone(&self) -> Box<dyn SearchableItemHandle> {
@@ -252,16 +252,15 @@ pub trait WeakSearchableItemHandle: WeakItemHandle {
// fn into_any(self) -> AnyWeakView;
}
// todo!()
// impl<T: SearchableItem> WeakSearchableItemHandle for WeakView<T> {
// fn upgrade(&self, cx: &AppContext) -> Option<Box<dyn SearchableItemHandle>> {
// Some(Box::new(self.upgrade(cx)?))
// }
impl<T: SearchableItem> WeakSearchableItemHandle for WeakView<T> {
fn upgrade(&self, cx: &AppContext) -> Option<Box<dyn SearchableItemHandle>> {
Some(Box::new(self.upgrade()?))
}
// // fn into_any(self) -> AnyView {
// // self.into_any()
// // }
// }
// fn into_any(self) -> AnyView {
// self.into_any()
// }
}
impl PartialEq for Box<dyn WeakSearchableItemHandle> {
fn eq(&self, other: &Self) -> bool {
+4 -2
View File
@@ -1,6 +1,7 @@
use crate::ItemHandle;
use gpui::{
AnyView, Div, Entity, EntityId, EventEmitter, Render, View, ViewContext, WindowContext,
div, AnyView, Div, Entity, EntityId, EventEmitter, ParentElement, Render, View, ViewContext,
WindowContext,
};
pub enum ToolbarItemEvent {
@@ -55,7 +56,8 @@ impl Render for Toolbar {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
todo!()
//dbg!(&self.items.len());
div().children(self.items.iter().map(|(child, _)| child.to_any()))
}
}
+1 -1
View File
@@ -68,7 +68,7 @@ use std::{
time::Duration,
};
use theme2::ActiveTheme;
pub use toolbar::{ToolbarItemLocation, ToolbarItemView};
pub use toolbar::{ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView};
use ui::{h_stack, Label};
use util::ResultExt;
use uuid::Uuid;