diff --git a/crates/collab_ui2/src/collab_titlebar_item.rs b/crates/collab_ui2/src/collab_titlebar_item.rs index bc30766c66..c5872e660d 100644 --- a/crates/collab_ui2/src/collab_titlebar_item.rs +++ b/crates/collab_ui2/src/collab_titlebar_item.rs @@ -302,87 +302,6 @@ fn render_color_ribbon( .w_full() } -// impl Entity for CollabTitlebarItem { -// type Event = (); -// } - -// impl View for CollabTitlebarItem { -// fn ui_name() -> &'static str { -// "CollabTitlebarItem" -// } - -// fn render(&mut self, cx: &mut ViewContext) -> AnyElement { -// let workspace = if let Some(workspace) = self.workspace.upgrade(cx) { -// workspace -// } else { -// return Empty::new().into_any(); -// }; - -// let theme = theme::current(cx).clone(); -// let mut left_container = Flex::row(); -// let mut right_container = Flex::row().align_children_center(); - -// left_container.add_child(self.collect_title_root_names(theme.clone(), cx)); - -// let user = self.user_store.read(cx).current_user(); -// let peer_id = self.client.peer_id(); -// if let Some(((user, peer_id), room)) = user -// .as_ref() -// .zip(peer_id) -// .zip(ActiveCall::global(cx).read(cx).room().cloned()) -// { -// if room.read(cx).can_publish() { -// right_container -// .add_children(self.render_in_call_share_unshare_button(&workspace, &theme, cx)); -// } -// right_container.add_child(self.render_leave_call(&theme, cx)); -// let muted = room.read(cx).is_muted(cx); -// let speaking = room.read(cx).is_speaking(); -// left_container.add_child( -// self.render_current_user(&workspace, &theme, &user, peer_id, muted, speaking, cx), -// ); -// left_container.add_children(self.render_collaborators(&workspace, &theme, &room, cx)); -// if room.read(cx).can_publish() { -// right_container.add_child(self.render_toggle_mute(&theme, &room, cx)); -// } -// right_container.add_child(self.render_toggle_deafen(&theme, &room, cx)); -// if room.read(cx).can_publish() { -// right_container -// .add_child(self.render_toggle_screen_sharing_button(&theme, &room, cx)); -// } -// } - -// let status = workspace.read(cx).client().status(); -// let status = &*status.borrow(); -// if matches!(status, client::Status::Connected { .. }) { -// let avatar = user.as_ref().and_then(|user| user.avatar.clone()); -// right_container.add_child(self.render_user_menu_button(&theme, avatar, cx)); -// } else { -// right_container.add_children(self.render_connection_status(status, cx)); -// right_container.add_child(self.render_sign_in_button(&theme, cx)); -// right_container.add_child(self.render_user_menu_button(&theme, None, cx)); -// } - -// Stack::new() -// .with_child(left_container) -// .with_child( -// Flex::row() -// .with_child( -// right_container.contained().with_background_color( -// theme -// .titlebar -// .container -// .background_color -// .unwrap_or_else(|| Color::transparent_black()), -// ), -// ) -// .aligned() -// .right(), -// ) -// .into_any() -// } -// } - impl CollabTitlebarItem { pub fn new(workspace: &Workspace, cx: &mut ViewContext) -> Self { let project = workspace.project().clone(); @@ -527,170 +446,6 @@ impl CollabTitlebarItem { Some(pile) } - // fn collect_title_root_names( - // &self, - // theme: Arc, - // cx: &mut ViewContext, - // ) -> AnyElement { - // let project = self.project.read(cx); - - // let (name, entry) = { - // let mut names_and_branches = project.visible_worktrees(cx).map(|worktree| { - // let worktree = worktree.read(cx); - // (worktree.root_name(), worktree.root_git_entry()) - // }); - - // names_and_branches.next().unwrap_or(("", None)) - // }; - - // let name = util::truncate_and_trailoff(name, MAX_PROJECT_NAME_LENGTH); - // let branch_prepended = entry - // .as_ref() - // .and_then(RepositoryEntry::branch) - // .map(|branch| util::truncate_and_trailoff(&branch, MAX_BRANCH_NAME_LENGTH)); - // let project_style = theme.titlebar.project_menu_button.clone(); - // let git_style = theme.titlebar.git_menu_button.clone(); - // let item_spacing = theme.titlebar.item_spacing; - - // let mut ret = Flex::row(); - - // if let Some(project_host) = self.collect_project_host(theme.clone(), cx) { - // ret = ret.with_child(project_host) - // } - - // ret = ret.with_child( - // Stack::new() - // .with_child( - // MouseEventHandler::new::(0, cx, |mouse_state, cx| { - // let style = project_style - // .in_state(self.project_popover.is_some()) - // .style_for(mouse_state); - // enum RecentProjectsTooltip {} - // Label::new(name, style.text.clone()) - // .contained() - // .with_style(style.container) - // .aligned() - // .left() - // .with_tooltip::( - // 0, - // "Recent projects", - // Some(Box::new(recent_projects::OpenRecent)), - // theme.tooltip.clone(), - // cx, - // ) - // .into_any_named("title-project-name") - // }) - // .with_cursor_style(CursorStyle::PointingHand) - // .on_down(MouseButton::Left, move |_, this, cx| { - // this.toggle_project_menu(&Default::default(), cx) - // }) - // .on_click(MouseButton::Left, move |_, _, _| {}), - // ) - // .with_children(self.render_project_popover_host(&theme.titlebar, cx)), - // ); - // if let Some(git_branch) = branch_prepended { - // ret = ret.with_child( - // Flex::row().with_child( - // Stack::new() - // .with_child( - // MouseEventHandler::new::(0, cx, |mouse_state, cx| { - // enum BranchPopoverTooltip {} - // let style = git_style - // .in_state(self.branch_popover.is_some()) - // .style_for(mouse_state); - // Label::new(git_branch, style.text.clone()) - // .contained() - // .with_style(style.container.clone()) - // .with_margin_right(item_spacing) - // .aligned() - // .left() - // .with_tooltip::( - // 0, - // "Recent branches", - // Some(Box::new(ToggleVcsMenu)), - // theme.tooltip.clone(), - // cx, - // ) - // .into_any_named("title-project-branch") - // }) - // .with_cursor_style(CursorStyle::PointingHand) - // .on_down(MouseButton::Left, move |_, this, cx| { - // this.toggle_vcs_menu(&Default::default(), cx) - // }) - // .on_click(MouseButton::Left, move |_, _, _| {}), - // ) - // .with_children(self.render_branches_popover_host(&theme.titlebar, cx)), - // ), - // ) - // } - // ret.into_any() - // } - - // fn collect_project_host( - // &self, - // theme: Arc, - // cx: &mut ViewContext, - // ) -> Option> { - // if ActiveCall::global(cx).read(cx).room().is_none() { - // return None; - // } - // let project = self.project.read(cx); - // let user_store = self.user_store.read(cx); - - // if project.is_local() { - // return None; - // } - - // let Some(host) = project.host() else { - // return None; - // }; - // let (Some(host_user), Some(participant_index)) = ( - // user_store.get_cached_user(host.user_id), - // user_store.participant_indices().get(&host.user_id), - // ) else { - // return None; - // }; - - // enum ProjectHost {} - // enum ProjectHostTooltip {} - - // let host_style = theme.titlebar.project_host.clone(); - // let selection_style = theme - // .editor - // .selection_style_for_room_participant(participant_index.0); - // let peer_id = host.peer_id.clone(); - - // Some( - // MouseEventHandler::new::(0, cx, |mouse_state, _| { - // let mut host_style = host_style.style_for(mouse_state).clone(); - // host_style.text.color = selection_style.cursor; - // Label::new(host_user.github_login.clone(), host_style.text) - // .contained() - // .with_style(host_style.container) - // .aligned() - // .left() - // }) - // .with_cursor_style(CursorStyle::PointingHand) - // .on_click(MouseButton::Left, move |_, this, cx| { - // if let Some(workspace) = this.workspace.upgrade(cx) { - // if let Some(task) = - // workspace.update(cx, |workspace, cx| workspace.follow(peer_id, cx)) - // { - // task.detach_and_log_err(cx); - // } - // } - // }) - // .with_tooltip::( - // 0, - // host_user.github_login.clone() + " is sharing this project. Click to follow.", - // None, - // theme.tooltip.clone(), - // cx, - // ) - // .into_any_named("project-host"), - // ) - // } - fn window_activation_changed(&mut self, cx: &mut ViewContext) { let project = if cx.is_window_active() { Some(self.project.clone()) @@ -886,245 +641,6 @@ impl CollabTitlebarItem { // cx.notify(); // } - // fn render_toggle_screen_sharing_button( - // &self, - // theme: &Theme, - // room: &ModelHandle, - // cx: &mut ViewContext, - // ) -> AnyElement { - // let icon; - // let tooltip; - // if room.read(cx).is_screen_sharing() { - // icon = "icons/desktop.svg"; - // tooltip = "Stop Sharing Screen" - // } else { - // icon = "icons/desktop.svg"; - // tooltip = "Share Screen"; - // } - - // let active = room.read(cx).is_screen_sharing(); - // let titlebar = &theme.titlebar; - // MouseEventHandler::new::(0, cx, |state, _| { - // let style = titlebar - // .screen_share_button - // .in_state(active) - // .style_for(state); - - // Svg::new(icon) - // .with_color(style.color) - // .constrained() - // .with_width(style.icon_width) - // .aligned() - // .constrained() - // .with_width(style.button_width) - // .with_height(style.button_width) - // .contained() - // .with_style(style.container) - // }) - // .with_cursor_style(CursorStyle::PointingHand) - // .on_click(MouseButton::Left, move |_, _, cx| { - // toggle_screen_sharing(&Default::default(), cx) - // }) - // .with_tooltip::( - // 0, - // tooltip, - // Some(Box::new(ToggleScreenSharing)), - // theme.tooltip.clone(), - // cx, - // ) - // .aligned() - // .into_any() - // } - // fn render_toggle_mute( - // &self, - // theme: &Theme, - // room: &ModelHandle, - // cx: &mut ViewContext, - // ) -> AnyElement { - // let icon; - // let tooltip; - // let is_muted = room.read(cx).is_muted(cx); - // if is_muted { - // icon = "icons/mic-mute.svg"; - // tooltip = "Unmute microphone"; - // } else { - // icon = "icons/mic.svg"; - // tooltip = "Mute microphone"; - // } - - // let titlebar = &theme.titlebar; - // MouseEventHandler::new::(0, cx, |state, _| { - // let style = titlebar - // .toggle_microphone_button - // .in_state(is_muted) - // .style_for(state); - // let image = Svg::new(icon) - // .with_color(style.color) - // .constrained() - // .with_width(style.icon_width) - // .aligned() - // .constrained() - // .with_width(style.button_width) - // .with_height(style.button_width) - // .contained() - // .with_style(style.container); - // if let Some(color) = style.container.background_color { - // image.with_background_color(color) - // } else { - // image - // } - // }) - // .with_cursor_style(CursorStyle::PointingHand) - // .on_click(MouseButton::Left, move |_, _, cx| { - // toggle_mute(&Default::default(), cx) - // }) - // .with_tooltip::( - // 0, - // tooltip, - // Some(Box::new(ToggleMute)), - // theme.tooltip.clone(), - // cx, - // ) - // .aligned() - // .into_any() - // } - // fn render_toggle_deafen( - // &self, - // theme: &Theme, - // room: &ModelHandle, - // cx: &mut ViewContext, - // ) -> AnyElement { - // let icon; - // let tooltip; - // let is_deafened = room.read(cx).is_deafened().unwrap_or(false); - // if is_deafened { - // icon = "icons/speaker-off.svg"; - // tooltip = "Unmute speakers"; - // } else { - // icon = "icons/speaker-loud.svg"; - // tooltip = "Mute speakers"; - // } - - // let titlebar = &theme.titlebar; - // MouseEventHandler::new::(0, cx, |state, _| { - // let style = titlebar - // .toggle_speakers_button - // .in_state(is_deafened) - // .style_for(state); - // Svg::new(icon) - // .with_color(style.color) - // .constrained() - // .with_width(style.icon_width) - // .aligned() - // .constrained() - // .with_width(style.button_width) - // .with_height(style.button_width) - // .contained() - // .with_style(style.container) - // }) - // .with_cursor_style(CursorStyle::PointingHand) - // .on_click(MouseButton::Left, move |_, _, cx| { - // toggle_deafen(&Default::default(), cx) - // }) - // .with_tooltip::( - // 0, - // tooltip, - // Some(Box::new(ToggleDeafen)), - // theme.tooltip.clone(), - // cx, - // ) - // .aligned() - // .into_any() - // } - // fn render_leave_call(&self, theme: &Theme, cx: &mut ViewContext) -> AnyElement { - // let icon = "icons/exit.svg"; - // let tooltip = "Leave call"; - - // let titlebar = &theme.titlebar; - // MouseEventHandler::new::(0, cx, |state, _| { - // let style = titlebar.leave_call_button.style_for(state); - // Svg::new(icon) - // .with_color(style.color) - // .constrained() - // .with_width(style.icon_width) - // .aligned() - // .constrained() - // .with_width(style.button_width) - // .with_height(style.button_width) - // .contained() - // .with_style(style.container) - // }) - // .with_cursor_style(CursorStyle::PointingHand) - // .on_click(MouseButton::Left, move |_, _, cx| { - // ActiveCall::global(cx) - // .update(cx, |call, cx| call.hang_up(cx)) - // .detach_and_log_err(cx); - // }) - // .with_tooltip::( - // 0, - // tooltip, - // Some(Box::new(LeaveCall)), - // theme.tooltip.clone(), - // cx, - // ) - // .aligned() - // .into_any() - // } - // fn render_in_call_share_unshare_button( - // &self, - // workspace: &ViewHandle, - // theme: &Theme, - // cx: &mut ViewContext, - // ) -> Option> { - // let project = workspace.read(cx).project(); - // if project.read(cx).is_remote() { - // return None; - // } - - // let is_shared = project.read(cx).is_shared(); - // let label = if is_shared { "Stop Sharing" } else { "Share" }; - // let tooltip = if is_shared { - // "Stop sharing project with call participants" - // } else { - // "Share project with call participants" - // }; - - // let titlebar = &theme.titlebar; - - // enum ShareUnshare {} - // Some( - // Stack::new() - // .with_child( - // MouseEventHandler::new::(0, cx, |state, _| { - // //TODO: Ensure this button has consistent width for both text variations - // let style = titlebar.share_button.inactive_state().style_for(state); - // Label::new(label, style.text.clone()) - // .contained() - // .with_style(style.container) - // }) - // .with_cursor_style(CursorStyle::PointingHand) - // .on_click(MouseButton::Left, move |_, this, cx| { - // if is_shared { - // this.unshare_project(&Default::default(), cx); - // } else { - // this.share_project(&Default::default(), cx); - // } - // }) - // .with_tooltip::( - // 0, - // tooltip.to_owned(), - // None, - // theme.tooltip.clone(), - // cx, - // ), - // ) - // .aligned() - // .contained() - // .with_margin_left(theme.titlebar.item_spacing) - // .into_any(), - // ) - // } - // fn render_user_menu_button( // &self, // theme: &Theme, @@ -1476,25 +992,6 @@ impl CollabTitlebarItem { // style // } - // fn render_face( - // avatar: Arc, - // avatar_style: AvatarStyle, - // background_color: Color, - // microphone_state: Option, - // ) -> AnyElement { - // Image::from_data(avatar) - // .with_style(avatar_style.image) - // .aligned() - // .contained() - // .with_background_color(microphone_state.unwrap_or(background_color)) - // .with_corner_radius(avatar_style.outer_corner_radius) - // .constrained() - // .with_width(avatar_style.outer_width) - // .with_height(avatar_style.outer_width) - // .aligned() - // .into_any() - // } - // fn render_connection_status( // &self, // status: &client::Status, @@ -1554,76 +1051,3 @@ impl CollabTitlebarItem { // } // } } - -// pub struct AvatarRibbon { -// color: Color, -// } - -// impl AvatarRibbon { -// pub fn new(color: Color) -> AvatarRibbon { -// AvatarRibbon { color } -// } -// } - -// impl Element for AvatarRibbon { -// type LayoutState = (); - -// type PaintState = (); - -// fn layout( -// &mut self, -// constraint: gpui::SizeConstraint, -// _: &mut CollabTitlebarItem, -// _: &mut ViewContext, -// ) -> (gpui::geometry::vector::Vector2F, Self::LayoutState) { -// (constraint.max, ()) -// } - -// fn paint( -// &mut self, -// bounds: RectF, -// _: RectF, -// _: &mut Self::LayoutState, -// _: &mut CollabTitlebarItem, -// cx: &mut ViewContext, -// ) -> Self::PaintState { -// let mut path = PathBuilder::new(); -// path.reset(bounds.lower_left()); -// path.curve_to( -// bounds.origin() + vec2f(bounds.height(), 0.), -// bounds.origin(), -// ); -// path.line_to(bounds.upper_right() - vec2f(bounds.height(), 0.)); -// path.curve_to(bounds.lower_right(), bounds.upper_right()); -// path.line_to(bounds.lower_left()); -// cx.scene().push_path(path.build(self.color, None)); -// } - -// fn rect_for_text_range( -// &self, -// _: Range, -// _: RectF, -// _: RectF, -// _: &Self::LayoutState, -// _: &Self::PaintState, -// _: &CollabTitlebarItem, -// _: &ViewContext, -// ) -> Option { -// None -// } - -// fn debug( -// &self, -// bounds: RectF, -// _: &Self::LayoutState, -// _: &Self::PaintState, -// _: &CollabTitlebarItem, -// _: &ViewContext, -// ) -> gpui::json::Value { -// json::json!({ -// "type": "AvatarRibbon", -// "bounds": bounds.to_json(), -// "color": self.color.to_json(), -// }) -// } -// } diff --git a/crates/collab_ui2/src/face_pile.rs b/crates/collab_ui2/src/face_pile.rs index 162a3f261a..b7422d2b22 100644 --- a/crates/collab_ui2/src/face_pile.rs +++ b/crates/collab_ui2/src/face_pile.rs @@ -21,58 +21,6 @@ impl RenderOnce for FacePile { } } -// impl Element for FacePile { -// type State = (); -// fn layout( -// &mut self, -// state: Option, -// cx: &mut WindowContext, -// ) -> (LayoutId, Self::State) { -// let mut width = 0.; -// let mut max_height = 0.; -// let mut faces = Vec::with_capacity(self.faces.len()); -// for face in &mut self.faces { -// let layout = face.layout(cx); -// width += layout.x(); -// max_height = f32::max(max_height, layout.y()); -// faces.push(layout); -// } -// width -= self.overlap * self.faces.len().saturating_sub(1) as f32; -// (cx.request_layout(&Style::default(), faces), ()) -// // ( -// // Vector2F::new(width, max_height.clamp(1., constraint.max.y())), -// // (), -// // )) -// } - -// fn paint( -// &mut self, -// bounds: RectF, -// visible_bounds: RectF, -// _layout: &mut Self::LayoutState, -// view: &mut V, -// cx: &mut ViewContext, -// ) -> Self::PaintState { -// let visible_bounds = bounds.intersection(visible_bounds).unwrap_or_default(); - -// let origin_y = bounds.upper_right().y(); -// let mut origin_x = bounds.upper_right().x(); - -// for face in self.faces.iter_mut().rev() { -// let size = face.size(); -// origin_x -= size.x(); -// let origin_y = origin_y + (bounds.height() - size.y()) / 2.0; - -// cx.scene().push_layer(None); -// face.paint(vec2f(origin_x, origin_y), visible_bounds, view, cx); -// cx.scene().pop_layer(); -// origin_x += self.overlap; -// } - -// () -// } -// } - impl Extend for FacePile { fn extend>(&mut self, children: T) { self.faces.extend(children);