Merge branch 'main' into collab_ui-zed2

This commit is contained in:
Piotr Osiewicz 2023-11-23 15:02:55 +01:00
commit 390ecb5b0c
51 changed files with 339 additions and 323 deletions

View file

@ -1,9 +1,9 @@
use crate::{
point, px, Action, AnyDrag, AnyElement, AnyTooltip, AnyView, AppContext, BorrowAppContext,
BorrowWindow, Bounds, ClickEvent, DispatchPhase, Element, ElementId, FocusEvent, FocusHandle,
KeyContext, KeyDownEvent, KeyUpEvent, LayoutId, MouseButton, MouseDownEvent, MouseMoveEvent,
MouseUpEvent, ParentElement, Pixels, Point, Render, RenderOnce, ScrollWheelEvent, SharedString,
Size, Style, StyleRefinement, Styled, Task, View, Visibility, WindowContext,
IntoElement, KeyContext, KeyDownEvent, KeyUpEvent, LayoutId, MouseButton, MouseDownEvent,
MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point, Render, ScrollWheelEvent,
SharedString, Size, Style, StyleRefinement, Styled, Task, View, Visibility, WindowContext,
};
use collections::HashMap;
use refineable::Refineable;
@ -666,14 +666,14 @@ impl Element for Div {
}
}
impl RenderOnce for Div {
impl IntoElement for Div {
type Element = Self;
fn element_id(&self) -> Option<ElementId> {
self.interactivity.element_id.clone()
}
fn render_once(self) -> Self::Element {
fn into_element(self) -> Self::Element {
self
}
}
@ -1278,7 +1278,7 @@ where
}
}
impl<E> RenderOnce for Focusable<E>
impl<E> IntoElement for Focusable<E>
where
E: Element,
{
@ -1288,7 +1288,7 @@ where
self.element.element_id()
}
fn render_once(self) -> Self::Element {
fn into_element(self) -> Self::Element {
self.element
}
}
@ -1352,7 +1352,7 @@ where
}
}
impl<E> RenderOnce for Stateful<E>
impl<E> IntoElement for Stateful<E>
where
E: Element,
{
@ -1362,7 +1362,7 @@ where
self.element.element_id()
}
fn render_once(self) -> Self::Element {
fn into_element(self) -> Self::Element {
self
}
}

View file

