Refine naming of element-related types and traits
Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
parent
03619dfa55
commit
fe492eacbf
93 changed files with 661 additions and 656 deletions
|
@ -41,7 +41,7 @@ pub use test_app_context::{ContextHandle, TestAppContext};
|
|||
use window_input_handler::WindowInputHandler;
|
||||
|
||||
use crate::{
|
||||
elements::{AnyRootElement, Element, RootElement},
|
||||
elements::{AnyElement, AnyRootElement, RootElement},
|
||||
executor::{self, Task},
|
||||
keymap_matcher::{self, Binding, KeymapContext, KeymapMatcher, Keystroke, MatchResult},
|
||||
platform::{
|
||||
|
@ -69,7 +69,7 @@ pub trait Entity: 'static {
|
|||
|
||||
pub trait View: Entity + Sized {
|
||||
fn ui_name() -> &'static str;
|
||||
fn render(&mut self, cx: &mut ViewContext<'_, '_, '_, Self>) -> Element<Self>;
|
||||
fn render(&mut self, cx: &mut ViewContext<'_, '_, '_, Self>) -> AnyElement<Self>;
|
||||
fn focus_in(&mut self, _: AnyViewHandle, _: &mut ViewContext<Self>) {}
|
||||
fn focus_out(&mut self, _: AnyViewHandle, _: &mut ViewContext<Self>) {}
|
||||
fn key_down(&mut self, _: &KeyDownEvent, _: &mut ViewContext<Self>) -> bool {
|
||||
|
@ -4683,9 +4683,9 @@ mod tests {
|
|||
}
|
||||
|
||||
impl super::View for View {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
post_inc(&mut self.render_count);
|
||||
Empty::new().into_element()
|
||||
Empty::new().into_any()
|
||||
}
|
||||
|
||||
fn ui_name() -> &'static str {
|
||||
|
@ -4736,8 +4736,8 @@ mod tests {
|
|||
}
|
||||
|
||||
impl super::View for View {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
|
||||
fn ui_name() -> &'static str {
|
||||
|
@ -4806,14 +4806,14 @@ mod tests {
|
|||
}
|
||||
|
||||
impl super::View for View {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
enum Handler {}
|
||||
let mouse_down_count = self.mouse_down_count.clone();
|
||||
MouseEventHandler::<Handler, _>::new(0, cx, |_, _| Empty::new())
|
||||
.on_down(MouseButton::Left, move |_, _, _| {
|
||||
mouse_down_count.fetch_add(1, SeqCst);
|
||||
})
|
||||
.into_element()
|
||||
.into_any()
|
||||
}
|
||||
|
||||
fn ui_name() -> &'static str {
|
||||
|
@ -4872,8 +4872,8 @@ mod tests {
|
|||
"View"
|
||||
}
|
||||
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5390,8 +5390,8 @@ mod tests {
|
|||
}
|
||||
|
||||
impl super::View for View {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
|
||||
fn ui_name() -> &'static str {
|
||||
|
@ -5457,8 +5457,8 @@ mod tests {
|
|||
}
|
||||
|
||||
impl super::View for View {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
|
||||
fn ui_name() -> &'static str {
|
||||
|
@ -5638,8 +5638,8 @@ mod tests {
|
|||
}
|
||||
|
||||
impl View for ViewA {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
|
||||
fn ui_name() -> &'static str {
|
||||
|
@ -5656,8 +5656,8 @@ mod tests {
|
|||
}
|
||||
|
||||
impl View for ViewB {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
|
||||
fn ui_name() -> &'static str {
|
||||
|
@ -5804,8 +5804,8 @@ mod tests {
|
|||
}
|
||||
|
||||
impl super::View for View {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
|
||||
fn ui_name() -> &'static str {
|
||||
|
@ -5931,16 +5931,16 @@ mod tests {
|
|||
}
|
||||
|
||||
impl super::View for View1 {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
fn ui_name() -> &'static str {
|
||||
"View1"
|
||||
}
|
||||
}
|
||||
impl super::View for View2 {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
fn ui_name() -> &'static str {
|
||||
"View2"
|
||||
|
@ -6109,8 +6109,8 @@ mod tests {
|
|||
"test view"
|
||||
}
|
||||
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6171,8 +6171,8 @@ mod tests {
|
|||
"test view"
|
||||
}
|
||||
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_named_element(format!("render count: {}", post_inc(&mut self.0)))
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any_named(format!("render count: {}", post_inc(&mut self.0)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6260,8 +6260,8 @@ mod tests {
|
|||
"test view"
|
||||
}
|
||||
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6340,9 +6340,9 @@ mod tests {
|
|||
"child view"
|
||||
}
|
||||
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
self.rendered.set(true);
|
||||
Empty::new().into_element()
|
||||
Empty::new().into_any()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6365,11 +6365,11 @@ mod tests {
|
|||
"parent view"
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
if let Some(child) = self.child.as_ref() {
|
||||
ChildView::new(child, cx).into_element()
|
||||
ChildView::new(child, cx).into_any()
|
||||
} else {
|
||||
Empty::new().into_element()
|
||||
Empty::new().into_any()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6407,8 +6407,8 @@ mod tests {
|
|||
"TestView"
|
||||
}
|
||||
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
|
||||
Empty::new().into_element()
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
Empty::new().into_any()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue