Superimpose external location message on active view

This commit is contained in:
Antonio Scandurra 2022-10-10 12:23:50 +02:00
parent d7bac3cea6
commit 25ff5959fb
2 changed files with 78 additions and 56 deletions

View File

@ -127,16 +127,26 @@ impl Member {
Some((collaborator.replica_id, participant)) Some((collaborator.replica_id, participant))
}); });
if let Some((replica_id, leader)) = leader { let mut border = Border::default();
let view = match leader.location {
let prompt = if let Some((replica_id, leader)) = leader {
let leader_color = theme.editor.replica_selection_style(replica_id).cursor;
border = Border::all(theme.workspace.leader_border_width, leader_color);
border
.color
.fade_out(1. - theme.workspace.leader_border_opacity);
border.overlay = true;
match leader.location {
call::ParticipantLocation::Project { call::ParticipantLocation::Project {
project_id: leader_project_id, project_id: leader_project_id,
} => { } => {
if Some(leader_project_id) == project.read(cx).remote_id() { if Some(leader_project_id) == project.read(cx).remote_id() {
ChildView::new(pane).boxed() None
} else { } else {
let leader_user = leader.user.clone(); let leader_user = leader.user.clone();
let leader_user_id = leader.user.id; let leader_user_id = leader.user.id;
Some(
MouseEventHandler::<FollowIntoExternalProject>::new( MouseEventHandler::<FollowIntoExternalProject>::new(
pane.id(), pane.id(),
cx, cx,
@ -146,7 +156,11 @@ impl Member {
"Follow {} on their currently active project", "Follow {} on their currently active project",
leader_user.github_login, leader_user.github_login,
), ),
theme.workspace.external_location_message.text.clone(), theme
.workspace
.external_location_message
.text
.clone(),
) )
.contained() .contained()
.with_style( .with_style(
@ -163,10 +177,14 @@ impl Member {
}) })
}) })
.aligned() .aligned()
.boxed() .bottom()
.right()
.boxed(),
)
} }
} }
call::ParticipantLocation::External => Label::new( call::ParticipantLocation::External => Some(
Label::new(
format!( format!(
"{} is viewing a window outside of Zed", "{} is viewing a window outside of Zed",
leader.user.github_login leader.user.github_login
@ -176,19 +194,19 @@ impl Member {
.contained() .contained()
.with_style(theme.workspace.external_location_message.container) .with_style(theme.workspace.external_location_message.container)
.aligned() .aligned()
.bottom()
.right()
.boxed(), .boxed(),
),
}
} else {
None
}; };
let leader_color = theme.editor.replica_selection_style(replica_id).cursor; Stack::new()
let mut border = Border::all(theme.workspace.leader_border_width, leader_color); .with_child(ChildView::new(pane).contained().with_border(border).boxed())
border .with_children(prompt)
.color .boxed()
.fade_out(1. - theme.workspace.leader_border_opacity);
border.overlay = true;
Container::new(view).with_border(border).boxed()
} else {
ChildView::new(pane).boxed()
}
} }
Member::Axis(axis) => axis.render(project, theme, follower_states, cx), Member::Axis(axis) => axis.render(project, theme, follower_states, cx),
} }

View File

@ -48,8 +48,12 @@ export default function workspace(theme: Theme) {
...text(theme, "sans", "primary", { size: "lg" }), ...text(theme, "sans", "primary", { size: "lg" }),
}, },
externalLocationMessage: { externalLocationMessage: {
background: backgroundColor(theme, "info"),
border: border(theme, "secondary"),
cornerRadius: 6,
padding: 12, padding: 12,
...text(theme, "sans", "primary", { size: "lg" }), margin: { bottom: 8, right: 8 },
...text(theme, "sans", "secondary", { size: "xs" }),
}, },
leaderBorderOpacity: 0.7, leaderBorderOpacity: 0.7,
leaderBorderWidth: 2.0, leaderBorderWidth: 2.0,