Revert changes to gpui2 crate

This commit is contained in:
Marshall Bowers 2023-10-06 15:49:53 -04:00
parent d37785c214
commit 88a6a41c7c
5 changed files with 4 additions and 61 deletions

View file

@ -160,15 +160,6 @@ pub fn black() -> Hsla {
} }
} }
pub fn white() -> Hsla {
Hsla {
h: 0.,
s: 0.,
l: 1.,
a: 1.,
}
}
impl From<Rgba> for Hsla { impl From<Rgba> for Hsla {
fn from(color: Rgba) -> Self { fn from(color: Rgba) -> Self {
let r = color.r; let r = color.r;

View file

@ -12,21 +12,11 @@ use parking_lot::Mutex;
use std::sync::Arc; use std::sync::Arc;
use util::arc_cow::ArcCow; use util::arc_cow::ArcCow;
impl<V: 'static> IntoElement<V> for ArcCow<'static, str> { impl<V: 'static, S: Into<ArcCow<'static, str>>> IntoElement<V> for S {
type Element = Text; type Element = Text;
fn into_element(self) -> Self::Element { fn into_element(self) -> Self::Element {
Text { text: self } Text { text: self.into() }
}
}
impl<V: 'static> IntoElement<V> for &'static str {
type Element = Text;
fn into_element(self) -> Self::Element {
Text {
text: ArcCow::from(self),
}
} }
} }

View file

@ -6,7 +6,6 @@ pub mod interactive;
pub mod style; pub mod style;
pub mod view; pub mod view;
pub mod view_context; pub mod view_context;
pub mod view_handle;
pub use color::*; pub use color::*;
pub use element::{AnyElement, Element, IntoElement, Layout, ParentElement}; pub use element::{AnyElement, Element, IntoElement, Layout, ParentElement};

View file

@ -22,8 +22,6 @@ use gpui2_macros::styleable_helpers;
use refineable::{Refineable, RefinementCascade}; use refineable::{Refineable, RefinementCascade};
use std::sync::Arc; use std::sync::Arc;
pub type StyleCascade = RefinementCascade<Style>;
#[derive(Clone, Refineable, Debug)] #[derive(Clone, Refineable, Debug)]
#[refineable(debug)] #[refineable(debug)]
pub struct Style { pub struct Style {
@ -131,7 +129,7 @@ impl Style {
color: self.text_color.map(Into::into), color: self.text_color.map(Into::into),
font_family: self.font_family.clone(), font_family: self.font_family.clone(),
font_size: self.font_size.map(|size| size * cx.rem_size()), font_size: self.font_size.map(|size| size * cx.rem_size()),
font_weight: self.font_weight.map(Into::into), font_weight: self.font_weight,
font_style: self.font_style, font_style: self.font_style,
underline: None, underline: None,
}) })

View file

@ -3,10 +3,7 @@ use std::{any::TypeId, rc::Rc};
use crate::{element::LayoutId, style::Style}; use crate::{element::LayoutId, style::Style};
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use derive_more::{Deref, DerefMut}; use derive_more::{Deref, DerefMut};
use gpui::{ use gpui::{geometry::Size, scene::EventHandler, EventContext, Layout, MeasureParams};
geometry::Size, scene::EventHandler, AnyWindowHandle, BorrowWindowContext, EventContext,
Layout, MeasureParams, WindowContext,
};
pub use gpui::{taffy::tree::NodeId, ViewContext as LegacyViewContext}; pub use gpui::{taffy::tree::NodeId, ViewContext as LegacyViewContext};
#[derive(Deref, DerefMut)] #[derive(Deref, DerefMut)]
@ -80,35 +77,3 @@ impl<'a, 'b, 'c, V: 'static> ViewContext<'a, 'b, 'c, V> {
.computed_layout(layout_id) .computed_layout(layout_id)
} }
} }
impl<'a, 'b, 'c, V: 'static> BorrowWindowContext for ViewContext<'a, 'b, 'c, V> {
type Result<T> = T;
fn read_window<T, F>(&self, window: AnyWindowHandle, f: F) -> Self::Result<T>
where
F: FnOnce(&WindowContext) -> T,
{
self.legacy_cx.read_window(window, f)
}
fn read_window_optional<T, F>(&self, window: AnyWindowHandle, f: F) -> Option<T>
where
F: FnOnce(&WindowContext) -> Option<T>,
{
self.legacy_cx.read_window_optional(window, f)
}
fn update_window<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Self::Result<T>
where
F: FnOnce(&mut WindowContext) -> T,
{
self.legacy_cx.update_window(window, f)
}
fn update_window_optional<T, F>(&mut self, window: AnyWindowHandle, f: F) -> Option<T>
where
F: FnOnce(&mut WindowContext) -> Option<T>,
{
self.legacy_cx.update_window_optional(window, f)
}
}