Take &mut self in View::render
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
917a80ec36
commit
ef89ceae4d
11 changed files with 28 additions and 28 deletions
|
@ -28,7 +28,7 @@ impl gpui::View for TextView {
|
||||||
"View"
|
"View"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, _: &mut gpui::RenderContext<Self>) -> gpui::ElementBox {
|
fn render(&mut self, _: &mut gpui::RenderContext<Self>) -> gpui::ElementBox {
|
||||||
TextElement.boxed()
|
TextElement.boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub trait Entity: 'static {
|
||||||
|
|
||||||
pub trait View: Entity + Sized {
|
pub trait View: Entity + Sized {
|
||||||
fn ui_name() -> &'static str;
|
fn ui_name() -> &'static str;
|
||||||
fn render(&self, cx: &mut RenderContext<'_, Self>) -> ElementBox;
|
fn render(&mut self, cx: &mut RenderContext<'_, Self>) -> ElementBox;
|
||||||
fn on_focus(&mut self, _: &mut ViewContext<Self>) {}
|
fn on_focus(&mut self, _: &mut ViewContext<Self>) {}
|
||||||
fn on_blur(&mut self, _: &mut ViewContext<Self>) {}
|
fn on_blur(&mut self, _: &mut ViewContext<Self>) {}
|
||||||
fn keymap_context(&self, _: &AppContext) -> keymap::Context {
|
fn keymap_context(&self, _: &AppContext) -> keymap::Context {
|
||||||
|
@ -817,7 +817,7 @@ impl MutableAppContext {
|
||||||
titlebar_height: f32,
|
titlebar_height: f32,
|
||||||
refreshing: bool,
|
refreshing: bool,
|
||||||
) -> Result<ElementBox> {
|
) -> Result<ElementBox> {
|
||||||
let view = self
|
let mut view = self
|
||||||
.cx
|
.cx
|
||||||
.views
|
.views
|
||||||
.remove(&(window_id, view_id))
|
.remove(&(window_id, view_id))
|
||||||
|
@ -1863,7 +1863,7 @@ pub trait AnyView {
|
||||||
fn release(&mut self, cx: &mut MutableAppContext);
|
fn release(&mut self, cx: &mut MutableAppContext);
|
||||||
fn ui_name(&self) -> &'static str;
|
fn ui_name(&self) -> &'static str;
|
||||||
fn render<'a>(
|
fn render<'a>(
|
||||||
&self,
|
&mut self,
|
||||||
window_id: usize,
|
window_id: usize,
|
||||||
view_id: usize,
|
view_id: usize,
|
||||||
titlebar_height: f32,
|
titlebar_height: f32,
|
||||||
|
@ -1896,7 +1896,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<'a>(
|
fn render<'a>(
|
||||||
&self,
|
&mut self,
|
||||||
window_id: usize,
|
window_id: usize,
|
||||||
view_id: usize,
|
view_id: usize,
|
||||||
titlebar_height: f32,
|
titlebar_height: f32,
|
||||||
|
@ -3368,7 +3368,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl super::View for View {
|
impl super::View for View {
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3432,7 +3432,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl super::View for View {
|
impl super::View for View {
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
let mouse_down_count = self.mouse_down_count.clone();
|
let mouse_down_count = self.mouse_down_count.clone();
|
||||||
EventHandler::new(Empty::new().boxed())
|
EventHandler::new(Empty::new().boxed())
|
||||||
.on_mouse_down(move |_| {
|
.on_mouse_down(move |_| {
|
||||||
|
@ -3494,7 +3494,7 @@ mod tests {
|
||||||
"View"
|
"View"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3534,7 +3534,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl super::View for View {
|
impl super::View for View {
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3590,7 +3590,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl super::View for View {
|
impl super::View for View {
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3640,7 +3640,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl super::View for View {
|
impl super::View for View {
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3684,7 +3684,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl super::View for View {
|
impl super::View for View {
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3731,7 +3731,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl super::View for View {
|
impl super::View for View {
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3789,7 +3789,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl View for ViewA {
|
impl View for ViewA {
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3807,7 +3807,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl View for ViewB {
|
impl View for ViewB {
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3903,7 +3903,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl super::View for View {
|
impl super::View for View {
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4038,7 +4038,7 @@ mod tests {
|
||||||
"test view"
|
"test view"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4083,7 +4083,7 @@ mod tests {
|
||||||
"test view"
|
"test view"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4106,7 +4106,7 @@ mod tests {
|
||||||
"test view"
|
"test view"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,7 +510,7 @@ mod tests {
|
||||||
"TestView"
|
"TestView"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, _: &mut RenderContext<'_, Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<'_, Self>) -> ElementBox {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1776,7 +1776,7 @@ mod tests {
|
||||||
"empty view"
|
"empty view"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, _: &mut gpui::RenderContext<Self>) -> gpui::ElementBox {
|
fn render(&mut self, _: &mut gpui::RenderContext<Self>) -> gpui::ElementBox {
|
||||||
gpui::Element::boxed(gpui::elements::Empty)
|
gpui::Element::boxed(gpui::elements::Empty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,7 @@ impl View for ChatPanel {
|
||||||
"ChatPanel"
|
"ChatPanel"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, cx: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
||||||
let theme = &self.settings.borrow().theme;
|
let theme = &self.settings.borrow().theme;
|
||||||
Container::new(
|
Container::new(
|
||||||
Flex::column()
|
Flex::column()
|
||||||
|
|
|
@ -2522,7 +2522,7 @@ impl Entity for Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl View for Editor {
|
impl View for Editor {
|
||||||
fn render<'a>(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
EditorElement::new(self.handle.clone()).boxed()
|
EditorElement::new(self.handle.clone()).boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ impl View for FileFinder {
|
||||||
"FileFinder"
|
"FileFinder"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
let settings = self.settings.borrow();
|
let settings = self.settings.borrow();
|
||||||
|
|
||||||
Align::new(
|
Align::new(
|
||||||
|
|
|
@ -13,7 +13,7 @@ impl View for ProjectBrowser {
|
||||||
"ProjectBrowser"
|
"ProjectBrowser"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, _: &mut gpui::RenderContext<'_, Self>) -> gpui::ElementBox {
|
fn render(&mut self, _: &mut gpui::RenderContext<'_, Self>) -> gpui::ElementBox {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ impl View for ThemeSelector {
|
||||||
"ThemeSelector"
|
"ThemeSelector"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, cx: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
||||||
let settings = self.settings.borrow();
|
let settings = self.settings.borrow();
|
||||||
|
|
||||||
Align::new(
|
Align::new(
|
||||||
|
|
|
@ -944,7 +944,7 @@ impl View for Workspace {
|
||||||
"Workspace"
|
"Workspace"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, cx: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
||||||
let settings = self.settings.borrow();
|
let settings = self.settings.borrow();
|
||||||
Container::new(
|
Container::new(
|
||||||
Flex::column()
|
Flex::column()
|
||||||
|
|
|
@ -369,7 +369,7 @@ impl View for Pane {
|
||||||
"Pane"
|
"Pane"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&self, cx: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
||||||
if let Some(active_item) = self.active_item() {
|
if let Some(active_item) = self.active_item() {
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_child(self.render_tabs(cx))
|
.with_child(self.render_tabs(cx))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue