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