@ -2,7 +2,7 @@ use std::sync::Arc;
use crate::{
Bounds, Element, ImageData, InteractiveElement, InteractiveElementState, Interactivity,
LayoutId, Pixels, RenderOnce, SharedString, StyleRefinement, Styled, WindowContext,
IntoElement, LayoutId, Pixels, SharedString, StyleRefinement, Styled, WindowContext,
};
use futures::FutureExt;
use util::ResultExt;
@ -120,14 +120,14 @@ impl Element for Img {
}
}
impl RenderOnce for Img {
impl IntoElement for Img {
type Element = Self;
fn element_id(&self) -> Option<crate::ElementId> {
self.interactivity.element_id.clone()
}
fn render_once(self) -> Self::Element {
fn into_element(self) -> Self::Element {
self
}
}

View file

@ -2,8 +2,8 @@ use smallvec::SmallVec;
use taffy::style::{Display, Position};
use crate::{
point, AnyElement, BorrowWindow, Bounds, Element, LayoutId, ParentElement, Pixels, Point,
RenderOnce, Size, Style, WindowContext,
point, AnyElement, BorrowWindow, Bounds, Element, IntoElement, LayoutId, ParentElement, Pixels,
Point, Size, Style, WindowContext,
};
pub struct OverlayState {
@ -151,14 +151,14 @@ impl Element for Overlay {
}
}
impl RenderOnce for Overlay {
impl IntoElement for Overlay {
type Element = Self;
fn element_id(&self) -> Option<crate::ElementId> {
None
}
fn render_once(self) -> Self::Element {
fn into_element(self) -> Self::Element {
self
}
}

View file

@ -1,6 +1,6 @@
use crate::{
Bounds, Element, ElementId, InteractiveElement, InteractiveElementState, Interactivity,
LayoutId, Pixels, RenderOnce, SharedString, StyleRefinement, Styled, WindowContext,
IntoElement, LayoutId, Pixels, SharedString, StyleRefinement, Styled, WindowContext,
};
use util::ResultExt;
@ -49,14 +49,14 @@ impl Element for Svg {
}
}
impl RenderOnce for Svg {
impl IntoElement for Svg {
type Element = Self;
fn element_id(&self) -> Option<ElementId> {
self.interactivity.element_id.clone()
}
fn render_once(self) -> Self::Element {
fn into_element(self) -> Self::Element {
self
}
}

View file

@ -1,5 +1,5 @@
use crate::{
Bounds, Element, ElementId, LayoutId, Pixels, RenderOnce, SharedString, Size, TextRun,
Bounds, Element, ElementId, IntoElement, LayoutId, Pixels, SharedString, Size, TextRun,
WhiteSpace, WindowContext, WrappedLine,
};
use anyhow::anyhow;
@ -26,14 +26,14 @@ impl Element for &'static str {
}
}
impl RenderOnce for &'static str {
impl IntoElement for &'static str {
type Element = Self;
fn element_id(&self) -> Option<ElementId> {
None
}
fn render_once(self) -> Self::Element {
fn into_element(self) -> Self::Element {
self
}
}
@ -57,14 +57,14 @@ impl Element for SharedString {
}
}
impl RenderOnce for SharedString {
impl IntoElement for SharedString {
type Element = Self;
fn element_id(&self) -> Option<ElementId> {
None
}
fn render_once(self) -> Self::Element {
fn into_element(self) -> Self::Element {
self
}
}
@ -106,14 +106,14 @@ impl Element for StyledText {
}
}
impl RenderOnce for StyledText {
impl IntoElement for StyledText {
type Element = Self;
fn element_id(&self) -> Option<crate::ElementId> {
None
}
fn render_once(self) -> Self::Element {
fn into_element(self) -> Self::Element {
self
}
}
@ -272,14 +272,14 @@ impl Element for InteractiveText {
}
}
impl RenderOnce for InteractiveText {
impl IntoElement for InteractiveText {
type Element = Self;
fn element_id(&self) -> Option<ElementId> {
Some(self.element_id.clone())
}
fn render_once(self) -> Self::Element {
fn into_element(self) -> Self::Element {
self
}
}

View file

@ -1,7 +1,7 @@
use crate::{
point, px, size, AnyElement, AvailableSpace, BorrowWindow, Bounds, ContentMask, Element,
ElementId, InteractiveElement, InteractiveElementState, Interactivity, LayoutId, Pixels, Point,
Render, RenderOnce, Size, StyleRefinement, Styled, View, ViewContext, WindowContext,
ElementId, InteractiveElement, InteractiveElementState, Interactivity, IntoElement, LayoutId,
Pixels, Point, Render, Size, StyleRefinement, Styled, View, ViewContext, WindowContext,
};
use smallvec::SmallVec;
use std::{cell::RefCell, cmp, ops::Range, rc::Rc};
@ -18,7 +18,7 @@ pub fn uniform_list<I, R, V>(
) -> UniformList
where
I: Into<ElementId>,
R: RenderOnce,
R: IntoElement,
V: Render,
{
let id = id.into();
@ -29,7 +29,7 @@ where
view.update(cx, |this, cx| {
f(this, range, cx)
.into_iter()
.map(|component| component.render_into_any())
.map(|component| component.into_any_element())
.collect()
})
};
@ -243,14 +243,14 @@ impl Element for UniformList {
}
}
impl RenderOnce for UniformList {
impl IntoElement for UniformList {
type Element = Self;
fn element_id(&self) -> Option<crate::ElementId> {
Some(self.id.clone())
}
fn render_once(self) -> Self::Element {
fn into_element(self) -> Self::Element {
self
}
}