Highlight termina on external files drag and drop
This commit is contained in:
parent
3d5b903f78
commit
6c4670287d
2 changed files with 13 additions and 22 deletions
|
@ -4,8 +4,9 @@ use gpui::{
|
||||||
BorrowWindow, Bounds, DispatchPhase, Element, ElementId, ExternalPaths, FocusHandle, Font,
|
BorrowWindow, Bounds, DispatchPhase, Element, ElementId, ExternalPaths, FocusHandle, Font,
|
||||||
FontStyle, FontWeight, HighlightStyle, Hsla, InteractiveElement, InteractiveElementState,
|
FontStyle, FontWeight, HighlightStyle, Hsla, InteractiveElement, InteractiveElementState,
|
||||||
Interactivity, IntoElement, LayoutId, Model, ModelContext, ModifiersChangedEvent, MouseButton,
|
Interactivity, IntoElement, LayoutId, Model, ModelContext, ModifiersChangedEvent, MouseButton,
|
||||||
Pixels, PlatformInputHandler, Point, Rgba, ShapedLine, StatefulInteractiveElement, Styled,
|
Pixels, PlatformInputHandler, Point, Rgba, ShapedLine, StatefulInteractiveElement,
|
||||||
TextRun, TextStyle, TextSystem, UnderlineStyle, WhiteSpace, WindowContext,
|
StyleRefinement, Styled, TextRun, TextStyle, TextSystem, UnderlineStyle, WhiteSpace,
|
||||||
|
WindowContext,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use language::CursorShape;
|
use language::CursorShape;
|
||||||
|
@ -24,7 +25,7 @@ use terminal::{
|
||||||
use theme::{ActiveTheme, Theme, ThemeSettings};
|
use theme::{ActiveTheme, Theme, ThemeSettings};
|
||||||
use ui::Tooltip;
|
use ui::Tooltip;
|
||||||
|
|
||||||
use std::mem;
|
use std::{any::TypeId, mem};
|
||||||
use std::{fmt::Debug, ops::RangeInclusive};
|
use std::{fmt::Debug, ops::RangeInclusive};
|
||||||
|
|
||||||
///The information generated during layout that is necessary for painting
|
///The information generated during layout that is necessary for painting
|
||||||
|
@ -689,6 +690,10 @@ impl TerminalElement {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.interactivity.drag_over_styles.push((
|
||||||
|
TypeId::of::<ExternalPaths>(),
|
||||||
|
StyleRefinement::default().bg(cx.theme().colors().drop_target_background),
|
||||||
|
));
|
||||||
self.interactivity.on_drop::<ExternalPaths>({
|
self.interactivity.on_drop::<ExternalPaths>({
|
||||||
let focus = focus.clone();
|
let focus = focus.clone();
|
||||||
let terminal = terminal.clone();
|
let terminal = terminal.clone();
|
||||||
|
@ -787,8 +792,6 @@ impl Element for TerminalElement {
|
||||||
) {
|
) {
|
||||||
let mut layout = self.compute_layout(bounds, cx);
|
let mut layout = self.compute_layout(bounds, cx);
|
||||||
|
|
||||||
let theme = cx.theme();
|
|
||||||
|
|
||||||
cx.paint_quad(fill(bounds, layout.background_color));
|
cx.paint_quad(fill(bounds, layout.background_color));
|
||||||
let origin = bounds.origin + Point::new(layout.gutter, px(0.));
|
let origin = bounds.origin + Point::new(layout.gutter, px(0.));
|
||||||
|
|
||||||
|
@ -801,16 +804,8 @@ impl Element for TerminalElement {
|
||||||
.map(|cursor| cursor.bounding_rect(origin)),
|
.map(|cursor| cursor.bounding_rect(origin)),
|
||||||
};
|
};
|
||||||
|
|
||||||
let terminal_focus_handle = self.focus.clone();
|
|
||||||
let terminal_handle = self.terminal.clone();
|
|
||||||
self.register_mouse_listeners(origin, layout.mode, bounds, cx);
|
self.register_mouse_listeners(origin, layout.mode, bounds, cx);
|
||||||
|
|
||||||
// todo!(change this to work in terms of on_drag_move or some such)
|
|
||||||
// .drag_over::<ExternalPaths>(|style| {
|
|
||||||
// // todo!() why does not it work? z-index of elements?
|
|
||||||
// style.bg(cx.theme().colors().ghost_element_hover)
|
|
||||||
// })
|
|
||||||
|
|
||||||
let mut interactivity = mem::take(&mut self.interactivity);
|
let mut interactivity = mem::take(&mut self.interactivity);
|
||||||
interactivity.paint(bounds, bounds.size, state, cx, |_, _, cx| {
|
interactivity.paint(bounds, bounds.size, state, cx, |_, _, cx| {
|
||||||
cx.handle_input(&self.focus, terminal_input_handler);
|
cx.handle_input(&self.focus, terminal_input_handler);
|
||||||
|
|
|
@ -4,8 +4,8 @@ use crate::TerminalView;
|
||||||
use db::kvp::KEY_VALUE_STORE;
|
use db::kvp::KEY_VALUE_STORE;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, div, serde_json, AppContext, AsyncWindowContext, Div, Entity, EventEmitter,
|
actions, div, serde_json, AppContext, AsyncWindowContext, Div, Entity, EventEmitter,
|
||||||
FocusHandle, FocusableView, ParentElement, Render, Styled, Subscription, Task, View,
|
ExternalPaths, FocusHandle, FocusableView, ParentElement, Render, Styled, Subscription, Task,
|
||||||
ViewContext, VisualContext, WeakView, WindowContext,
|
View, ViewContext, VisualContext, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use project::Fs;
|
use project::Fs;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -64,6 +64,9 @@ impl TerminalPanel {
|
||||||
return item.downcast::<TerminalView>().is_some();
|
return item.downcast::<TerminalView>().is_some();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if a.downcast_ref::<ExternalPaths>().is_some() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
false
|
false
|
||||||
})),
|
})),
|
||||||
|
@ -72,13 +75,6 @@ impl TerminalPanel {
|
||||||
pane.set_can_split(false, cx);
|
pane.set_can_split(false, cx);
|
||||||
pane.set_can_navigate(false, cx);
|
pane.set_can_navigate(false, cx);
|
||||||
// todo!()
|
// todo!()
|
||||||
// pane.on_can_drop(move |drag_and_drop, cx| {
|
|
||||||
// drag_and_drop
|
|
||||||
// .currently_dragged::<DraggedItem>(window)
|
|
||||||
// .map_or(false, |(_, item)| {
|
|
||||||
// item.handle.act_as::<TerminalView>(cx).is_some()
|
|
||||||
// })
|
|
||||||
// });
|
|
||||||
// pane.set_render_tab_bar_buttons(cx, move |pane, cx| {
|
// pane.set_render_tab_bar_buttons(cx, move |pane, cx| {
|
||||||
// let this = weak_self.clone();
|
// let this = weak_self.clone();
|
||||||
// Flex::row()
|
// Flex::row()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue