mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-05 10:20:51 +00:00
WIP
This commit is contained in:
parent
e115baa60c
commit
e6cc132b19
14 changed files with 119 additions and 83 deletions
|
@ -3,7 +3,8 @@ use gpui::{
|
||||||
elements::*,
|
elements::*,
|
||||||
geometry::rect::RectF,
|
geometry::rect::RectF,
|
||||||
platform::{WindowBounds, WindowKind, WindowOptions},
|
platform::{WindowBounds, WindowKind, WindowOptions},
|
||||||
AppContext, ClipboardItem, Element, Entity, View, ViewContext, ViewHandle,
|
AnyViewHandle, AppContext, ClipboardItem, Element, ElementBox, Entity, View, ViewContext,
|
||||||
|
ViewHandle,
|
||||||
};
|
};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use theme::ui::modal;
|
use theme::ui::modal;
|
||||||
|
@ -28,9 +29,9 @@ pub fn init(cx: &mut AppContext) {
|
||||||
if let Some(code_verification_handle) = code_verification.as_mut() {
|
if let Some(code_verification_handle) = code_verification.as_mut() {
|
||||||
if cx.has_window(code_verification_handle.window_id()) {
|
if cx.has_window(code_verification_handle.window_id()) {
|
||||||
code_verification_handle.update(cx, |code_verification_view, cx| {
|
code_verification_handle.update(cx, |code_verification_view, cx| {
|
||||||
code_verification_view.set_status(status, cx)
|
code_verification_view.set_status(status, cx);
|
||||||
|
cx.activate_window();
|
||||||
});
|
});
|
||||||
cx.activate_window(code_verification_handle.window_id());
|
|
||||||
} else {
|
} else {
|
||||||
create_copilot_auth_window(cx, &status, &mut code_verification);
|
create_copilot_auth_window(cx, &status, &mut code_verification);
|
||||||
}
|
}
|
||||||
|
@ -41,11 +42,11 @@ pub fn init(cx: &mut AppContext) {
|
||||||
Status::Authorized | Status::Unauthorized => {
|
Status::Authorized | Status::Unauthorized => {
|
||||||
if let Some(code_verification) = code_verification.as_ref() {
|
if let Some(code_verification) = code_verification.as_ref() {
|
||||||
code_verification.update(cx, |code_verification, cx| {
|
code_verification.update(cx, |code_verification, cx| {
|
||||||
code_verification.set_status(status, cx)
|
code_verification.set_status(status, cx);
|
||||||
|
cx.activate_window();
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.platform().activate(true);
|
cx.platform().activate(true);
|
||||||
cx.activate_window(code_verification.window_id());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -96,8 +97,8 @@ impl CopilotCodeVerification {
|
||||||
fn render_device_code(
|
fn render_device_code(
|
||||||
data: &PromptUserDeviceFlow,
|
data: &PromptUserDeviceFlow,
|
||||||
style: &theme::Copilot,
|
style: &theme::Copilot,
|
||||||
cx: &mut gpui::ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> ElementBox {
|
) -> ElementBox<Self> {
|
||||||
let copied = cx
|
let copied = cx
|
||||||
.read_from_clipboard()
|
.read_from_clipboard()
|
||||||
.map(|item| item.text() == &data.user_code)
|
.map(|item| item.text() == &data.user_code)
|
||||||
|
@ -105,7 +106,7 @@ impl CopilotCodeVerification {
|
||||||
|
|
||||||
let device_code_style = &style.auth.prompting.device_code;
|
let device_code_style = &style.auth.prompting.device_code;
|
||||||
|
|
||||||
MouseEventHandler::<Self>::new(0, cx, |state, _cx| {
|
MouseEventHandler::<Self, _>::new(0, cx, |state, _cx| {
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_children([
|
.with_children([
|
||||||
Label::new(data.user_code.clone(), device_code_style.text.clone())
|
Label::new(data.user_code.clone(), device_code_style.text.clone())
|
||||||
|
@ -132,7 +133,7 @@ impl CopilotCodeVerification {
|
||||||
})
|
})
|
||||||
.on_click(gpui::platform::MouseButton::Left, {
|
.on_click(gpui::platform::MouseButton::Left, {
|
||||||
let user_code = data.user_code.clone();
|
let user_code = data.user_code.clone();
|
||||||
move |_, cx| {
|
move |_, _, cx| {
|
||||||
cx.platform()
|
cx.platform()
|
||||||
.write_to_clipboard(ClipboardItem::new(user_code.clone()));
|
.write_to_clipboard(ClipboardItem::new(user_code.clone()));
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
@ -145,8 +146,10 @@ impl CopilotCodeVerification {
|
||||||
fn render_prompting_modal(
|
fn render_prompting_modal(
|
||||||
data: &PromptUserDeviceFlow,
|
data: &PromptUserDeviceFlow,
|
||||||
style: &theme::Copilot,
|
style: &theme::Copilot,
|
||||||
cx: &mut gpui::ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> ElementBox {
|
) -> ElementBox<Self> {
|
||||||
|
enum ConnectButton {}
|
||||||
|
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_children([
|
.with_children([
|
||||||
Flex::column()
|
Flex::column()
|
||||||
|
@ -188,14 +191,14 @@ impl CopilotCodeVerification {
|
||||||
.contained()
|
.contained()
|
||||||
.with_style(style.auth.prompting.hint.container.clone())
|
.with_style(style.auth.prompting.hint.container.clone())
|
||||||
.boxed(),
|
.boxed(),
|
||||||
theme::ui::cta_button_with_click(
|
theme::ui::cta_button_with_click::<ConnectButton, _, _, _>(
|
||||||
"Connect to GitHub",
|
"Connect to GitHub",
|
||||||
style.auth.content_width,
|
style.auth.content_width,
|
||||||
&style.auth.cta_button,
|
&style.auth.cta_button,
|
||||||
cx,
|
cx,
|
||||||
{
|
{
|
||||||
let verification_uri = data.verification_uri.clone();
|
let verification_uri = data.verification_uri.clone();
|
||||||
move |_, cx| cx.platform().open_url(&verification_uri)
|
move |_, _, cx| cx.platform().open_url(&verification_uri)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.boxed(),
|
.boxed(),
|
||||||
|
@ -205,8 +208,10 @@ impl CopilotCodeVerification {
|
||||||
}
|
}
|
||||||
fn render_enabled_modal(
|
fn render_enabled_modal(
|
||||||
style: &theme::Copilot,
|
style: &theme::Copilot,
|
||||||
cx: &mut gpui::ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> ElementBox {
|
) -> ElementBox<Self> {
|
||||||
|
enum DoneButton {}
|
||||||
|
|
||||||
let enabled_style = &style.auth.authorized;
|
let enabled_style = &style.auth.authorized;
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_children([
|
.with_children([
|
||||||
|
@ -237,12 +242,12 @@ impl CopilotCodeVerification {
|
||||||
.contained()
|
.contained()
|
||||||
.with_style(enabled_style.hint.container)
|
.with_style(enabled_style.hint.container)
|
||||||
.boxed(),
|
.boxed(),
|
||||||
theme::ui::cta_button_with_click(
|
theme::ui::cta_button_with_click::<DoneButton, _, _, _>(
|
||||||
"Done",
|
"Done",
|
||||||
style.auth.content_width,
|
style.auth.content_width,
|
||||||
&style.auth.cta_button,
|
&style.auth.cta_button,
|
||||||
cx,
|
cx,
|
||||||
|_, cx| {
|
|_, _, cx| {
|
||||||
let window_id = cx.window_id();
|
let window_id = cx.window_id();
|
||||||
cx.remove_window(window_id)
|
cx.remove_window(window_id)
|
||||||
},
|
},
|
||||||
|
@ -254,8 +259,8 @@ impl CopilotCodeVerification {
|
||||||
}
|
}
|
||||||
fn render_unauthorized_modal(
|
fn render_unauthorized_modal(
|
||||||
style: &theme::Copilot,
|
style: &theme::Copilot,
|
||||||
cx: &mut gpui::ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> ElementBox {
|
) -> ElementBox<Self> {
|
||||||
let unauthorized_style = &style.auth.not_authorized;
|
let unauthorized_style = &style.auth.not_authorized;
|
||||||
|
|
||||||
Flex::column()
|
Flex::column()
|
||||||
|
@ -298,12 +303,12 @@ impl CopilotCodeVerification {
|
||||||
.contained()
|
.contained()
|
||||||
.with_style(unauthorized_style.warning.container)
|
.with_style(unauthorized_style.warning.container)
|
||||||
.boxed(),
|
.boxed(),
|
||||||
theme::ui::cta_button_with_click(
|
theme::ui::cta_button_with_click::<CopilotCodeVerification, _, _, _>(
|
||||||
"Subscribe on GitHub",
|
"Subscribe on GitHub",
|
||||||
style.auth.content_width,
|
style.auth.content_width,
|
||||||
&style.auth.cta_button,
|
&style.auth.cta_button,
|
||||||
cx,
|
cx,
|
||||||
|_, cx| {
|
|_, _, cx| {
|
||||||
let window_id = cx.window_id();
|
let window_id = cx.window_id();
|
||||||
cx.remove_window(window_id);
|
cx.remove_window(window_id);
|
||||||
cx.platform().open_url(COPILOT_SIGN_UP_URL)
|
cx.platform().open_url(COPILOT_SIGN_UP_URL)
|
||||||
|
@ -325,18 +330,20 @@ impl View for CopilotCodeVerification {
|
||||||
"CopilotCodeVerification"
|
"CopilotCodeVerification"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut gpui::ViewContext<Self>) {
|
fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
|
||||||
cx.notify()
|
cx.notify()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn focus_out(&mut self, _: gpui::AnyViewHandle, cx: &mut gpui::ViewContext<Self>) {
|
fn focus_out(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
|
||||||
cx.notify()
|
cx.notify()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> gpui::ElementBox {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||||
|
enum ConnectModal {}
|
||||||
|
|
||||||
let style = cx.global::<Settings>().theme.clone();
|
let style = cx.global::<Settings>().theme.clone();
|
||||||
|
|
||||||
modal("Connect Copilot to Zed", &style.copilot.modal, cx, |cx| {
|
modal::<ConnectModal, _, _, _>("Connect Copilot to Zed", &style.copilot.modal, cx, |cx| {
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_children([
|
.with_children([
|
||||||
theme::ui::icon(&style.copilot.auth.header).boxed(),
|
theme::ui::icon(&style.copilot.auth.header).boxed(),
|
||||||
|
|
|
@ -25,6 +25,8 @@ pub use self::{
|
||||||
keystroke_label::*, label::*, list::*, mouse_event_handler::*, overlay::*, resizable::*,
|
keystroke_label::*, label::*, list::*, mouse_event_handler::*, overlay::*, resizable::*,
|
||||||
stack::*, svg::*, text::*, tooltip::*, uniform_list::*,
|
stack::*, svg::*, text::*, tooltip::*, uniform_list::*,
|
||||||
};
|
};
|
||||||
|
pub use crate::window::ChildView;
|
||||||
|
|
||||||
use self::{clipped::Clipped, expanded::Expanded};
|
use self::{clipped::Clipped, expanded::Expanded};
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{
|
geometry::{
|
||||||
|
|
|
@ -315,7 +315,7 @@ impl Dock {
|
||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
anchor: DockAnchor,
|
anchor: DockAnchor,
|
||||||
cx: &mut ViewContext<Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) -> Option<ElementBox> {
|
) -> Option<ElementBox<Self>> {
|
||||||
let style = &theme.workspace.dock;
|
let style = &theme.workspace.dock;
|
||||||
|
|
||||||
self.position
|
self.position
|
||||||
|
|
|
@ -34,7 +34,7 @@ impl View for ToggleDockButton {
|
||||||
"Dock Toggle"
|
"Dock Toggle"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> ElementBox<Self> {
|
||||||
let workspace = self.workspace.upgrade(cx);
|
let workspace = self.workspace.upgrade(cx);
|
||||||
|
|
||||||
if workspace.is_none() {
|
if workspace.is_none() {
|
||||||
|
|
|
@ -47,8 +47,12 @@ pub trait Item: View {
|
||||||
fn tab_description<'a>(&'a self, _: usize, _: &'a AppContext) -> Option<Cow<'a, str>> {
|
fn tab_description<'a>(&'a self, _: usize, _: &'a AppContext) -> Option<Cow<'a, str>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
fn tab_content(&self, detail: Option<usize>, style: &theme::Tab, cx: &AppContext)
|
fn tab_content(
|
||||||
-> ElementBox;
|
&self,
|
||||||
|
detail: Option<usize>,
|
||||||
|
style: &theme::Tab,
|
||||||
|
cx: &AppContext,
|
||||||
|
) -> ElementBox<Self>;
|
||||||
fn for_each_project_item(&self, _: &AppContext, _: &mut dyn FnMut(usize, &dyn project::Item)) {}
|
fn for_each_project_item(&self, _: &AppContext, _: &mut dyn FnMut(usize, &dyn project::Item)) {}
|
||||||
fn is_singleton(&self, _cx: &AppContext) -> bool {
|
fn is_singleton(&self, _cx: &AppContext) -> bool {
|
||||||
false
|
false
|
||||||
|
@ -130,7 +134,7 @@ pub trait Item: View {
|
||||||
ToolbarItemLocation::Hidden
|
ToolbarItemLocation::Hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<ElementBox>> {
|
fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<ElementBox<Self>>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,8 +167,12 @@ pub trait ItemHandle: 'static + fmt::Debug {
|
||||||
handler: Box<dyn Fn(ItemEvent, &mut AppContext)>,
|
handler: Box<dyn Fn(ItemEvent, &mut AppContext)>,
|
||||||
) -> gpui::Subscription;
|
) -> gpui::Subscription;
|
||||||
fn tab_description<'a>(&self, detail: usize, cx: &'a AppContext) -> Option<Cow<'a, str>>;
|
fn tab_description<'a>(&self, detail: usize, cx: &'a AppContext) -> Option<Cow<'a, str>>;
|
||||||
fn tab_content(&self, detail: Option<usize>, style: &theme::Tab, cx: &AppContext)
|
fn tab_content(
|
||||||
-> ElementBox;
|
&self,
|
||||||
|
detail: Option<usize>,
|
||||||
|
style: &theme::Tab,
|
||||||
|
cx: &AppContext,
|
||||||
|
) -> ElementBox<Pane>;
|
||||||
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
|
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
|
||||||
fn project_entry_ids(&self, cx: &AppContext) -> SmallVec<[ProjectEntryId; 3]>;
|
fn project_entry_ids(&self, cx: &AppContext) -> SmallVec<[ProjectEntryId; 3]>;
|
||||||
fn project_item_model_ids(&self, cx: &AppContext) -> SmallVec<[usize; 3]>;
|
fn project_item_model_ids(&self, cx: &AppContext) -> SmallVec<[usize; 3]>;
|
||||||
|
@ -213,7 +221,7 @@ pub trait ItemHandle: 'static + fmt::Debug {
|
||||||
) -> gpui::Subscription;
|
) -> gpui::Subscription;
|
||||||
fn to_searchable_item_handle(&self, cx: &AppContext) -> Option<Box<dyn SearchableItemHandle>>;
|
fn to_searchable_item_handle(&self, cx: &AppContext) -> Option<Box<dyn SearchableItemHandle>>;
|
||||||
fn breadcrumb_location(&self, cx: &AppContext) -> ToolbarItemLocation;
|
fn breadcrumb_location(&self, cx: &AppContext) -> ToolbarItemLocation;
|
||||||
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<ElementBox>>;
|
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<ElementBox<Pane>>>;
|
||||||
fn serialized_item_kind(&self) -> Option<&'static str>;
|
fn serialized_item_kind(&self) -> Option<&'static str>;
|
||||||
fn show_toolbar(&self, cx: &AppContext) -> bool;
|
fn show_toolbar(&self, cx: &AppContext) -> bool;
|
||||||
}
|
}
|
||||||
|
@ -257,7 +265,7 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
|
||||||
detail: Option<usize>,
|
detail: Option<usize>,
|
||||||
style: &theme::Tab,
|
style: &theme::Tab,
|
||||||
cx: &AppContext,
|
cx: &AppContext,
|
||||||
) -> ElementBox {
|
) -> ElementBox<Pane> {
|
||||||
self.read(cx).tab_content(detail, style, cx)
|
self.read(cx).tab_content(detail, style, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,7 +591,7 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
|
||||||
self.read(cx).breadcrumb_location()
|
self.read(cx).breadcrumb_location()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<ElementBox>> {
|
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<ElementBox<Self>>> {
|
||||||
self.read(cx).breadcrumbs(theme, cx)
|
self.read(cx).breadcrumbs(theme, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -899,7 +907,7 @@ pub(crate) mod test {
|
||||||
"TestItem"
|
"TestItem"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, _: &mut ViewContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -912,7 +920,12 @@ pub(crate) mod test {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tab_content(&self, detail: Option<usize>, _: &theme::Tab, _: &AppContext) -> ElementBox {
|
fn tab_content(
|
||||||
|
&self,
|
||||||
|
detail: Option<usize>,
|
||||||
|
_: &theme::Tab,
|
||||||
|
_: &AppContext,
|
||||||
|
) -> ElementBox<Self> {
|
||||||
self.tab_detail.set(detail);
|
self.tab_detail.set(detail);
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,7 @@ pub mod simple_message_notification {
|
||||||
"MessageNotification"
|
"MessageNotification"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> gpui::ElementBox {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> gpui::ElementBox<Self> {
|
||||||
let theme = cx.global::<Settings>().theme.clone();
|
let theme = cx.global::<Settings>().theme.clone();
|
||||||
let theme = &theme.simple_message_notification;
|
let theme = &theme.simple_message_notification;
|
||||||
|
|
||||||
|
|
|
@ -1383,8 +1383,8 @@ impl Pane {
|
||||||
detail: Option<usize>,
|
detail: Option<usize>,
|
||||||
hovered: bool,
|
hovered: bool,
|
||||||
tab_style: &theme::Tab,
|
tab_style: &theme::Tab,
|
||||||
cx: &mut ViewContext<V>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> ElementBox {
|
) -> ElementBox<Self> {
|
||||||
let title = item.tab_content(detail, &tab_style, cx);
|
let title = item.tab_content(detail, &tab_style, cx);
|
||||||
let mut container = tab_style.container.clone();
|
let mut container = tab_style.container.clone();
|
||||||
if first {
|
if first {
|
||||||
|
@ -1404,7 +1404,7 @@ impl Pane {
|
||||||
};
|
};
|
||||||
|
|
||||||
ConstrainedBox::new(
|
ConstrainedBox::new(
|
||||||
Canvas::new(move |bounds, _, cx| {
|
Canvas::new(move |scene, bounds, _, cx| {
|
||||||
if let Some(color) = icon_color {
|
if let Some(color) = icon_color {
|
||||||
let square = RectF::new(bounds.origin(), vec2f(diameter, diameter));
|
let square = RectF::new(bounds.origin(), vec2f(diameter, diameter));
|
||||||
scene.push_quad(Quad {
|
scene.push_quad(Quad {
|
||||||
|
@ -1475,7 +1475,11 @@ impl Pane {
|
||||||
.boxed()
|
.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_tab_bar_buttons(&mut self, theme: &Theme, cx: &mut ViewContext<Self>) -> ElementBox {
|
fn render_tab_bar_buttons(
|
||||||
|
&mut self,
|
||||||
|
theme: &Theme,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) -> ElementBox<Self> {
|
||||||
Flex::row()
|
Flex::row()
|
||||||
// New menu
|
// New menu
|
||||||
.with_child(render_tab_bar_button(
|
.with_child(render_tab_bar_button(
|
||||||
|
@ -1524,7 +1528,11 @@ impl Pane {
|
||||||
.boxed()
|
.boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_blank_pane(&mut self, theme: &Theme, _cx: &mut ViewContext<Self>) -> ElementBox {
|
fn render_blank_pane(
|
||||||
|
&mut self,
|
||||||
|
theme: &Theme,
|
||||||
|
_cx: &mut ViewContext<Self>,
|
||||||
|
) -> ElementBox<Self> {
|
||||||
let background = theme.workspace.background;
|
let background = theme.workspace.background;
|
||||||
Empty::new()
|
Empty::new()
|
||||||
.contained()
|
.contained()
|
||||||
|
@ -1542,7 +1550,7 @@ impl View for Pane {
|
||||||
"Pane"
|
"Pane"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||||
let this = cx.handle();
|
let this = cx.handle();
|
||||||
|
|
||||||
enum MouseNavigationHandler {}
|
enum MouseNavigationHandler {}
|
||||||
|
@ -1703,7 +1711,7 @@ fn render_tab_bar_button<A: Action + Clone>(
|
||||||
cx: &mut ViewContext<Pane>,
|
cx: &mut ViewContext<Pane>,
|
||||||
action: A,
|
action: A,
|
||||||
context_menu: Option<ViewHandle<ContextMenu>>,
|
context_menu: Option<ViewHandle<ContextMenu>>,
|
||||||
) -> ElementBox {
|
) -> ElementBox<Pane> {
|
||||||
enum TabBarButton {}
|
enum TabBarButton {}
|
||||||
|
|
||||||
Stack::new()
|
Stack::new()
|
||||||
|
@ -1837,10 +1845,11 @@ impl NavHistory {
|
||||||
|
|
||||||
pub struct PaneBackdrop {
|
pub struct PaneBackdrop {
|
||||||
child_view: usize,
|
child_view: usize,
|
||||||
child: ElementBox,
|
child: ElementBox<Pane>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PaneBackdrop {
|
impl PaneBackdrop {
|
||||||
pub fn new(pane_item_view: usize, child: ElementBox) -> Self {
|
pub fn new(pane_item_view: usize, child: ElementBox<Pane>) -> Self {
|
||||||
PaneBackdrop {
|
PaneBackdrop {
|
||||||
child,
|
child,
|
||||||
child_view: pane_item_view,
|
child_view: pane_item_view,
|
||||||
|
@ -1906,8 +1915,8 @@ impl Element<Pane> for PaneBackdrop {
|
||||||
_visible_bounds: RectF,
|
_visible_bounds: RectF,
|
||||||
_layout: &Self::LayoutState,
|
_layout: &Self::LayoutState,
|
||||||
_paint: &Self::PaintState,
|
_paint: &Self::PaintState,
|
||||||
view: &V,
|
view: &Pane,
|
||||||
cx: &gpui::ViewContext<V>,
|
cx: &gpui::ViewContext<Pane>,
|
||||||
) -> Option<RectF> {
|
) -> Option<RectF> {
|
||||||
self.child.rect_for_text_range(range_utf16, view, cx)
|
self.child.rect_for_text_range(range_utf16, view, cx)
|
||||||
}
|
}
|
||||||
|
@ -1917,8 +1926,8 @@ impl Element<Pane> for PaneBackdrop {
|
||||||
_bounds: RectF,
|
_bounds: RectF,
|
||||||
_layout: &Self::LayoutState,
|
_layout: &Self::LayoutState,
|
||||||
_paint: &Self::PaintState,
|
_paint: &Self::PaintState,
|
||||||
view: &V,
|
view: &Pane,
|
||||||
cx: &gpui::ViewContext<V>,
|
cx: &gpui::ViewContext<Pane>,
|
||||||
) -> serde_json::Value {
|
) -> serde_json::Value {
|
||||||
gpui::json::json!({
|
gpui::json::json!({
|
||||||
"type": "Pane Back Drop",
|
"type": "Pane Back Drop",
|
||||||
|
|
|
@ -5,7 +5,7 @@ use gpui::{
|
||||||
geometry::{rect::RectF, vector::Vector2F},
|
geometry::{rect::RectF, vector::Vector2F},
|
||||||
platform::MouseButton,
|
platform::MouseButton,
|
||||||
scene::MouseUp,
|
scene::MouseUp,
|
||||||
AppContext, Element, ElementBox, EventContext, MouseState, Quad, ViewContext, WeakViewHandle,
|
AppContext, Element, ElementBox, MouseState, Quad, ViewContext, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use project::ProjectEntryId;
|
use project::ProjectEntryId;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
@ -24,10 +24,10 @@ pub fn dragged_item_receiver<Tag, F>(
|
||||||
split_margin: Option<f32>,
|
split_margin: Option<f32>,
|
||||||
cx: &mut ViewContext<Pane>,
|
cx: &mut ViewContext<Pane>,
|
||||||
render_child: F,
|
render_child: F,
|
||||||
) -> MouseEventHandler<Tag>
|
) -> MouseEventHandler<Tag, Pane>
|
||||||
where
|
where
|
||||||
Tag: 'static,
|
Tag: 'static,
|
||||||
F: FnOnce(&mut MouseState, &mut ViewContext<Pane>) -> ElementBox,
|
F: FnOnce(&mut MouseState, &mut ViewContext<Pane>) -> ElementBox<Pane>,
|
||||||
{
|
{
|
||||||
MouseEventHandler::<Tag>::above(region_id, cx, |state, _, cx| {
|
MouseEventHandler::<Tag>::above(region_id, cx, |state, _, cx| {
|
||||||
// Observing hovered will cause a render when the mouse enters regardless
|
// Observing hovered will cause a render when the mouse enters regardless
|
||||||
|
@ -48,7 +48,7 @@ where
|
||||||
Stack::new()
|
Stack::new()
|
||||||
.with_child(render_child(state, cx))
|
.with_child(render_child(state, cx))
|
||||||
.with_children(drag_position.map(|drag_position| {
|
.with_children(drag_position.map(|drag_position| {
|
||||||
Canvas::new(move |bounds, _, cx| {
|
Canvas::new(move |scene, bounds, _, cx| {
|
||||||
if bounds.contains_point(drag_position) {
|
if bounds.contains_point(drag_position) {
|
||||||
let overlay_region = split_margin
|
let overlay_region = split_margin
|
||||||
.and_then(|split_margin| {
|
.and_then(|split_margin| {
|
||||||
|
@ -58,7 +58,7 @@ where
|
||||||
.map(|(dir, margin)| dir.along_edge(bounds, margin))
|
.map(|(dir, margin)| dir.along_edge(bounds, margin))
|
||||||
.unwrap_or(bounds);
|
.unwrap_or(bounds);
|
||||||
|
|
||||||
cx.paint_stacking_context(None, None, |cx| {
|
scene.paint_stacking_context(None, None, |cx| {
|
||||||
scene.push_quad(Quad {
|
scene.push_quad(Quad {
|
||||||
bounds: overlay_region,
|
bounds: overlay_region,
|
||||||
background: Some(overlay_color(cx)),
|
background: Some(overlay_color(cx)),
|
||||||
|
@ -102,7 +102,7 @@ pub fn handle_dropped_item(
|
||||||
index: usize,
|
index: usize,
|
||||||
allow_same_pane: bool,
|
allow_same_pane: bool,
|
||||||
split_margin: Option<f32>,
|
split_margin: Option<f32>,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Pane>,
|
||||||
) {
|
) {
|
||||||
enum Action {
|
enum Action {
|
||||||
Move(WeakViewHandle<Pane>, usize),
|
Move(WeakViewHandle<Pane>, usize),
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl PaneGroup {
|
||||||
active_call: Option<&ModelHandle<ActiveCall>>,
|
active_call: Option<&ModelHandle<ActiveCall>>,
|
||||||
active_pane: &ViewHandle<Pane>,
|
active_pane: &ViewHandle<Pane>,
|
||||||
cx: &mut ViewContext<Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) -> ElementBox {
|
) -> ElementBox<Workspace> {
|
||||||
self.root.render(
|
self.root.render(
|
||||||
project,
|
project,
|
||||||
theme,
|
theme,
|
||||||
|
@ -132,7 +132,7 @@ impl Member {
|
||||||
active_call: Option<&ModelHandle<ActiveCall>>,
|
active_call: Option<&ModelHandle<ActiveCall>>,
|
||||||
active_pane: &ViewHandle<Pane>,
|
active_pane: &ViewHandle<Pane>,
|
||||||
cx: &mut ViewContext<Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) -> ElementBox {
|
) -> ElementBox<Workspace> {
|
||||||
enum FollowIntoExternalProject {}
|
enum FollowIntoExternalProject {}
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
|
@ -367,7 +367,7 @@ impl PaneAxis {
|
||||||
active_call: Option<&ModelHandle<ActiveCall>>,
|
active_call: Option<&ModelHandle<ActiveCall>>,
|
||||||
active_pane: &ViewHandle<Pane>,
|
active_pane: &ViewHandle<Pane>,
|
||||||
cx: &mut ViewContext<Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) -> ElementBox {
|
) -> ElementBox<Workspace> {
|
||||||
let last_member_ix = self.members.len() - 1;
|
let last_member_ix = self.members.len() - 1;
|
||||||
Flex::new(self.axis)
|
Flex::new(self.axis)
|
||||||
.with_children(self.members.iter().enumerate().map(|(ix, member)| {
|
.with_children(self.members.iter().enumerate().map(|(ix, member)| {
|
||||||
|
|
|
@ -64,12 +64,12 @@ impl View for SharedScreen {
|
||||||
"SharedScreen"
|
"SharedScreen"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||||
enum Focus {}
|
enum Focus {}
|
||||||
|
|
||||||
let frame = self.frame.clone();
|
let frame = self.frame.clone();
|
||||||
MouseEventHandler::<Focus>::new(0, cx, |_, cx| {
|
MouseEventHandler::<Focus>::new(0, cx, |_, cx| {
|
||||||
Canvas::new(move |bounds, _, cx| {
|
Canvas::new(move |scene, bounds, _, cx| {
|
||||||
if let Some(frame) = frame.clone() {
|
if let Some(frame) = frame.clone() {
|
||||||
let size = constrain_size_preserving_aspect_ratio(
|
let size = constrain_size_preserving_aspect_ratio(
|
||||||
bounds.size(),
|
bounds.size(),
|
||||||
|
@ -103,7 +103,7 @@ impl Item for SharedScreen {
|
||||||
_: Option<usize>,
|
_: Option<usize>,
|
||||||
style: &theme::Tab,
|
style: &theme::Tab,
|
||||||
_: &AppContext,
|
_: &AppContext,
|
||||||
) -> gpui::ElementBox {
|
) -> gpui::ElementBox<Self> {
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child(
|
.with_child(
|
||||||
Svg::new("icons/disable_screen_sharing_12.svg")
|
Svg::new("icons/disable_screen_sharing_12.svg")
|
||||||
|
|
|
@ -188,7 +188,7 @@ impl View for Sidebar {
|
||||||
"Sidebar"
|
"Sidebar"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||||
if let Some(active_item) = self.active_item() {
|
if let Some(active_item) = self.active_item() {
|
||||||
enum ResizeHandleTag {}
|
enum ResizeHandleTag {}
|
||||||
let style = &cx.global::<Settings>().theme.workspace.sidebar;
|
let style = &cx.global::<Settings>().theme.workspace.sidebar;
|
||||||
|
@ -225,7 +225,7 @@ impl View for SidebarButtons {
|
||||||
"SidebarToggleButton"
|
"SidebarToggleButton"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||||
let theme = &cx.global::<Settings>().theme;
|
let theme = &cx.global::<Settings>().theme;
|
||||||
let tooltip_style = theme.tooltip.clone();
|
let tooltip_style = theme.tooltip.clone();
|
||||||
let theme = &theme.workspace.status_bar.sidebar_buttons;
|
let theme = &theme.workspace.status_bar.sidebar_buttons;
|
||||||
|
|
|
@ -8,8 +8,8 @@ use gpui::{
|
||||||
vector::{vec2f, Vector2F},
|
vector::{vec2f, Vector2F},
|
||||||
},
|
},
|
||||||
json::{json, ToJson},
|
json::{json, ToJson},
|
||||||
AnyViewHandle, AppContext, DebugContext, ElementBox, Entity, LayoutContext, MeasurementContext,
|
AnyViewHandle, AppContext, ElementBox, Entity, SceneBuilder, SizeConstraint, Subscription,
|
||||||
PaintContext, SceneBuilder, SizeConstraint, Subscription, View, ViewContext, ViewHandle,
|
View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ impl View for StatusBar {
|
||||||
"StatusBar"
|
"StatusBar"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||||
let theme = &cx.global::<Settings>().theme.workspace.status_bar;
|
let theme = &cx.global::<Settings>().theme.workspace.status_bar;
|
||||||
|
|
||||||
StatusBarElement {
|
StatusBarElement {
|
||||||
|
@ -139,19 +139,19 @@ impl From<&dyn StatusItemViewHandle> for AnyViewHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StatusBarElement {
|
struct StatusBarElement {
|
||||||
left: ElementBox,
|
left: ElementBox<StatusBar>,
|
||||||
right: ElementBox,
|
right: ElementBox<StatusBar>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V: View> Element<V> for StatusBarElement {
|
impl Element<StatusBar> for StatusBarElement {
|
||||||
type LayoutState = ();
|
type LayoutState = ();
|
||||||
type PaintState = ();
|
type PaintState = ();
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut constraint: SizeConstraint,
|
mut constraint: SizeConstraint,
|
||||||
view: &mut V,
|
view: &mut StatusBar,
|
||||||
cx: &mut ViewContext<V>,
|
cx: &mut ViewContext<StatusBar>,
|
||||||
) -> (Vector2F, Self::LayoutState) {
|
) -> (Vector2F, Self::LayoutState) {
|
||||||
let max_width = constraint.max.x();
|
let max_width = constraint.max.x();
|
||||||
constraint.min = vec2f(0., constraint.min.y());
|
constraint.min = vec2f(0., constraint.min.y());
|
||||||
|
@ -173,8 +173,8 @@ impl<V: View> Element<V> for StatusBarElement {
|
||||||
bounds: RectF,
|
bounds: RectF,
|
||||||
visible_bounds: RectF,
|
visible_bounds: RectF,
|
||||||
_: &mut Self::LayoutState,
|
_: &mut Self::LayoutState,
|
||||||
view: &mut V,
|
view: &mut StatusBar,
|
||||||
cx: &mut ViewContext<V>,
|
cx: &mut ViewContext<StatusBar>,
|
||||||
) -> Self::PaintState {
|
) -> Self::PaintState {
|
||||||
let origin_y = bounds.upper_right().y();
|
let origin_y = bounds.upper_right().y();
|
||||||
let visible_bounds = bounds.intersection(visible_bounds).unwrap_or_default();
|
let visible_bounds = bounds.intersection(visible_bounds).unwrap_or_default();
|
||||||
|
@ -195,7 +195,8 @@ impl<V: View> Element<V> for StatusBarElement {
|
||||||
_: RectF,
|
_: RectF,
|
||||||
_: &Self::LayoutState,
|
_: &Self::LayoutState,
|
||||||
_: &Self::PaintState,
|
_: &Self::PaintState,
|
||||||
_: &MeasurementContext,
|
_: &StatusBar,
|
||||||
|
_: &ViewContext<StatusBar>,
|
||||||
) -> Option<RectF> {
|
) -> Option<RectF> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -205,7 +206,8 @@ impl<V: View> Element<V> for StatusBarElement {
|
||||||
bounds: RectF,
|
bounds: RectF,
|
||||||
_: &Self::LayoutState,
|
_: &Self::LayoutState,
|
||||||
_: &Self::PaintState,
|
_: &Self::PaintState,
|
||||||
_: &DebugContext,
|
_: &StatusBar,
|
||||||
|
_: &ViewContext<StatusBar>,
|
||||||
) -> serde_json::Value {
|
) -> serde_json::Value {
|
||||||
json!({
|
json!({
|
||||||
"type": "StatusBarElement",
|
"type": "StatusBarElement",
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl View for Toolbar {
|
||||||
"Toolbar"
|
"Toolbar"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||||
let theme = &cx.global::<Settings>().theme.workspace.toolbar;
|
let theme = &cx.global::<Settings>().theme.workspace.toolbar;
|
||||||
|
|
||||||
let mut primary_left_items = Vec::new();
|
let mut primary_left_items = Vec::new();
|
||||||
|
@ -169,7 +169,7 @@ fn nav_button<A: Action + Clone>(
|
||||||
tooltip_action: A,
|
tooltip_action: A,
|
||||||
action_name: &str,
|
action_name: &str,
|
||||||
cx: &mut ViewContext<Toolbar>,
|
cx: &mut ViewContext<Toolbar>,
|
||||||
) -> ElementBox {
|
) -> ElementBox<Toolbar> {
|
||||||
MouseEventHandler::<A>::new(0, cx, |state, _| {
|
MouseEventHandler::<A>::new(0, cx, |state, _| {
|
||||||
let style = if enabled {
|
let style = if enabled {
|
||||||
style.style_for(state, false)
|
style.style_for(state, false)
|
||||||
|
|
|
@ -2053,7 +2053,7 @@ impl Workspace {
|
||||||
self.leader_state.followers.contains(&peer_id)
|
self.leader_state.followers.contains(&peer_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_titlebar(&self, theme: &Theme, cx: &mut ViewContext<Self>) -> ElementBox {
|
fn render_titlebar(&self, theme: &Theme, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||||
// TODO: There should be a better system in place for this
|
// TODO: There should be a better system in place for this
|
||||||
// (https://github.com/zed-industries/zed/issues/1290)
|
// (https://github.com/zed-industries/zed/issues/1290)
|
||||||
let is_fullscreen = cx.window_is_fullscreen();
|
let is_fullscreen = cx.window_is_fullscreen();
|
||||||
|
@ -2153,7 +2153,10 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_disconnected_overlay(&self, cx: &mut ViewContext<Workspace>) -> Option<ElementBox> {
|
fn render_disconnected_overlay(
|
||||||
|
&self,
|
||||||
|
cx: &mut ViewContext<Workspace>,
|
||||||
|
) -> Option<ElementBox<Workspace>> {
|
||||||
if self.project.read(cx).is_read_only() {
|
if self.project.read(cx).is_read_only() {
|
||||||
enum DisconnectedOverlay {}
|
enum DisconnectedOverlay {}
|
||||||
Some(
|
Some(
|
||||||
|
@ -2181,7 +2184,7 @@ impl Workspace {
|
||||||
&self,
|
&self,
|
||||||
theme: &theme::Workspace,
|
theme: &theme::Workspace,
|
||||||
cx: &AppContext,
|
cx: &AppContext,
|
||||||
) -> Option<ElementBox> {
|
) -> Option<ElementBox<Workspace>> {
|
||||||
if self.notifications.is_empty() {
|
if self.notifications.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -2809,7 +2812,7 @@ impl View for Workspace {
|
||||||
"Workspace"
|
"Workspace"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
|
||||||
let theme = cx.global::<Settings>().theme.clone();
|
let theme = cx.global::<Settings>().theme.clone();
|
||||||
Stack::new()
|
Stack::new()
|
||||||
.with_child(
|
.with_child(
|
||||||
|
|
Loading…
Reference in a new issue