Merge branch 'main' into perf-2
This commit is contained in:
commit
8418f25d0a
3 changed files with 33 additions and 20 deletions
|
@ -27,7 +27,7 @@ impl IntoElement for Canvas {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Element for Canvas {
|
impl Element for Canvas {
|
||||||
type State = ();
|
type State = Style;
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -37,11 +37,13 @@ impl Element for Canvas {
|
||||||
let mut style = Style::default();
|
let mut style = Style::default();
|
||||||
style.refine(&self.style);
|
style.refine(&self.style);
|
||||||
let layout_id = cx.request_layout(&style, []);
|
let layout_id = cx.request_layout(&style, []);
|
||||||
(layout_id, ())
|
(layout_id, style)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint(&mut self, bounds: Bounds<Pixels>, _: &mut (), cx: &mut WindowContext) {
|
fn paint(&mut self, bounds: Bounds<Pixels>, style: &mut Style, cx: &mut WindowContext) {
|
||||||
|
style.paint(bounds, cx, |cx| {
|
||||||
(self.paint_callback.take().unwrap())(&bounds, cx)
|
(self.paint_callback.take().unwrap())(&bounds, cx)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ impl Interactivity {
|
||||||
if cx
|
if cx
|
||||||
.active_drag
|
.active_drag
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.is_some_and(|drag| drag.value.type_id() == TypeId::of::<T>())
|
.is_some_and(|drag| (*drag.value).type_id() == TypeId::of::<T>())
|
||||||
{
|
{
|
||||||
(listener)(
|
(listener)(
|
||||||
&DragMoveEvent {
|
&DragMoveEvent {
|
||||||
|
@ -432,7 +432,7 @@ pub trait InteractiveElement: Sized {
|
||||||
listener: impl Fn(&DragMoveEvent<T>, &mut WindowContext) + 'static,
|
listener: impl Fn(&DragMoveEvent<T>, &mut WindowContext) + 'static,
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
T: Render,
|
T: 'static,
|
||||||
{
|
{
|
||||||
self.interactivity().on_drag_move(listener);
|
self.interactivity().on_drag_move(listener);
|
||||||
self
|
self
|
||||||
|
|
|
@ -486,12 +486,9 @@ impl Render for Dock {
|
||||||
if let Some(entry) = self.visible_entry() {
|
if let Some(entry) = self.visible_entry() {
|
||||||
let size = entry.panel.size(cx);
|
let size = entry.panel.size(cx);
|
||||||
|
|
||||||
let mut pre_resize_handle = None;
|
|
||||||
let mut post_resize_handle = None;
|
|
||||||
let position = self.position;
|
let position = self.position;
|
||||||
let handler = div()
|
let mut handle = div()
|
||||||
.id("resize-handle")
|
.id("resize-handle")
|
||||||
.bg(cx.theme().colors().border)
|
|
||||||
.on_drag(DraggedDock(position), |dock, cx| {
|
.on_drag(DraggedDock(position), |dock, cx| {
|
||||||
cx.build_view(|_| dock.clone())
|
cx.build_view(|_| dock.clone())
|
||||||
})
|
})
|
||||||
|
@ -506,16 +503,31 @@ impl Render for Dock {
|
||||||
|
|
||||||
match self.position() {
|
match self.position() {
|
||||||
DockPosition::Left => {
|
DockPosition::Left => {
|
||||||
post_resize_handle =
|
handle = handle
|
||||||
Some(handler.min_w(HANDLE_SIZE).h_full().cursor_col_resize())
|
.absolute()
|
||||||
|
.right(px(0.))
|
||||||
|
.top(px(0.))
|
||||||
|
.h_full()
|
||||||
|
.w(HANDLE_SIZE)
|
||||||
|
.cursor_col_resize();
|
||||||
}
|
}
|
||||||
DockPosition::Bottom => {
|
DockPosition::Bottom => {
|
||||||
pre_resize_handle =
|
handle = handle
|
||||||
Some(handler.w_full().min_h(HANDLE_SIZE).cursor_row_resize())
|
.absolute()
|
||||||
|
.top(px(0.))
|
||||||
|
.left(px(0.))
|
||||||
|
.w_full()
|
||||||
|
.h(HANDLE_SIZE)
|
||||||
|
.cursor_row_resize();
|
||||||
}
|
}
|
||||||
DockPosition::Right => {
|
DockPosition::Right => {
|
||||||
pre_resize_handle =
|
handle = handle
|
||||||
Some(handler.min_w(HANDLE_SIZE).h_full().cursor_col_resize())
|
.absolute()
|
||||||
|
.top(px(0.))
|
||||||
|
.left(px(0.))
|
||||||
|
.w_full()
|
||||||
|
.h(HANDLE_SIZE)
|
||||||
|
.cursor_col_resize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,16 +543,15 @@ impl Render for Dock {
|
||||||
DockPosition::Right => this.border_l(),
|
DockPosition::Right => this.border_l(),
|
||||||
DockPosition::Bottom => this.border_t(),
|
DockPosition::Bottom => this.border_t(),
|
||||||
})
|
})
|
||||||
.children(pre_resize_handle)
|
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.map(|this| match self.position().axis() {
|
.map(|this| match self.position().axis() {
|
||||||
Axis::Horizontal => this.min_w(px(size) - HANDLE_SIZE).h_full(),
|
Axis::Horizontal => this.min_w(px(size)).h_full(),
|
||||||
Axis::Vertical => this.min_h(px(size) - HANDLE_SIZE).w_full(),
|
Axis::Vertical => this.min_h(px(size)).w_full(),
|
||||||
})
|
})
|
||||||
.child(entry.panel.to_any()),
|
.child(entry.panel.to_any()),
|
||||||
)
|
)
|
||||||
.children(post_resize_handle)
|
.child(handle)
|
||||||
} else {
|
} else {
|
||||||
div()
|
div()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue