Move the collab panel to the left by default

Increase the indent size on channels
Switch font UI mono
This commit is contained in:
Mikayla 2023-08-18 14:53:30 -07:00
parent d1aa82bb48
commit 8ef671d7a1
No known key found for this signature in database
6 changed files with 78 additions and 22 deletions

View file

@ -2354,7 +2354,7 @@ impl View for CollabPanel {
.into_any()
})
.on_click(MouseButton::Left, |_, _, cx| cx.focus_self())
.into_any_named("channels panel")
.into_any_named("collab panel")
}
}
@ -2404,7 +2404,10 @@ impl Panel for CollabPanel {
}
fn icon_tooltip(&self) -> (String, Option<Box<dyn gpui::Action>>) {
("Channels Panel".to_string(), Some(Box::new(ToggleFocus)))
(
"Collaboration Panel".to_string(),
Some(Box::new(ToggleFocus)),
)
}
fn should_change_position_on_event(event: &Self::Event) -> bool {

View file

@ -72,7 +72,7 @@ impl View for TestView {
TextStyle::for_color(Color::blue()),
)
.with_style(ButtonStyle::fill(Color::yellow()))
.into_element(),
.element(),
)
.with_child(
ToggleableButton::new(self.is_doubling, move |_, v: &mut Self, cx| {
@ -84,7 +84,7 @@ impl View for TestView {
inactive: ButtonStyle::fill(Color::red()),
active: ButtonStyle::fill(Color::green()),
})
.into_element(),
.element(),
)
.expanded()
.contained()

View file

@ -9,6 +9,12 @@ use super::Empty;
pub trait GeneralComponent {
fn render<V: View>(self, v: &mut V, cx: &mut ViewContext<V>) -> AnyElement<V>;
fn element<V: View>(self) -> ComponentAdapter<V, Self>
where
Self: Sized,
{
ComponentAdapter::new(self)
}
}
pub trait StyleableComponent {
@ -50,6 +56,53 @@ impl<V: View, C: GeneralComponent> Component<V> for C {
}
}
// StylableComponent -> GeneralComponent
pub struct StylableComponentAdapter<C: Component<V>, V: View> {
component: C,
phantom: std::marker::PhantomData<V>,
}
impl<C: Component<V>, V: View> StylableComponentAdapter<C, V> {
fn new(component: C) -> Self {
Self {
component,
phantom: std::marker::PhantomData,
}
}
}
impl<C: GeneralComponent, V: View> StyleableComponent for StylableComponentAdapter<C, V> {
type Style = ();
type Output = C;
fn with_style(self, _: Self::Style) -> Self::Output {
self.component
}
}
// Element -> Component
pub struct ElementAdapter<V: View> {
element: AnyElement<V>,
_phantom: std::marker::PhantomData<V>,
}
impl<V: View> ElementAdapter<V> {
pub fn new(element: AnyElement<V>) -> Self {
Self {
element,
_phantom: std::marker::PhantomData,
}
}
}
impl<V: View> Component<V> for ElementAdapter<V> {
fn render(self, _: &mut V, _: &mut ViewContext<V>) -> AnyElement<V> {
self.element
}
}
// Component -> Element
pub struct ComponentAdapter<V: View, E> {
component: Option<E>,
element: Option<AnyElement<V>>,