Merge branch 'main' into search2

This commit is contained in:
Piotr Osiewicz
2023-11-20 19:23:35 +01:00
108 changed files with 2988 additions and 1900 deletions
+6 -7
View File
@@ -1,7 +1,7 @@
use crate::{status_bar::StatusItemView, Axis, Workspace};
use gpui::{
div, px, Action, AnchorCorner, AnyView, AppContext, Component, Div, Entity, EntityId,
EventEmitter, FocusHandle, FocusableView, ParentComponent, Render, SharedString, Styled,
div, px, Action, AnchorCorner, AnyView, AppContext, Div, Entity, EntityId, EventEmitter,
FocusHandle, FocusableView, ParentElement, Render, RenderOnce, SharedString, Styled,
Subscription, View, ViewContext, VisualContext, WeakView, WindowContext,
};
use schemars::JsonSchema;
@@ -476,7 +476,7 @@ impl Dock {
}
}
impl Render for Dock {
impl Render<Self> for Dock {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
@@ -662,7 +662,7 @@ impl PanelButtons {
// }
// here be kittens
impl Render for PanelButtons {
impl Render<Self> for PanelButtons {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
@@ -705,8 +705,7 @@ impl Render for PanelButtons {
};
Some(
menu_handle()
.id(name)
menu_handle(name)
.menu(move |_, cx| {
const POSITIONS: [DockPosition; 3] = [
DockPosition::Left,
@@ -781,7 +780,7 @@ pub mod test {
}
}
impl Render for TestPanel {
impl Render<Self> for TestPanel {
type Element = Div<Self>;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
+1 -1
View File
@@ -71,7 +71,7 @@ impl ModalLayer {
}
}
impl Render for ModalLayer {
impl Render<Self> for ModalLayer {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
+3 -3
View File
@@ -13,9 +13,9 @@ pub enum NotificationEvent {
Dismiss,
}
pub trait Notification: EventEmitter<NotificationEvent> + Render {}
pub trait Notification: EventEmitter<NotificationEvent> + Render<Self> {}
impl<V: EventEmitter<NotificationEvent> + Render> Notification for V {}
impl<V: EventEmitter<NotificationEvent> + Render<Self>> Notification for V {}
pub trait NotificationHandle: Send {
fn id(&self) -> EntityId;
@@ -253,7 +253,7 @@ pub mod simple_message_notification {
// }
}
impl Render for MessageNotification {
impl Render<Self> for MessageNotification {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
+8 -8
View File
@@ -7,9 +7,9 @@ use crate::{
use anyhow::Result;
use collections::{HashMap, HashSet, VecDeque};
use gpui::{
actions, prelude::*, Action, AppContext, AsyncWindowContext, Component, Div, EntityId,
EventEmitter, FocusHandle, Focusable, FocusableView, Model, Pixels, Point, PromptLevel, Render,
Task, View, ViewContext, VisualContext, WeakView, WindowContext,
actions, prelude::*, Action, AppContext, AsyncWindowContext, Div, EntityId, EventEmitter,
FocusHandle, Focusable, FocusableView, Model, Pixels, Point, PromptLevel, Render, Task, View,
ViewContext, VisualContext, WeakView, WindowContext,
};
use parking_lot::Mutex;
use project2::{Project, ProjectEntryId, ProjectPath};
@@ -594,7 +594,7 @@ impl Pane {
self.items.iter()
}
pub fn items_of_type<T: Render>(&self) -> impl '_ + Iterator<Item = View<T>> {
pub fn items_of_type<T: Render<T>>(&self) -> impl '_ + Iterator<Item = View<T>> {
self.items
.iter()
.filter_map(|item| item.to_any().downcast().ok())
@@ -1344,7 +1344,7 @@ impl Pane {
item: &Box<dyn ItemHandle>,
detail: usize,
cx: &mut ViewContext<'_, Pane>,
) -> impl Component<Self> {
) -> impl RenderOnce<Self> {
let label = item.tab_content(Some(detail), cx);
let close_icon = || {
let id = item.item_id();
@@ -1437,7 +1437,7 @@ impl Pane {
)
}
fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl Component<Self> {
fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl RenderOnce<Self> {
div()
.group("tab_bar")
.id("tab_bar")
@@ -1891,7 +1891,7 @@ impl FocusableView for Pane {
}
}
impl Render for Pane {
impl Render<Self> for Pane {
type Element = Focusable<Self, Div<Self>>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
@@ -2945,7 +2945,7 @@ struct DraggedTab {
title: String,
}
impl Render for DraggedTab {
impl Render<Self> for DraggedTab {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
+9 -8
View File
@@ -6,7 +6,9 @@ use db2::sqlez::{
bindable::{Bind, Column, StaticColumnCount},
statement::Statement,
};
use gpui::{point, size, AnyElement, AnyWeakView, Bounds, Model, Pixels, Point, View, ViewContext};
use gpui::{
point, size, AnyWeakView, Bounds, Div, Model, Pixels, Point, RenderOnce, View, ViewContext,
};
use parking_lot::Mutex;
use project2::Project;
use serde::Deserialize;
@@ -130,7 +132,7 @@ impl PaneGroup {
zoomed: Option<&AnyWeakView>,
app_state: &Arc<AppState>,
cx: &mut ViewContext<Workspace>,
) -> impl Component<Workspace> {
) -> impl RenderOnce<Workspace> {
self.root.render(
project,
0,
@@ -202,7 +204,7 @@ impl Member {
zoomed: Option<&AnyWeakView>,
app_state: &Arc<AppState>,
cx: &mut ViewContext<Workspace>,
) -> impl Component<Workspace> {
) -> impl RenderOnce<Workspace> {
match self {
Member::Pane(pane) => {
// todo!()
@@ -212,7 +214,7 @@ impl Member {
// Some(pane)
// };
div().size_full().child(pane.clone()).render()
div().size_full().child(pane.clone())
// Stack::new()
// .with_child(pane_element.contained().with_border(leader_border))
@@ -559,7 +561,7 @@ impl PaneAxis {
zoomed: Option<&AnyWeakView>,
app_state: &Arc<AppState>,
cx: &mut ViewContext<Workspace>,
) -> AnyElement<Workspace> {
) -> Div<Workspace> {
debug_assert!(self.members.len() == self.flexes.lock().len());
div()
@@ -582,11 +584,10 @@ impl PaneAxis {
app_state,
cx,
)
.render(),
Member::Pane(pane) => pane.clone().render(),
.render_into_any(),
Member::Pane(pane) => pane.clone().render_into_any(),
}
}))
.render()
// let mut pane_axis = PaneAxisElement::new(
// self.axis,
+5 -5
View File
@@ -2,14 +2,14 @@ use std::any::TypeId;
use crate::{ItemHandle, Pane};
use gpui::{
div, AnyView, Component, Div, ParentComponent, Render, Styled, Subscription, View, ViewContext,
div, AnyView, Div, ParentElement, Render, RenderOnce, Styled, Subscription, View, ViewContext,
WindowContext,
};
use theme2::ActiveTheme;
use ui::h_stack;
use util::ResultExt;
pub trait StatusItemView: Render {
pub trait StatusItemView: Render<Self> {
fn set_active_pane_item(
&mut self,
active_pane_item: Option<&dyn crate::ItemHandle>,
@@ -34,7 +34,7 @@ pub struct StatusBar {
_observe_active_pane: Subscription,
}
impl Render for StatusBar {
impl Render<Self> for StatusBar {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
@@ -53,14 +53,14 @@ impl Render for StatusBar {
}
impl StatusBar {
fn render_left_tools(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
fn render_left_tools(&self, cx: &mut ViewContext<Self>) -> impl RenderOnce<Self> {
h_stack()
.items_center()
.gap_2()
.children(self.left_items.iter().map(|item| item.to_any()))
}
fn render_right_tools(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
fn render_right_tools(&self, cx: &mut ViewContext<Self>) -> impl RenderOnce<Self> {
h_stack()
.items_center()
.gap_2()
+3 -3
View File
@@ -1,6 +1,6 @@
use crate::ItemHandle;
use gpui::{
AnyView, Div, Entity, EntityId, EventEmitter, ParentComponent, Render, Styled, View,
AnyView, Div, Entity, EntityId, EventEmitter, ParentElement as _, Render, Styled, View,
ViewContext, WindowContext,
};
use theme2::ActiveTheme;
@@ -10,7 +10,7 @@ pub enum ToolbarItemEvent {
ChangeLocation(ToolbarItemLocation),
}
pub trait ToolbarItemView: Render + EventEmitter<ToolbarItemEvent> {
pub trait ToolbarItemView: Render<Self> + EventEmitter<ToolbarItemEvent> {
fn set_active_pane_item(
&mut self,
active_pane_item: Option<&dyn crate::ItemHandle>,
@@ -76,7 +76,7 @@ impl Toolbar {
}
}
impl Render for Toolbar {
impl Render<Self> for Toolbar {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
+5 -5
View File
@@ -31,10 +31,10 @@ use futures::{
use gpui::{
actions, div, point, size, Action, AnyModel, AnyView, AnyWeakView, AppContext, AsyncAppContext,
AsyncWindowContext, Bounds, Context, Div, Entity, EntityId, EventEmitter, FocusHandle,
FocusableView, GlobalPixels, InteractiveComponent, KeyContext, ManagedView, Model,
ModelContext, ParentComponent, PathPromptOptions, Point, PromptLevel, Render, Size, Styled,
Subscription, Task, View, ViewContext, VisualContext, WeakView, WindowBounds, WindowContext,
WindowHandle, WindowOptions,
FocusableView, GlobalPixels, InteractiveElement, KeyContext, ManagedView, Model, ModelContext,
ParentElement, PathPromptOptions, Point, PromptLevel, Render, Size, Styled, Subscription, Task,
View, ViewContext, VisualContext, WeakView, WindowBounds, WindowContext, WindowHandle,
WindowOptions,
};
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, ProjectItem};
use itertools::Itertools;
@@ -3594,7 +3594,7 @@ impl FocusableView for Workspace {
}
}
impl Render for Workspace {
impl Render<Self> for Workspace {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {