From 6b26965074faa9793cb28e05ab816bb917e76102 Mon Sep 17 00:00:00 2001 From: K Simmons Date: Fri, 9 Sep 2022 17:29:52 -0700 Subject: [PATCH] Permanent fix to repeat MouseRegion Tag failure in Workspace Polish tab bar buttons Co-Authored-By: Mikayla Maki --- .../src/activity_indicator.rs | 2 +- crates/auto_update/src/update_notification.rs | 4 +- crates/chat_panel/src/chat_panel.rs | 2 +- crates/contacts_panel/src/contacts_panel.rs | 68 ++-- crates/contacts_panel/src/notifications.rs | 4 +- crates/context_menu/src/context_menu.rs | 24 +- crates/diagnostics/src/items.rs | 4 +- crates/drag_and_drop/src/drag_and_drop.rs | 5 +- crates/editor/src/editor.rs | 8 +- crates/editor/src/element.rs | 2 +- crates/editor/src/hover_popover.rs | 4 +- crates/editor/src/mouse_context_menu.rs | 6 +- crates/gpui/src/app.rs | 13 +- crates/gpui/src/elements.rs | 7 +- crates/gpui/src/elements/event_handler.rs | 179 ---------- .../gpui/src/elements/mouse_event_handler.rs | 35 +- crates/gpui/src/elements/overlay.rs | 171 +++++++--- crates/gpui/src/elements/tooltip.rs | 53 ++- crates/gpui/src/presenter.rs | 10 +- crates/gpui/src/scene.rs | 32 +- crates/gpui/src/scene/mouse_region.rs | 42 ++- crates/gpui/src/views/select.rs | 30 +- crates/picker/src/picker.rs | 2 +- crates/project_panel/src/project_panel.rs | 10 +- crates/search/src/buffer_search.rs | 4 +- crates/search/src/project_search.rs | 6 +- crates/terminal/src/terminal_view.rs | 7 +- crates/workspace/src/dock.rs | 20 +- crates/workspace/src/pane.rs | 311 ++++++++++-------- crates/workspace/src/sidebar.rs | 4 +- crates/workspace/src/toolbar.rs | 2 +- crates/workspace/src/workspace.rs | 14 +- crates/zed/src/feedback.rs | 2 +- 33 files changed, 542 insertions(+), 545 deletions(-) delete mode 100644 crates/gpui/src/elements/event_handler.rs diff --git a/crates/activity_indicator/src/activity_indicator.rs b/crates/activity_indicator/src/activity_indicator.rs index 7d4d01e8a1..8f6f4bf627 100644 --- a/crates/activity_indicator/src/activity_indicator.rs +++ b/crates/activity_indicator/src/activity_indicator.rs @@ -278,7 +278,7 @@ impl View for ActivityIndicator { fn render(&mut self, cx: &mut RenderContext) -> ElementBox { let (icon, message, action) = self.content_to_render(cx); - let mut element = MouseEventHandler::new::(0, cx, |state, cx| { + let mut element = MouseEventHandler::::new(0, cx, |state, cx| { let theme = &cx .global::() .theme diff --git a/crates/auto_update/src/update_notification.rs b/crates/auto_update/src/update_notification.rs index b0dff3e40c..bbc9b0ea7f 100644 --- a/crates/auto_update/src/update_notification.rs +++ b/crates/auto_update/src/update_notification.rs @@ -29,7 +29,7 @@ impl View for UpdateNotification { let theme = cx.global::().theme.clone(); let theme = &theme.update_notification; - MouseEventHandler::new::(0, cx, |state, cx| { + MouseEventHandler::::new(0, cx, |state, cx| { Flex::column() .with_child( Flex::row() @@ -47,7 +47,7 @@ impl View for UpdateNotification { .boxed(), ) .with_child( - MouseEventHandler::new::(0, cx, |state, _| { + MouseEventHandler::::new(0, cx, |state, _| { let style = theme.dismiss_button.style_for(state, false); Svg::new("icons/x_mark_thin_8.svg") .with_color(style.color) diff --git a/crates/chat_panel/src/chat_panel.rs b/crates/chat_panel/src/chat_panel.rs index 3ff7062f40..6744ae9339 100644 --- a/crates/chat_panel/src/chat_panel.rs +++ b/crates/chat_panel/src/chat_panel.rs @@ -308,7 +308,7 @@ impl ChatPanel { enum SignInPromptLabel {} Align::new( - MouseEventHandler::new::(0, cx, |mouse_state, _| { + MouseEventHandler::::new(0, cx, |mouse_state, _| { Label::new( "Sign in to use chat".to_string(), if mouse_state.hovered { diff --git a/crates/contacts_panel/src/contacts_panel.rs b/crates/contacts_panel/src/contacts_panel.rs index 672730cf22..b5460f4d06 100644 --- a/crates/contacts_panel/src/contacts_panel.rs +++ b/crates/contacts_panel/src/contacts_panel.rs @@ -276,7 +276,7 @@ impl ContactsPanel { Section::Offline => "Offline", }; let icon_size = theme.section_icon_size; - MouseEventHandler::new::(section as usize, cx, |_, _| { + MouseEventHandler::
::new(section as usize, cx, |_, _| { Flex::row() .with_child( Svg::new(if is_collapsed { @@ -375,7 +375,7 @@ impl ContactsPanel { let baseline_offset = row.name.text.baseline_offset(font_cache) + (theme.row_height - line_height) / 2.; - MouseEventHandler::new::(project_id as usize, cx, |mouse_state, cx| { + MouseEventHandler::::new(project_id as usize, cx, |mouse_state, cx| { let tree_branch = *tree_branch.style_for(mouse_state, is_selected); let row = theme.project_row.style_for(mouse_state, is_selected); @@ -424,7 +424,7 @@ impl ContactsPanel { return None; } - let button = MouseEventHandler::new::( + let button = MouseEventHandler::::new( project_id as usize, cx, |state, _| { @@ -529,7 +529,7 @@ impl ContactsPanel { enum ToggleOnline {} let project_id = project_handle.id(); - MouseEventHandler::new::(project_id, cx, |state, cx| { + MouseEventHandler::::new(project_id, cx, |state, cx| { let row = theme.project_row.style_for(state, is_selected); let mut worktree_root_names = String::new(); let project = if let Some(project) = project_handle.upgrade(cx.deref_mut()) { @@ -548,7 +548,7 @@ impl ContactsPanel { Flex::row() .with_child({ let button = - MouseEventHandler::new::(project_id, cx, |state, _| { + MouseEventHandler::::new(project_id, cx, |state, _| { let mut style = *theme.private_button.style_for(state, false); if is_going_online { style.color = theme.disabled_button.color; @@ -636,7 +636,7 @@ impl ContactsPanel { if is_incoming { row.add_children([ - MouseEventHandler::new::(user.id as usize, cx, |mouse_state, _| { + MouseEventHandler::::new(user.id as usize, cx, |mouse_state, _| { let button_style = if is_contact_request_pending { &theme.disabled_button } else { @@ -658,7 +658,7 @@ impl ContactsPanel { .contained() .with_margin_right(button_spacing) .boxed(), - MouseEventHandler::new::(user.id as usize, cx, |mouse_state, _| { + MouseEventHandler::::new(user.id as usize, cx, |mouse_state, _| { let button_style = if is_contact_request_pending { &theme.disabled_button } else { @@ -680,7 +680,7 @@ impl ContactsPanel { ]); } else { row.add_child( - MouseEventHandler::new::(user.id as usize, cx, |mouse_state, _| { + MouseEventHandler::::new(user.id as usize, cx, |mouse_state, _| { let button_style = if is_contact_request_pending { &theme.disabled_button } else { @@ -1071,7 +1071,7 @@ impl View for ContactsPanel { .boxed(), ) .with_child( - MouseEventHandler::new::(0, cx, |_, _| { + MouseEventHandler::::new(0, cx, |_, _| { Svg::new("icons/user_plus_16.svg") .with_color(theme.add_contact_button.color) .constrained() @@ -1102,35 +1102,31 @@ impl View for ContactsPanel { if info.count > 0 { Some( - MouseEventHandler::new::( - 0, - cx, - |state, cx| { - let style = - theme.invite_row.style_for(state, false).clone(); + MouseEventHandler::::new(0, cx, |state, cx| { + let style = + theme.invite_row.style_for(state, false).clone(); - let copied = - cx.read_from_clipboard().map_or(false, |item| { - item.text().as_str() == info.url.as_ref() - }); + let copied = + cx.read_from_clipboard().map_or(false, |item| { + item.text().as_str() == info.url.as_ref() + }); - Label::new( - format!( - "{} invite link ({} left)", - if copied { "Copied" } else { "Copy" }, - info.count - ), - style.label.clone(), - ) - .aligned() - .left() - .constrained() - .with_height(theme.row_height) - .contained() - .with_style(style.container) - .boxed() - }, - ) + Label::new( + format!( + "{} invite link ({} left)", + if copied { "Copied" } else { "Copy" }, + info.count + ), + style.label.clone(), + ) + .aligned() + .left() + .constrained() + .with_height(theme.row_height) + .contained() + .with_style(style.container) + .boxed() + }) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, move |_, cx| { cx.write_to_clipboard(ClipboardItem::new( diff --git a/crates/contacts_panel/src/notifications.rs b/crates/contacts_panel/src/notifications.rs index 4cc30560d2..b9a6dba545 100644 --- a/crates/contacts_panel/src/notifications.rs +++ b/crates/contacts_panel/src/notifications.rs @@ -52,7 +52,7 @@ pub fn render_user_notification( .boxed(), ) .with_child( - MouseEventHandler::new::(user.id as usize, cx, |state, _| { + MouseEventHandler::::new(user.id as usize, cx, |state, _| { render_icon_button( theme.dismiss_button.style_for(state, false), "icons/x_mark_thin_8.svg", @@ -90,7 +90,7 @@ pub fn render_user_notification( Flex::row() .with_children(buttons.into_iter().enumerate().map( |(ix, (message, action))| { - MouseEventHandler::new::(ix, cx, |state, _| { + MouseEventHandler::