Re-enable navigation with mouse navigation buttons

This commit is contained in:
Piotr Osiewicz 2023-12-08 17:59:52 +01:00
parent 5e3d0a6d03
commit a283cbaf8f

View file

@ -9,8 +9,8 @@ use collections::{HashMap, HashSet, VecDeque};
use gpui::{
actions, overlay, prelude::*, rems, Action, AnchorCorner, AnyWeakView, AppContext,
AsyncWindowContext, DismissEvent, Div, EntityId, EventEmitter, FocusHandle, Focusable,
FocusableView, Model, Pixels, Point, PromptLevel, Render, Task, View, ViewContext,
VisualContext, WeakView, WindowContext,
FocusableView, Model, MouseButton, NavigationDirection, Pixels, Point, PromptLevel, Render,
Task, View, ViewContext, VisualContext, WeakView, WindowContext,
};
use parking_lot::Mutex;
use project::{Project, ProjectEntryId, ProjectPath};
@ -2139,19 +2139,14 @@ impl Render for Pane {
.justify_center()
.child(Label::new("Open a file or project to get started.").color(Color::Muted))
})
// enum MouseNavigationHandler {}
// MouseEventHandler::new::<MouseNavigationHandler, _>(0, cx, |_, cx| {
// let active_item_index = self.active_item_index;
// if let Some(active_item) = self.active_item() {
// Flex::column()
// .with_child({
// let theme = theme::current(cx).clone();
// let mut stack = Stack::new();
// enum TabBarEventHandler {}
// stack.add_child(
// MouseEventHandler::new::<TabBarEventHandler, _>(0, cx, |_, _| {
@ -2168,7 +2163,6 @@ impl Render for Pane {
// );
// let tooltip_style = theme.tooltip.clone();
// let tab_bar_theme = theme.workspace.tab_bar.clone();
// let nav_button_height = tab_bar_theme.height;
// let button_style = tab_bar_theme.nav_button;
// let border_for_nav_buttons = tab_bar_theme
@ -2176,7 +2170,6 @@ impl Render for Pane {
// .container
// .border
// .clone();
// let mut tab_row = Flex::row()
// .with_child(nav_button(
// "icons/arrow_left.svg",
@ -2231,7 +2224,6 @@ impl Render for Pane {
// .with_border(border_for_nav_buttons),
// )
// .with_child(self.render_tabs(cx).flex(1., true).into_any_named("tabs"));
// if self.has_focus {
// let render_tab_bar_buttons = self.render_tab_bar_buttons.clone();
// tab_row.add_child(
@ -2242,7 +2234,6 @@ impl Render for Pane {
// .into_any(),
// )
// }
// stack.add_child(tab_row);
// stack
// .constrained()
@ -2281,7 +2272,6 @@ impl Render for Pane {
// } else {
// enum EmptyPane {}
// let theme = theme::current(cx).clone();
// dragged_item_receiver::<EmptyPane, _, _>(self, 0, 0, false, None, cx, |_, cx| {
// self.render_blank_pane(&theme, cx)
// })
@ -2291,31 +2281,32 @@ impl Render for Pane {
// .into_any()
// }
// })
// .on_down(
// MouseButton::Navigate(NavigationDirection::Back),
// move |_, pane, cx| {
// if let Some(workspace) = pane.workspace.upgrade(cx) {
// let pane = cx.weak_handle();
// cx.window_context().defer(move |cx| {
// workspace.update(cx, |workspace, cx| {
// workspace.go_back(pane, cx).detach_and_log_err(cx)
// })
// })
// }
// },
// )
// .on_down(MouseButton::Navigate(NavigationDirection::Forward), {
// move |_, pane, cx| {
// if let Some(workspace) = pane.workspace.upgrade(cx) {
// let pane = cx.weak_handle();
// cx.window_context().defer(move |cx| {
// workspace.update(cx, |workspace, cx| {
// workspace.go_forward(pane, cx).detach_and_log_err(cx)
// })
// })
// }
// }
// })
.on_mouse_down(
MouseButton::Navigate(NavigationDirection::Back),
cx.listener(|pane, _, cx| {
if let Some(workspace) = pane.workspace.upgrade() {
let pane = cx.view().downgrade();
cx.window_context().defer(move |cx| {
workspace.update(cx, |workspace, cx| {
workspace.go_back(pane, cx).detach_and_log_err(cx)
})
})
}
}),
)
.on_mouse_down(
MouseButton::Navigate(NavigationDirection::Forward),
cx.listener(|pane, _, cx| {
if let Some(workspace) = pane.workspace.upgrade() {
let pane = cx.view().downgrade();
cx.window_context().defer(move |cx| {
workspace.update(cx, |workspace, cx| {
workspace.go_forward(pane, cx).detach_and_log_err(cx)
})
})
}
}),
)
// .into_any_named("pane")
}