Fix a few mouse event id bugs and move facepile to the left

co-authored-by: conrad <conrad.irwin@gmail.com>
This commit is contained in:
Mikayla 2023-10-03 19:31:55 -07:00
parent 23ee8211c7
commit 4ff80a7074
No known key found for this signature in database

View file

@ -592,6 +592,7 @@ impl CollabPanel {
*channel_id, *channel_id,
&theme.collab_panel, &theme.collab_panel,
is_selected, is_selected,
ix,
cx, cx,
), ),
ListEntry::ChannelInvite(channel) => Self::render_channel_invite( ListEntry::ChannelInvite(channel) => Self::render_channel_invite(
@ -1918,7 +1919,8 @@ impl CollabPanel {
enum ChannelCall {} enum ChannelCall {}
enum ChannelNote {} enum ChannelNote {}
enum IconTooltip {} enum NotesTooltip {}
enum ChatTooltip {}
enum ChannelTooltip {} enum ChannelTooltip {}
let mut is_dragged_over = false; let mut is_dragged_over = false;
@ -1965,13 +1967,15 @@ impl CollabPanel {
let style = collab_theme let style = collab_theme
.channel_name .channel_name
.in_state(channel.unseen_note_version.is_some()); .in_state(channel.unseen_note_version.is_some());
Flex::row()
.with_child(
Label::new(channel.name.clone(), style.text.clone()) Label::new(channel.name.clone(), style.text.clone())
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.aligned() .aligned()
.left() .left()
.with_tooltip::<ChannelTooltip>( .with_tooltip::<ChannelTooltip>(
channel_id as usize, ix,
if is_active { if is_active {
"Open channel notes" "Open channel notes"
} else { } else {
@ -1980,17 +1984,16 @@ impl CollabPanel {
None, None,
theme.tooltip.clone(), theme.tooltip.clone(),
cx, cx,
),
) )
.flex(1., true) .with_children({
})
.with_child(
MouseEventHandler::new::<ChannelCall, _>(ix, cx, move |_, cx| {
let participants = let participants =
self.channel_store.read(cx).channel_participants(channel_id); self.channel_store.read(cx).channel_participants(channel_id);
if !participants.is_empty() { if !participants.is_empty() {
let extra_count = participants.len().saturating_sub(FACEPILE_LIMIT); let extra_count = participants.len().saturating_sub(FACEPILE_LIMIT);
FacePile::new(collab_theme.face_overlap) let result = FacePile::new(collab_theme.face_overlap)
.with_children( .with_children(
participants participants
.iter() .iter()
@ -2009,53 +2012,19 @@ impl CollabPanel {
) )
.contained() .contained()
.with_style(collab_theme.extra_participant_label.container) .with_style(collab_theme.extra_participant_label.container)
})) }));
.with_tooltip::<IconTooltip>(
channel_id as usize, Some(result)
if is_active {
"Open Channel Notes"
} else { } else {
"Join channel" None
},
None,
theme.tooltip.clone(),
cx,
)
.into_any()
} else if row_hovered {
Svg::new("icons/file.svg")
.with_color(collab_theme.channel_hash.color)
.constrained()
.with_width(collab_theme.channel_hash.width)
.contained()
.with_margin_right(collab_theme.channel_hash.container.margin.left)
.with_tooltip::<IconTooltip>(
channel_id as usize,
"Open channel notes",
None,
theme.tooltip.clone(),
cx,
)
.into_any()
} else {
Empty::new().into_any()
} }
}) })
.on_click(MouseButton::Left, move |_, this, cx| { .with_spacing(8.)
let participants = .align_children_center()
this.channel_store.read(cx).channel_participants(channel_id); .flex(1., true)
if is_active || participants.is_empty() { })
this.open_channel_notes(&OpenChannelNotes { channel_id }, cx);
} else {
this.join_channel(channel_id, cx);
};
}),
)
.with_child( .with_child(
MouseEventHandler::new::<ChannelNote, _>(ix, cx, move |_, cx| { MouseEventHandler::new::<ChannelNote, _>(ix, cx, move |_, _| {
let participants =
self.channel_store.read(cx).channel_participants(channel_id);
if participants.is_empty() {
if channel.unseen_message_id.is_some() { if channel.unseen_message_id.is_some() {
Svg::new("icons/conversations.svg") Svg::new("icons/conversations.svg")
.with_color(collab_theme.channel_note_active_color) .with_color(collab_theme.channel_note_active_color)
@ -2069,14 +2038,63 @@ impl CollabPanel {
.with_width(collab_theme.channel_hash.width) .with_width(collab_theme.channel_hash.width)
.into_any() .into_any()
} else { } else {
Empty::new().into_any() Empty::new()
} .constrained()
} else { .with_width(collab_theme.channel_hash.width)
Empty::new().into_any() .into_any()
} }
}) })
.on_click(MouseButton::Left, move |_, this, cx| { .on_click(MouseButton::Left, move |_, this, cx| {
this.join_channel_chat(&JoinChannelChat { channel_id }, cx); this.join_channel_chat(&JoinChannelChat { channel_id }, cx);
})
.with_tooltip::<ChatTooltip>(
ix,
"Open channel chat",
None,
theme.tooltip.clone(),
cx,
)
.contained()
.with_margin_right(4.),
)
.with_child(
MouseEventHandler::new::<ChannelCall, _>(ix, cx, move |_, cx| {
if row_hovered || channel.unseen_note_version.is_some() {
Svg::new("icons/file.svg")
.with_color(if channel.unseen_note_version.is_some() {
collab_theme.channel_note_active_color
} else {
collab_theme.channel_hash.color
})
.constrained()
.with_width(collab_theme.channel_hash.width)
.contained()
.with_margin_right(collab_theme.channel_hash.container.margin.left)
.with_tooltip::<NotesTooltip>(
ix as usize,
"Open channel notes",
None,
theme.tooltip.clone(),
cx,
)
.into_any()
} else {
Empty::new()
.constrained()
.with_width(collab_theme.channel_hash.width)
.contained()
.with_margin_right(collab_theme.channel_hash.container.margin.left)
.into_any()
}
})
.on_click(MouseButton::Left, move |_, this, cx| {
let participants =
this.channel_store.read(cx).channel_participants(channel_id);
if is_active || participants.is_empty() {
this.open_channel_notes(&OpenChannelNotes { channel_id }, cx);
} else {
this.join_channel(channel_id, cx);
};
}), }),
) )
.align_children_center() .align_children_center()
@ -2223,6 +2241,7 @@ impl CollabPanel {
channel_id: ChannelId, channel_id: ChannelId,
theme: &theme::CollabPanel, theme: &theme::CollabPanel,
is_selected: bool, is_selected: bool,
ix: usize,
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
) -> AnyElement<Self> { ) -> AnyElement<Self> {
enum ChannelNotes {} enum ChannelNotes {}
@ -2232,7 +2251,7 @@ impl CollabPanel {
.or(theme.contact_avatar.height) .or(theme.contact_avatar.height)
.unwrap_or(0.); .unwrap_or(0.);
MouseEventHandler::new::<ChannelNotes, _>(channel_id as usize, cx, |state, cx| { MouseEventHandler::new::<ChannelNotes, _>(ix as usize, cx, |state, cx| {
let tree_branch = *theme.tree_branch.in_state(is_selected).style_for(state); let tree_branch = *theme.tree_branch.in_state(is_selected).style_for(state);
let row = theme.project_row.in_state(is_selected).style_for(state); let row = theme.project_row.in_state(is_selected).style_for(state);