Revert changes to `gpui2` crate

Marshall Bowers created

Change summary

crates/gpui2/src/color.rs         |  9 --------
crates/gpui2/src/elements/text.rs | 14 +----------
crates/gpui2/src/gpui2.rs         |  1 
crates/gpui2/src/style.rs         |  4 --
crates/gpui2/src/view_context.rs  | 37 --------------------------------
5 files changed, 4 insertions(+), 61 deletions(-)

Detailed changes

crates/gpui2/src/color.rs 🔗

@@ -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 {
     fn from(color: Rgba) -> Self {
         let r = color.r;

crates/gpui2/src/elements/text.rs 🔗

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

crates/gpui2/src/gpui2.rs 🔗

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

crates/gpui2/src/style.rs 🔗

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

crates/gpui2/src/view_context.rs 🔗

@@ -3,10 +3,7 @@ use std::{any::TypeId, rc::Rc};
 use crate::{element::LayoutId, style::Style};
 use anyhow::{anyhow, Result};
 use derive_more::{Deref, DerefMut};
-use gpui::{
-    geometry::Size, scene::EventHandler, AnyWindowHandle, BorrowWindowContext, EventContext,
-    Layout, MeasureParams, WindowContext,
-};
+use gpui::{geometry::Size, scene::EventHandler, EventContext, Layout, MeasureParams};
 pub use gpui::{taffy::tree::NodeId, ViewContext as LegacyViewContext};
 
 #[derive(Deref, DerefMut)]
@@ -80,35 +77,3 @@ impl<'a, 'b, 'c, V: 'static> ViewContext<'a, 'b, 'c, V> {
             .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)
-    }
-}