Add more debugging
This commit is contained in:
parent
2ee0ecb677
commit
735f2029e9
3 changed files with 87 additions and 63 deletions
|
@ -1,10 +1,10 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
green, point, px, red, Action, AnyDrag, AnyDragState, AnyElement, AnyTooltip, AnyView,
|
point, px, Action, AnyDrag, AnyDragState, AnyElement, AnyTooltip, AnyView, AppContext,
|
||||||
AppContext, BorrowAppContext, BorrowWindow, Bounds, ClickEvent, DispatchPhase, Element,
|
BorrowAppContext, BorrowWindow, Bounds, ClickEvent, DispatchPhase, Element, ElementId,
|
||||||
ElementId, FocusEvent, FocusHandle, IntoElement, KeyContext, KeyDownEvent, KeyUpEvent,
|
FocusEvent, FocusHandle, IntoElement, KeyContext, KeyDownEvent, KeyUpEvent, LayoutId,
|
||||||
LayoutId, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels,
|
MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point,
|
||||||
Point, Render, ScrollWheelEvent, SharedString, Size, StackingOrder, Style, StyleRefinement,
|
Render, ScrollWheelEvent, SharedString, Size, StackingOrder, Style, StyleRefinement, Styled,
|
||||||
Styled, Task, View, Visibility, WindowContext,
|
Task, View, Visibility, WindowContext,
|
||||||
};
|
};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use refineable::Refineable;
|
use refineable::Refineable;
|
||||||
|
@ -95,6 +95,32 @@ pub trait InteractiveElement: Sized + Element {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn on_mouse_down_weird(
|
||||||
|
mut self,
|
||||||
|
button: MouseButton,
|
||||||
|
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
|
||||||
|
) -> Self {
|
||||||
|
self.interactivity().mouse_down_listeners.push(Box::new(
|
||||||
|
move |event, bounds, phase, cx| {
|
||||||
|
dbg!("HEREEEE");
|
||||||
|
|
||||||
|
let contains = dbg!(dbg!(&bounds.bounds).contains_point(dbg!(&event.position)))
|
||||||
|
&& dbg!(cx.was_top_layer(&event.position, &bounds.stacking_order));
|
||||||
|
dbg!(contains);
|
||||||
|
|
||||||
|
if phase == DispatchPhase::Bubble
|
||||||
|
&& event.button == button
|
||||||
|
&& bounds.visibly_contains(&event.position, cx)
|
||||||
|
{
|
||||||
|
dbg!("HEREEEE2");
|
||||||
|
|
||||||
|
(listener)(event, cx)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn on_any_mouse_down(
|
fn on_any_mouse_down(
|
||||||
mut self,
|
mut self,
|
||||||
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
|
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
|
||||||
|
@ -767,7 +793,7 @@ pub struct Interactivity {
|
||||||
pub tooltip_builder: Option<TooltipBuilder>,
|
pub tooltip_builder: Option<TooltipBuilder>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct InteractiveBounds {
|
pub struct InteractiveBounds {
|
||||||
pub bounds: Bounds<Pixels>,
|
pub bounds: Bounds<Pixels>,
|
||||||
pub stacking_order: StackingOrder,
|
pub stacking_order: StackingOrder,
|
||||||
|
|
|
@ -638,7 +638,7 @@ impl TerminalElement {
|
||||||
let connection = self.terminal.clone();
|
let connection = self.terminal.clone();
|
||||||
|
|
||||||
let mut this = self
|
let mut this = self
|
||||||
.on_mouse_down(MouseButton::Left, {
|
.on_mouse_down_weird(MouseButton::Left, {
|
||||||
let connection = connection.clone();
|
let connection = connection.clone();
|
||||||
let focus = focus.clone();
|
let focus = focus.clone();
|
||||||
move |e, cx| {
|
move |e, cx| {
|
||||||
|
@ -814,6 +814,7 @@ impl Element for TerminalElement {
|
||||||
state: &mut Self::State,
|
state: &mut Self::State,
|
||||||
cx: &mut WindowContext<'_>,
|
cx: &mut WindowContext<'_>,
|
||||||
) {
|
) {
|
||||||
|
dbg!(bounds);
|
||||||
let mut layout = self.compute_layout(bounds, cx);
|
let mut layout = self.compute_layout(bounds, cx);
|
||||||
|
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
|
@ -832,54 +833,51 @@ impl Element for TerminalElement {
|
||||||
let mut this = self.register_mouse_listeners(origin, layout.mode, bounds, cx);
|
let mut this = self.register_mouse_listeners(origin, layout.mode, bounds, cx);
|
||||||
let interactivity = mem::take(&mut this.interactivity);
|
let interactivity = mem::take(&mut this.interactivity);
|
||||||
|
|
||||||
cx.with_z_index(0, |cx| {
|
interactivity.paint(bounds, bounds.size, state, cx, |_, _, cx| {
|
||||||
interactivity.paint(bounds, bounds.size, state, cx, |_, _, cx| {
|
this.register_key_listeners(cx);
|
||||||
this.register_key_listeners(cx);
|
|
||||||
|
|
||||||
for rect in &layout.rects {
|
for rect in &layout.rects {
|
||||||
rect.paint(origin, &layout, cx);
|
rect.paint(origin, &layout, cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.with_z_index(1, |cx| {
|
cx.with_z_index(1, |cx| {
|
||||||
for (relative_highlighted_range, color) in
|
for (relative_highlighted_range, color) in layout.relative_highlighted_ranges.iter()
|
||||||
layout.relative_highlighted_ranges.iter()
|
{
|
||||||
|
if let Some((start_y, highlighted_range_lines)) =
|
||||||
|
to_highlighted_range_lines(relative_highlighted_range, &layout, origin)
|
||||||
{
|
{
|
||||||
if let Some((start_y, highlighted_range_lines)) =
|
let hr = HighlightedRange {
|
||||||
to_highlighted_range_lines(relative_highlighted_range, &layout, origin)
|
start_y, //Need to change this
|
||||||
{
|
line_height: layout.size.line_height,
|
||||||
let hr = HighlightedRange {
|
lines: highlighted_range_lines,
|
||||||
start_y, //Need to change this
|
color: color.clone(),
|
||||||
line_height: layout.size.line_height,
|
//Copied from editor. TODO: move to theme or something
|
||||||
lines: highlighted_range_lines,
|
corner_radius: 0.15 * layout.size.line_height,
|
||||||
color: color.clone(),
|
};
|
||||||
//Copied from editor. TODO: move to theme or something
|
hr.paint(bounds, cx);
|
||||||
corner_radius: 0.15 * layout.size.line_height,
|
|
||||||
};
|
|
||||||
hr.paint(bounds, cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
cx.with_z_index(2, |cx| {
|
|
||||||
for cell in &layout.cells {
|
|
||||||
cell.paint(origin, &layout, bounds, cx);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if this.cursor_visible {
|
|
||||||
cx.with_z_index(3, |cx| {
|
|
||||||
if let Some(cursor) = &layout.cursor {
|
|
||||||
cursor.paint(origin, cx);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(element) = layout.hyperlink_tooltip.take() {
|
|
||||||
let width: AvailableSpace = bounds.size.width.into();
|
|
||||||
let height: AvailableSpace = bounds.size.height.into();
|
|
||||||
element.draw(origin, Size { width, height }, cx)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cx.with_z_index(2, |cx| {
|
||||||
|
for cell in &layout.cells {
|
||||||
|
cell.paint(origin, &layout, bounds, cx);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if this.cursor_visible {
|
||||||
|
cx.with_z_index(3, |cx| {
|
||||||
|
if let Some(cursor) = &layout.cursor {
|
||||||
|
cursor.paint(origin, cx);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(element) = layout.hyperlink_tooltip.take() {
|
||||||
|
let width: AvailableSpace = bounds.size.width.into();
|
||||||
|
let height: AvailableSpace = bounds.size.height.into();
|
||||||
|
element.draw(origin, Size { width, height }, cx)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,18 +266,18 @@ impl TerminalView {
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
let focus = cx.focus_handle();
|
let focus = cx.focus_handle();
|
||||||
let focus_in = cx.on_focus_in(&focus, |this, cx| {
|
// let focus_in = cx.on_focus_in(&focus, |this, cx| {
|
||||||
this.has_new_content = false;
|
// this.has_new_content = false;
|
||||||
this.terminal.read(cx).focus_in();
|
// this.terminal.read(cx).focus_in();
|
||||||
this.blink_cursors(this.blink_epoch, cx);
|
// this.blink_cursors(this.blink_epoch, cx);
|
||||||
cx.notify();
|
// cx.notify();
|
||||||
});
|
// });
|
||||||
let focus_out = cx.on_focus_out(&focus, |this, cx| {
|
// let focus_out = cx.on_focus_out(&focus, |this, cx| {
|
||||||
this.terminal.update(cx, |terminal, _| {
|
// this.terminal.update(cx, |terminal, _| {
|
||||||
terminal.focus_out();
|
// terminal.focus_out();
|
||||||
});
|
// });
|
||||||
cx.notify();
|
// cx.notify();
|
||||||
});
|
// });
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
terminal,
|
terminal,
|
||||||
|
@ -291,7 +291,7 @@ impl TerminalView {
|
||||||
blink_epoch: 0,
|
blink_epoch: 0,
|
||||||
can_navigate_to_selected_word: false,
|
can_navigate_to_selected_word: false,
|
||||||
workspace_id,
|
workspace_id,
|
||||||
_subscriptions: vec![focus_in, focus_out],
|
_subscriptions: vec![/*focus_in, focus_out*/],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue