Rename back to div

This commit is contained in:
Nathan Sobo
2023-11-14 01:41:55 -07:00
parent be18c47912
commit c6e8a097a3
62 changed files with 154 additions and 156 deletions
@@ -538,37 +538,37 @@ pub type KeyUpListener<V> =
pub type ActionListener<V> =
Box<dyn Fn(&mut V, &dyn Any, DispatchPhase, &mut ViewContext<V>) + 'static>;
pub fn div<V: 'static>() -> Node<V> {
Node {
pub fn div<V: 'static>() -> Div<V> {
Div {
interactivity: Interactivity::default(),
children: SmallVec::default(),
}
}
pub struct Node<V> {
pub struct Div<V> {
interactivity: Interactivity<V>,
children: SmallVec<[AnyElement<V>; 2]>,
}
impl<V> Styled for Node<V> {
impl<V> Styled for Div<V> {
fn style(&mut self) -> &mut StyleRefinement {
&mut self.interactivity.base_style
}
}
impl<V: 'static> InteractiveComponent<V> for Node<V> {
impl<V: 'static> InteractiveComponent<V> for Div<V> {
fn interactivity(&mut self) -> &mut Interactivity<V> {
&mut self.interactivity
}
}
impl<V: 'static> ParentComponent<V> for Node<V> {
impl<V: 'static> ParentComponent<V> for Div<V> {
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]> {
&mut self.children
}
}
impl<V: 'static> Element<V> for Node<V> {
impl<V: 'static> Element<V> for Div<V> {
type ElementState = NodeState;
fn element_id(&self) -> Option<ElementId> {
@@ -671,7 +671,7 @@ impl<V: 'static> Element<V> for Node<V> {
}
}
impl<V: 'static> Component<V> for Node<V> {
impl<V: 'static> Component<V> for Div<V> {
fn render(self) -> AnyElement<V> {
AnyElement::new(self)
}
@@ -1,13 +1,11 @@
// mod div;
mod div;
mod img;
mod node;
mod svg;
mod text;
mod uniform_list;
// pub use div::*;
pub use div::*;
pub use img::*;
pub use node::*;
pub use svg::*;
pub use text::*;
pub use uniform_list::*;
+4 -4
View File
@@ -1,5 +1,5 @@
use crate::{
div, point, Component, FocusHandle, Keystroke, Modifiers, Node, Pixels, Point, Render,
div, point, Component, FocusHandle, Keystroke, Modifiers, Div, Pixels, Point, Render,
ViewContext,
};
use smallvec::SmallVec;
@@ -194,7 +194,7 @@ impl Deref for MouseExitEvent {
pub struct ExternalPaths(pub(crate) SmallVec<[PathBuf; 2]>);
impl Render for ExternalPaths {
type Element = Node<Self>;
type Element = Div<Self>;
fn render(&mut self, _: &mut ViewContext<Self>) -> Self::Element {
div() // Intentionally left empty because the platform will render icons for the dragged files
@@ -286,7 +286,7 @@ pub struct FocusEvent {
#[cfg(test)]
mod test {
use crate::{
self as gpui, div, FocusHandle, InteractiveComponent, KeyBinding, Keystroke, Node,
self as gpui, div, FocusHandle, InteractiveComponent, KeyBinding, Keystroke, Div,
ParentComponent, Render, Stateful, TestAppContext, VisualContext,
};
@@ -299,7 +299,7 @@ mod test {
actions!(TestAction);
impl Render for TestView {
type Element = Stateful<Self, Node<Self>>;
type Element = Stateful<Self, Div<Self>>;
fn render(&mut self, _: &mut gpui::ViewContext<Self>) -> Self::Element {
div().id("testview").child(