floem/views/
drag_resize_window_area.rs1use winit::window::ResizeDirection;
2
3use crate::{
4 action::drag_resize_window,
5 event::listener,
6 style::CursorStyle,
7 view::{IntoView, View, ViewId},
8};
9
10use super::Decorators;
11
12pub struct DragResizeWindowArea {
19 id: ViewId,
20}
21
22pub fn drag_resize_window_area<V: IntoView + 'static>(
29 direction: ResizeDirection,
30 child: V,
31) -> DragResizeWindowArea {
32 let id = ViewId::new();
33 id.set_children([child.into_view()]);
34 DragResizeWindowArea { id }
35 .on_event_stop(listener::PointerDown, move |_, _| {
36 drag_resize_window(direction)
37 })
38 .style(move |s| {
39 let cursor = match direction {
40 ResizeDirection::East => CursorStyle::ColResize,
41 ResizeDirection::West => CursorStyle::ColResize,
42 ResizeDirection::North => CursorStyle::RowResize,
43 ResizeDirection::South => CursorStyle::RowResize,
44 ResizeDirection::NorthEast => CursorStyle::NeswResize,
45 ResizeDirection::SouthWest => CursorStyle::NeswResize,
46 ResizeDirection::SouthEast => CursorStyle::NwseResize,
47 ResizeDirection::NorthWest => CursorStyle::NwseResize,
48 };
49 s.cursor(cursor)
50 })
51}
52
53impl View for DragResizeWindowArea {
54 fn id(&self) -> ViewId {
55 self.id
56 }
57
58 fn debug_name(&self) -> std::borrow::Cow<'static, str> {
59 "Drag-Resize Window Area".into()
60 }
61}