From 8049ec674ec4711c5db400c27eb0c388cd3d711f Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 20 Nov 2023 16:35:56 -0700 Subject: [PATCH] Fix last thing --- crates/terminal_view2/src/terminal_view.rs | 1 - crates/ui2/src/components/list.rs | 9 ++++--- crates/ui2/src/components/panel.rs | 6 ++--- crates/workspace2/src/dock.rs | 28 ++++++++++------------ 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/crates/terminal_view2/src/terminal_view.rs b/crates/terminal_view2/src/terminal_view.rs index 66dbd95dc4..c61afb0b94 100644 --- a/crates/terminal_view2/src/terminal_view.rs +++ b/crates/terminal_view2/src/terminal_view.rs @@ -63,7 +63,6 @@ pub struct SendKeystroke(String); actions!(Clear, Copy, Paste, ShowCharacterPalette, SearchTest); pub fn init(cx: &mut AppContext) { - workspace::ui::init(cx); terminal_panel::init(cx); terminal::init(cx); diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rs index b1a8d43bd8..54758b3803 100644 --- a/crates/ui2/src/components/list.rs +++ b/crates/ui2/src/components/list.rs @@ -1,8 +1,9 @@ -use gpui::{div, AnyElement, ClickEvent, Div, RenderOnce, Stateful, StatefulInteractiveElement}; +use gpui::{ + div, px, AnyElement, ClickEvent, Div, RenderOnce, Stateful, StatefulInteractiveElement, +}; use smallvec::SmallVec; use std::rc::Rc; -use crate::settings::user_settings; use crate::{ disclosure_control, h_stack, v_stack, Avatar, Icon, IconElement, IconSize, Label, Toggle, }; @@ -331,8 +332,6 @@ impl Component for ListItem { type Rendered = Stateful
; fn render(self, cx: &mut WindowContext) -> Self::Rendered { - let settings = user_settings(cx); - let left_content = match self.left_slot.clone() { Some(GraphicSlot::Icon(i)) => Some( h_stack().child( @@ -377,7 +376,7 @@ impl Component for ListItem { // .ml(rems(0.75 * self.indent_level as f32)) .children((0..self.indent_level).map(|_| { div() - .w(*settings.list_indent_depth) + .w(px(4.)) .h_full() .flex() .justify_center() diff --git a/crates/ui2/src/components/panel.rs b/crates/ui2/src/components/panel.rs index fefc2d4f70..4918d0df95 100644 --- a/crates/ui2/src/components/panel.rs +++ b/crates/ui2/src/components/panel.rs @@ -1,8 +1,8 @@ +use gpui::px; use gpui::{prelude::*, AbsoluteLength, AnyElement, Div, RenderOnce}; use smallvec::SmallVec; use crate::prelude::*; -use crate::settings::user_settings; use crate::v_stack; #[derive(Default, Debug, PartialEq, Eq, Hash, Clone, Copy)] @@ -75,13 +75,11 @@ impl Component for Panel { impl Panel { pub fn new(id: impl Into, cx: &mut WindowContext) -> Self { - let settings = user_settings(cx); - Self { id: id.into(), current_side: PanelSide::default(), allowed_sides: PanelAllowedSides::default(), - initial_width: *settings.default_panel_size, + initial_width: px(320.).into(), width: None, children: SmallVec::new(), } diff --git a/crates/workspace2/src/dock.rs b/crates/workspace2/src/dock.rs index 6da6052193..b44178ceb7 100644 --- a/crates/workspace2/src/dock.rs +++ b/crates/workspace2/src/dock.rs @@ -8,7 +8,9 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::sync::Arc; use theme2::ActiveTheme; -use ui::{h_stack, menu_handle, ContextMenu, IconButton, InteractionState, Tooltip}; +use ui::{ + h_stack, menu_handle, ContextMenu, IconButton, InteractionState, Label, ListItem, Tooltip, +}; pub enum PanelEvent { ChangePosition, @@ -711,25 +713,21 @@ impl Render for PanelButtons { DockPosition::Bottom, ]; - //CX: Pane ContextMenu::build(cx, |mut menu, cx| { - // CX: Menu for position in POSITIONS { if position != dock_position && panel.position_is_valid(position, cx) { - // let panel = panel.clone(); - todo!() - // menu = menu.entry( - // ListEntry::new(Label::new(format!( - // "Dock {}", - // position.to_label() - // ))), - // cx.listener(move |_, cx| { - // //What should CX be? CX: Pane - // panel.set_position(position, cx); - // }), - //) + let panel = panel.clone(); + menu = menu.entry( + ListItem::new( + panel.entity_id(), + Label::new(format!("Dock {}", position.to_label())), + ), + move |_, cx| { + panel.set_position(position, cx); + }, + ) } } menu