Add group hovers

This commit is contained in:
Nathan Sobo 2023-10-11 21:34:08 -06:00
parent f37b83a0ea
commit d920f7edc1
21 changed files with 157 additions and 103 deletions

View file

@ -13,12 +13,12 @@ use gpui::{
scene::{self}, scene::{self},
LayoutId, LayoutId,
}; };
use refineable::{Refineable, RefinementCascade}; use refineable::{Cascade, Refineable};
use smallvec::SmallVec; use smallvec::SmallVec;
use util::ResultExt; use util::ResultExt;
pub struct Div<V: 'static> { pub struct Div<V: 'static> {
styles: RefinementCascade<Style>, styles: Cascade<Style>,
handlers: InteractionHandlers<V>, handlers: InteractionHandlers<V>,
children: SmallVec<[AnyElement<V>; 2]>, children: SmallVec<[AnyElement<V>; 2]>,
scroll_state: Option<ScrollState>, scroll_state: Option<ScrollState>,
@ -263,7 +263,7 @@ impl<V: 'static> Div<V> {
impl<V> Styleable for Div<V> { impl<V> Styleable for Div<V> {
type Style = Style; type Style = Style;
fn style_cascade(&mut self) -> &mut RefinementCascade<Self::Style> { fn style_cascade(&mut self) -> &mut Cascade<Self::Style> {
&mut self.styles &mut self.styles
} }

View file

@ -6,7 +6,7 @@ use crate::{
}; };
use anyhow::Result; use anyhow::Result;
use gpui::{geometry::vector::Vector2F, platform::MouseMovedEvent, LayoutId}; use gpui::{geometry::vector::Vector2F, platform::MouseMovedEvent, LayoutId};
use refineable::{CascadeSlot, Refineable, RefinementCascade}; use refineable::{Cascade, CascadeSlot, Refineable};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{cell::Cell, rc::Rc}; use std::{cell::Cell, rc::Rc};
@ -29,7 +29,7 @@ pub fn hoverable<E: Styleable>(mut child: E) -> Hoverable<E> {
impl<E: Styleable> Styleable for Hoverable<E> { impl<E: Styleable> Styleable for Hoverable<E> {
type Style = E::Style; type Style = E::Style;
fn style_cascade(&mut self) -> &mut RefinementCascade<Self::Style> { fn style_cascade(&mut self) -> &mut Cascade<Self::Style> {
self.child.style_cascade() self.child.style_cascade()
} }

View file

@ -7,19 +7,19 @@ use futures::FutureExt;
use gpui::geometry::vector::Vector2F; use gpui::geometry::vector::Vector2F;
use gpui::scene; use gpui::scene;
use gpui2_macros::IntoElement; use gpui2_macros::IntoElement;
use refineable::RefinementCascade; use refineable::Cascade;
use util::arc_cow::ArcCow; use util::arc_cow::ArcCow;
use util::ResultExt; use util::ResultExt;
#[derive(IntoElement)] #[derive(IntoElement)]
pub struct Img { pub struct Img {
style: RefinementCascade<Style>, style: Cascade<Style>,
uri: Option<ArcCow<'static, str>>, uri: Option<ArcCow<'static, str>>,
} }
pub fn img() -> Img { pub fn img() -> Img {
Img { Img {
style: RefinementCascade::default(), style: Cascade::default(),
uri: None, uri: None,
} }
} }
@ -98,7 +98,7 @@ impl<V: 'static> Element<V> for Img {
impl Styleable for Img { impl Styleable for Img {
type Style = Style; type Style = Style;
fn style_cascade(&mut self) -> &mut RefinementCascade<Self::Style> { fn style_cascade(&mut self) -> &mut Cascade<Self::Style> {
&mut self.style &mut self.style
} }

View file

@ -6,7 +6,7 @@ use crate::{
}; };
use anyhow::Result; use anyhow::Result;
use gpui::{geometry::vector::Vector2F, platform::MouseButtonEvent, LayoutId}; use gpui::{geometry::vector::Vector2F, platform::MouseButtonEvent, LayoutId};
use refineable::{CascadeSlot, Refineable, RefinementCascade}; use refineable::{Cascade, CascadeSlot, Refineable};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{cell::Cell, rc::Rc}; use std::{cell::Cell, rc::Rc};
@ -33,7 +33,7 @@ impl<E: Styleable> Styleable for Pressable<E> {
&mut self.pressed_style &mut self.pressed_style
} }
fn style_cascade(&mut self) -> &mut RefinementCascade<E::Style> { fn style_cascade(&mut self) -> &mut Cascade<E::Style> {
self.child.style_cascade() self.child.style_cascade()
} }
} }

View file

@ -4,20 +4,20 @@ use crate::{
Element, IntoElement, Layout, LayoutId, Rgba, Element, IntoElement, Layout, LayoutId, Rgba,
}; };
use gpui::geometry::vector::Vector2F; use gpui::geometry::vector::Vector2F;
use refineable::RefinementCascade; use refineable::Cascade;
use std::borrow::Cow; use std::borrow::Cow;
use util::ResultExt; use util::ResultExt;
#[derive(IntoElement)] #[derive(IntoElement)]
pub struct Svg { pub struct Svg {
path: Option<Cow<'static, str>>, path: Option<Cow<'static, str>>,
style: RefinementCascade<Style>, style: Cascade<Style>,
} }
pub fn svg() -> Svg { pub fn svg() -> Svg {
Svg { Svg {
path: None, path: None,
style: RefinementCascade::<Style>::default(), style: Cascade::<Style>::default(),
} }
} }
@ -72,7 +72,7 @@ impl<V: 'static> Element<V> for Svg {
impl Styleable for Svg { impl Styleable for Svg {
type Style = Style; type Style = Style;
fn style_cascade(&mut self) -> &mut refineable::RefinementCascade<Self::Style> { fn style_cascade(&mut self) -> &mut refineable::Cascade<Self::Style> {
&mut self.style &mut self.style
} }

View file

@ -19,7 +19,7 @@ use gpui::{
scene, taffy, WindowContext, scene, taffy, WindowContext,
}; };
use gpui2_macros::styleable_helpers; use gpui2_macros::styleable_helpers;
use refineable::{Refineable, RefinementCascade}; use refineable::{Cascade, Refineable};
use std::sync::Arc; use std::sync::Arc;
#[derive(Clone, Refineable, Debug)] #[derive(Clone, Refineable, Debug)]
@ -292,7 +292,7 @@ impl CornerRadii {
pub trait Styleable { pub trait Styleable {
type Style: Refineable + Default; type Style: Refineable + Default;
fn style_cascade(&mut self) -> &mut RefinementCascade<Self::Style>; fn style_cascade(&mut self) -> &mut Cascade<Self::Style>;
fn declared_style(&mut self) -> &mut <Self::Style as Refineable>::Refinement; fn declared_style(&mut self) -> &mut <Self::Style as Refineable>::Refinement;
fn computed_style(&mut self) -> Self::Style { fn computed_style(&mut self) -> Self::Style {

View file

@ -1,8 +1,8 @@
use std::sync::Arc; use std::sync::Arc;
use crate::{ use crate::{
BorrowWindow, Bounds, Clickable, ElementGroup, ElementId, LayoutId, MouseDownEvent, BorrowWindow, Bounds, Clickable, ElementId, Group, LayoutId, MouseDownEvent, MouseUpEvent,
MouseUpEvent, Pixels, Point, SharedString, ViewContext, Pixels, Point, SharedString, ViewContext,
}; };
use derive_more::{Deref, DerefMut}; use derive_more::{Deref, DerefMut};
pub(crate) use smallvec::SmallVec; pub(crate) use smallvec::SmallVec;
@ -28,11 +28,11 @@ pub trait Element: 'static + Send + Sync {
cx: &mut ViewContext<Self::ViewState>, cx: &mut ViewContext<Self::ViewState>,
); );
fn group(self, name: impl Into<SharedString>) -> ElementGroup<Self> fn group(self, name: impl Into<SharedString>) -> Group<Self>
where where
Self: Sized, Self: Sized,
{ {
ElementGroup::new(name.into(), self) Group::new(name.into(), self)
} }
} }

View file

@ -3,7 +3,7 @@ use crate::{
MouseEventListeners, MouseUpEvent, ParentElement, Pixels, Styled, ViewContext, MouseEventListeners, MouseUpEvent, ParentElement, Pixels, Styled, ViewContext,
}; };
use parking_lot::Mutex; use parking_lot::Mutex;
use refineable::RefinementCascade; use refineable::Cascade;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::sync::Arc; use std::sync::Arc;
@ -32,7 +32,7 @@ where
{ {
type Style = E::Style; type Style = E::Style;
fn style_cascade(&mut self) -> &mut RefinementCascade<E::Style> { fn style_cascade(&mut self) -> &mut Cascade<E::Style> {
self.child.style_cascade() self.child.style_cascade()
} }

View file

@ -1,7 +1,7 @@
use crate::{ use crate::{
AnyElement, BorrowWindow, Bounds, Element, ElementId, IdentifiedElement, Interactive, LayoutId, AnyElement, BorrowWindow, Bounds, Cascade, Element, ElementId, IdentifiedElement, Interactive,
MouseEventListeners, Overflow, ParentElement, Pixels, Point, Refineable, RefinementCascade, LayoutId, MouseEventListeners, Overflow, ParentElement, Pixels, Point, Refineable, Style,
Style, Styled, ViewContext, Styled, ViewContext,
}; };
use parking_lot::Mutex; use parking_lot::Mutex;
use smallvec::SmallVec; use smallvec::SmallVec;
@ -10,7 +10,7 @@ use std::{marker::PhantomData, sync::Arc};
pub enum HasId {} pub enum HasId {}
pub struct Div<S: 'static, I = ()> { pub struct Div<S: 'static, I = ()> {
styles: RefinementCascade<Style>, styles: Cascade<Style>,
id: Option<ElementId>, id: Option<ElementId>,
listeners: MouseEventListeners<S>, listeners: MouseEventListeners<S>,
children: SmallVec<[AnyElement<S>; 2]>, children: SmallVec<[AnyElement<S>; 2]>,
@ -179,7 +179,7 @@ where
impl<V: 'static + Send + Sync, Marker: 'static + Send + Sync> Styled for Div<V, Marker> { impl<V: 'static + Send + Sync, Marker: 'static + Send + Sync> Styled for Div<V, Marker> {
type Style = Style; type Style = Style;
fn style_cascade(&mut self) -> &mut RefinementCascade<Self::Style> { fn style_cascade(&mut self) -> &mut Cascade<Self::Style> {
&mut self.styles &mut self.styles
} }

View file

@ -1,8 +1,9 @@
use crate::{ use crate::{
AnyElement, AppContext, Bounds, Element, ElementId, IdentifiedElement, ParentElement, Pixels, AnyElement, AppContext, Bounds, Element, ElementId, IdentifiedElement, Interactive,
SharedString, ViewContext, MouseEventListeners, ParentElement, Pixels, SharedString, Styled, ViewContext,
}; };
use collections::HashMap; use collections::HashMap;
use refineable::Cascade;
use smallvec::SmallVec; use smallvec::SmallVec;
#[derive(Default)] #[derive(Default)]
@ -15,18 +16,18 @@ pub fn element_group_bounds(name: &SharedString, cx: &mut AppContext) -> Option<
.and_then(|bounds_stack| bounds_stack.last().cloned()) .and_then(|bounds_stack| bounds_stack.last().cloned())
} }
pub struct ElementGroup<E> { pub struct Group<E> {
name: SharedString, name: SharedString,
child: E, child: E,
} }
impl<E> ElementGroup<E> { impl<E> Group<E> {
pub fn new(name: SharedString, child: E) -> Self { pub fn new(name: SharedString, child: E) -> Self {
ElementGroup { name, child } Group { name, child }
} }
} }
impl<E: Element> Element for ElementGroup<E> { impl<E: Element> Element for Group<E> {
type ViewState = E::ViewState; type ViewState = E::ViewState;
type ElementState = E::ElementState; type ElementState = E::ElementState;
@ -64,7 +65,7 @@ impl<E: Element> Element for ElementGroup<E> {
} }
} }
impl<E: ParentElement> ParentElement for ElementGroup<E> { impl<E: ParentElement> ParentElement for Group<E> {
type State = E::State; type State = E::State;
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<Self::State>; 2]> { fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<Self::State>; 2]> {
@ -72,4 +73,25 @@ impl<E: ParentElement> ParentElement for ElementGroup<E> {
} }
} }
impl<E> IdentifiedElement for ElementGroup<E> where E: IdentifiedElement {} impl<E> IdentifiedElement for Group<E> where E: IdentifiedElement {}
impl<E> Styled for Group<E>
where
E: Styled,
{
type Style = E::Style;
fn style_cascade(&mut self) -> &mut Cascade<E::Style> {
self.child.style_cascade()
}
fn declared_style(&mut self) -> &mut <Self::Style as refineable::Refineable>::Refinement {
self.child.declared_style()
}
}
impl<S: 'static + Send + Sync, E: Interactive<S> + Styled> Interactive<S> for Group<E> {
fn listeners(&mut self) -> &mut MouseEventListeners<S> {
self.child.listeners()
}
}

View file

@ -3,7 +3,7 @@ use crate::{
Interactive, MouseEventListeners, MouseMoveEvent, ParentElement, Pixels, SharedString, Styled, Interactive, MouseEventListeners, MouseMoveEvent, ParentElement, Pixels, SharedString, Styled,
ViewContext, ViewContext,
}; };
use refineable::{CascadeSlot, Refineable, RefinementCascade}; use refineable::{Cascade, CascadeSlot, Refineable};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::sync::{ use std::sync::{
atomic::{AtomicBool, Ordering::SeqCst}, atomic::{AtomicBool, Ordering::SeqCst},
@ -36,7 +36,7 @@ where
{ {
type Style = E::Style; type Style = E::Style;
fn style_cascade(&mut self) -> &mut RefinementCascade<E::Style> { fn style_cascade(&mut self) -> &mut Cascade<E::Style> {
self.child.style_cascade() self.child.style_cascade()
} }
@ -80,12 +80,13 @@ where
element_state: &mut Self::ElementState, element_state: &mut Self::ElementState,
cx: &mut ViewContext<Self::ViewState>, cx: &mut ViewContext<Self::ViewState>,
) { ) {
let bounds = self let hover_bounds = self
.hover_group .hover_group
.as_ref() .as_ref()
.and_then(|group| element_group_bounds(group, cx)) .and_then(|group| element_group_bounds(group, cx))
.unwrap_or(bounds); .unwrap_or(bounds);
let hovered = bounds.contains_point(cx.mouse_position());
let hovered = hover_bounds.contains_point(cx.mouse_position());
let slot = self.cascade_slot; let slot = self.cascade_slot;
let style = hovered.then_some(self.hovered_style.clone()); let style = hovered.then_some(self.hovered_style.clone());
@ -97,7 +98,7 @@ where
move |_, event: &MouseMoveEvent, phase, cx| { move |_, event: &MouseMoveEvent, phase, cx| {
if phase == DispatchPhase::Capture { if phase == DispatchPhase::Capture {
if bounds.contains_point(event.position) != hovered.load(SeqCst) { if hover_bounds.contains_point(event.position) != hovered.load(SeqCst) {
cx.notify(); cx.notify();
} }
} }

View file

@ -1,4 +1,4 @@
use refineable::{Refineable, RefinementCascade}; use refineable::{Cascade, Refineable};
use smallvec::SmallVec; use smallvec::SmallVec;
use crate::{ use crate::{
@ -46,7 +46,7 @@ impl<E: Element> IdentifiedElement for Identified<E> {}
impl<E: Styled> Styled for Identified<E> { impl<E: Styled> Styled for Identified<E> {
type Style = E::Style; type Style = E::Style;
fn style_cascade(&mut self) -> &mut RefinementCascade<Self::Style> { fn style_cascade(&mut self) -> &mut Cascade<Self::Style> {
self.element.style_cascade() self.element.style_cascade()
} }
fn declared_style(&mut self) -> &mut <Self::Style as Refineable>::Refinement { fn declared_style(&mut self) -> &mut <Self::Style as Refineable>::Refinement {

View file

@ -2,12 +2,12 @@ use crate::{
BorrowWindow, Bounds, Element, LayoutId, Pixels, SharedString, Style, Styled, ViewContext, BorrowWindow, Bounds, Element, LayoutId, Pixels, SharedString, Style, Styled, ViewContext,
}; };
use futures::FutureExt; use futures::FutureExt;
use refineable::RefinementCascade; use refineable::Cascade;
use std::marker::PhantomData; use std::marker::PhantomData;
use util::ResultExt; use util::ResultExt;
pub struct Img<S> { pub struct Img<S> {
style: RefinementCascade<Style>, style: Cascade<Style>,
uri: Option<SharedString>, uri: Option<SharedString>,
grayscale: bool, grayscale: bool,
state_type: PhantomData<S>, state_type: PhantomData<S>,
@ -15,7 +15,7 @@ pub struct Img<S> {
pub fn img<S>() -> Img<S> { pub fn img<S>() -> Img<S> {
Img { Img {
style: RefinementCascade::default(), style: Cascade::default(),
uri: None, uri: None,
grayscale: false, grayscale: false,
state_type: PhantomData, state_type: PhantomData,
@ -94,7 +94,7 @@ impl<S: Send + Sync + 'static> Element for Img<S> {
impl<S> Styled for Img<S> { impl<S> Styled for Img<S> {
type Style = Style; type Style = Style;
fn style_cascade(&mut self) -> &mut RefinementCascade<Self::Style> { fn style_cascade(&mut self) -> &mut Cascade<Self::Style> {
&mut self.style &mut self.style
} }

View file

@ -2,7 +2,7 @@ use crate::{
AnyElement, Bounds, DispatchPhase, Element, IdentifiedElement, Interactive, MouseDownEvent, AnyElement, Bounds, DispatchPhase, Element, IdentifiedElement, Interactive, MouseDownEvent,
MouseEventListeners, MouseUpEvent, ParentElement, Pixels, Styled, ViewContext, MouseEventListeners, MouseUpEvent, ParentElement, Pixels, Styled, ViewContext,
}; };
use refineable::{CascadeSlot, Refineable, RefinementCascade}; use refineable::{Cascade, CascadeSlot, Refineable};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::sync::{ use std::sync::{
atomic::{AtomicBool, Ordering::SeqCst}, atomic::{AtomicBool, Ordering::SeqCst},
@ -36,7 +36,7 @@ where
{ {
type Style = E::Style; type Style = E::Style;
fn style_cascade(&mut self) -> &mut RefinementCascade<E::Style> { fn style_cascade(&mut self) -> &mut Cascade<E::Style> {
self.child.style_cascade() self.child.style_cascade()
} }

View file

@ -1,18 +1,18 @@
use crate::{Bounds, Element, LayoutId, Pixels, SharedString, Style, Styled}; use crate::{Bounds, Element, LayoutId, Pixels, SharedString, Style, Styled};
use refineable::RefinementCascade; use refineable::Cascade;
use std::marker::PhantomData; use std::marker::PhantomData;
use util::ResultExt; use util::ResultExt;
pub struct Svg<S> { pub struct Svg<S> {
path: Option<SharedString>, path: Option<SharedString>,
style: RefinementCascade<Style>, style: Cascade<Style>,
state_type: PhantomData<S>, state_type: PhantomData<S>,
} }
pub fn svg<S>() -> Svg<S> { pub fn svg<S>() -> Svg<S> {
Svg { Svg {
path: None, path: None,
style: RefinementCascade::<Style>::default(), style: Cascade::<Style>::default(),
state_type: PhantomData, state_type: PhantomData,
} }
} }
@ -64,7 +64,7 @@ impl<S: 'static + Send + Sync> Element for Svg<S> {
impl<S: 'static + Send + Sync> Styled for Svg<S> { impl<S: 'static + Send + Sync> Styled for Svg<S> {
type Style = Style; type Style = Style;
fn style_cascade(&mut self) -> &mut refineable::RefinementCascade<Self::Style> { fn style_cascade(&mut self) -> &mut refineable::Cascade<Self::Style> {
&mut self.style &mut self.style
} }

View file

@ -263,7 +263,7 @@ pub trait StyleHelpers: Styled<Style = Style> {
{ {
self.declared_style().box_shadow = Some(smallvec![ self.declared_style().box_shadow = Some(smallvec![
BoxShadow { BoxShadow {
color: hsla(0.5, 0., 0., 1.0), color: hsla(0.5, 0., 0., 0.1),
offset: point(px(0.), px(4.)), offset: point(px(0.), px(4.)),
blur_radius: px(6.), blur_radius: px(6.),
spread_radius: px(-1.), spread_radius: px(-1.),

View file

@ -1,9 +1,9 @@
use crate::{Hoverable, Pressable, Refineable, RefinementCascade, SharedString}; use crate::{Cascade, Hoverable, Pressable, Refineable, SharedString};
pub trait Styled { pub trait Styled {
type Style: 'static + Refineable + Send + Sync + Default; type Style: 'static + Refineable + Send + Sync + Default;
fn style_cascade(&mut self) -> &mut RefinementCascade<Self::Style>; fn style_cascade(&mut self) -> &mut Cascade<Self::Style>;
fn declared_style(&mut self) -> &mut <Self::Style as Refineable>::Refinement; fn declared_style(&mut self) -> &mut <Self::Style as Refineable>::Refinement;
fn computed_style(&mut self) -> Self::Style { fn computed_style(&mut self) -> Self::Style {

View file

@ -17,7 +17,7 @@ pub trait Refineable: Clone {
{ {
Self::default().refined(refinement) Self::default().refined(refinement)
} }
fn from_cascade(cascade: &RefinementCascade<Self>) -> Self fn from_cascade(cascade: &Cascade<Self>) -> Self
where where
Self: Default + Sized, Self: Default + Sized,
{ {
@ -25,9 +25,9 @@ pub trait Refineable: Clone {
} }
} }
pub struct RefinementCascade<S: Refineable>(Vec<Option<S::Refinement>>); pub struct Cascade<S: Refineable>(Vec<Option<S::Refinement>>);
impl<S: Refineable + Default> Default for RefinementCascade<S> { impl<S: Refineable + Default> Default for Cascade<S> {
fn default() -> Self { fn default() -> Self {
Self(vec![Some(Default::default())]) Self(vec![Some(Default::default())])
} }
@ -36,7 +36,7 @@ impl<S: Refineable + Default> Default for RefinementCascade<S> {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct CascadeSlot(usize); pub struct CascadeSlot(usize);
impl<S: Refineable + Default> RefinementCascade<S> { impl<S: Refineable + Default> Cascade<S> {
pub fn reserve(&mut self) -> CascadeSlot { pub fn reserve(&mut self) -> CascadeSlot {
self.0.push(None); self.0.push(None);
return CascadeSlot(self.0.len() - 1); return CascadeSlot(self.0.len() - 1);

View file

@ -43,27 +43,27 @@ impl CollabPanel {
.flex_col() .flex_col()
.overflow_y_scroll(self.scroll_state.clone()) .overflow_y_scroll(self.scroll_state.clone())
// List Container // List Container
.child( // .child(
div() // div()
.id(0) // .id(0)
.on_click(|_, _, _| { // .on_click(|_, _, _| {
dbg!("click!"); // dbg!("click!");
}) // })
.fill(theme.lowest.base.default.background) // .fill(theme.lowest.base.default.background)
.pb_1() // .pb_1()
.border_color(theme.lowest.base.default.border) // .border_color(theme.lowest.base.default.border)
.border_b() // .border_b()
//:: https://tailwindcss.com/docs/hover-focus-and-other-states#styling-based-on-parent-state // //:: https://tailwindcss.com/docs/hover-focus-and-other-states#styling-based-on-parent-state
// .group() // // .group()
// List Section Header // // List Section Header
.child(self.list_section_header(0, "#CRDB 🗃️", true, theme)) // .child(self.list_section_header(0, "#CRDB 🗃️", true, theme))
// List Item Large // // List Item Large
.child(self.list_item( // .child(self.list_item(
"http://github.com/maxbrunsfeld.png?s=50", // "http://github.com/maxbrunsfeld.png?s=50",
"maxbrunsfeld", // "maxbrunsfeld",
theme, // theme,
)), // )),
) // )
.child( .child(
div() div()
.py_2() .py_2()
@ -85,19 +85,19 @@ impl CollabPanel {
"as-cii", "as-cii",
theme, theme,
), ),
self.list_item( // self.list_item(
"http://github.com/nathansobo.png?s=50", // "http://github.com/nathansobo.png?s=50",
"nathansobo", // "nathansobo",
theme, // theme,
), // ),
self.list_item( // self.list_item(
"http://github.com/maxbrunsfeld.png?s=50", // "http://github.com/maxbrunsfeld.png?s=50",
"maxbrunsfeld", // "maxbrunsfeld",
theme, // theme,
), // ),
] ]
}) })
.take(5) .take(1)
.flatten(), .flatten(),
), ),
), ),
@ -133,8 +133,6 @@ impl CollabPanel {
.flex() .flex()
.justify_between() .justify_between()
.items_center() .items_center()
.hover()
.fill(theme.lowest.base.active.background)
.active() .active()
.fill(theme.highest.accent.default.background) .fill(theme.highest.accent.default.background)
.child(div().flex().gap_1().text_sm().child(label)) .child(div().flex().gap_1().text_sm().child(label))
@ -160,6 +158,7 @@ impl CollabPanel {
theme: &Theme, theme: &Theme,
) -> impl Element<ViewState = Self> { ) -> impl Element<ViewState = Self> {
div() div()
.group("")
.h_7() .h_7()
.px_2() .px_2()
.flex() .flex()
@ -175,12 +174,16 @@ impl CollabPanel {
.gap_1() .gap_1()
.text_sm() .text_sm()
.child( .child(
img() div()
.uri(avatar_uri) // .uri(avatar_uri)
.size_3p5() .size_3p5()
.rounded_full() .rounded_full()
.fill(theme.middle.positive.default.foreground) .fill(theme.middle.positive.default.foreground)
.shadow_md(), .shadow()
.group_hover("")
.fill(theme.middle.negative.default.foreground)
.hover()
.fill(theme.middle.warning.default.foreground),
) )
.child(label), .child(label),
) )

View file

@ -1,10 +1,13 @@
#![allow(dead_code, unused_variables)] #![allow(dead_code, unused_variables)]
use assets::Assets; use assets::Assets;
use gpui3::{px, size, Bounds, WindowBounds, WindowOptions}; use gpui3::{
div, px, size, Bounds, Element, StyleHelpers, WindowBounds, WindowContext, WindowOptions,
};
use log::LevelFilter; use log::LevelFilter;
use simplelog::SimpleLogger; use simplelog::SimpleLogger;
use std::sync::Arc; use std::sync::Arc;
use themes::rose_pine;
use workspace::workspace; use workspace::workspace;
mod assets; mod assets;

View file

@ -1,10 +1,10 @@
use crate::{ use crate::{
collab_panel::{collab_panel, CollabPanel}, collab_panel::{collab_panel, CollabPanel},
theme::{theme, themed}, theme::{theme, themed},
themes::rose_pine_dawn, themes::{rose_pine, rose_pine_dawn},
}; };
use gpui3::{ use gpui3::{
div, img, svg, view, Context, Element, ParentElement, RootView, StyleHelpers, View, div, img, svg, view, Context, Element, ParentElement, RootView, StyleHelpers, Styled, View,
ViewContext, WindowContext, ViewContext, WindowContext,
}; };
@ -25,8 +25,34 @@ impl Workspace {
} }
} }
fn hover_test(&self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
let theme = theme(cx);
div().size_full().child(
div()
.group("")
.w_full()
.h_5()
.mt_10()
.fill(theme.middle.warning.default.foreground)
.flex()
.flex_row()
.justify_center()
.child(
div()
.size_5()
.fill(theme.middle.negative.default.foreground)
.group_hover("")
.fill(theme.middle.positive.default.foreground)
.hover()
.fill(theme.middle.variant.default.foreground),
),
)
}
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
themed(rose_pine_dawn(), cx, |cx| { themed(rose_pine(), cx, |cx| {
// self.hover_test(cx)
let theme = theme(cx); let theme = theme(cx);
div() div()
.size_full() .size_full()
@ -47,8 +73,7 @@ impl Workspace {
.flex_row() .flex_row()
.overflow_hidden() .overflow_hidden()
.child(self.left_panel.clone()) .child(self.left_panel.clone())
.child(div().h_full().flex_1()) .child(div().h_full().flex_1()), // .child(self.right_panel.clone()),
.child(self.right_panel.clone()),
) )
.child(statusbar::statusbar(cx)) .child(statusbar::statusbar(cx))
}) })