Resizable sizes a box from its right and bottom edges and a grip at its corner, within its least and greatest size; the grip is a Tab stop whose arrows resize a step. Rotatable turns an svg to its angle inside a ring whose knob a drag moves, Shift snapping to 15 degrees, with the arrows turning it a notch. SelectionArea selects items with a band drawn on empty space, a press, Command or Shift to add, and a cursor the arrows walk with Space to add or drop; Escape clears and Command-A takes all. The gallery shows gpui's own drag and drop, drag preview, double press and wheel zoom, with pointers for Sortable, LongPress and PanZoom; pinch stays blocked, gpui 0.2.2 forwards no magnify event.
36 lines
975 B
Rust
36 lines
975 B
Rust
use gpui::{AnyElement, App, Window, div, prelude::*};
|
|
|
|
mod pointer;
|
|
|
|
use super::Page;
|
|
use crate::script::Step;
|
|
|
|
pub const PAGE: Page = Page {
|
|
number: 38,
|
|
slug: "interaction",
|
|
title: "Interaction",
|
|
summary: "Drag and drop, resizing and turning, band selection, presses and gestures.",
|
|
render,
|
|
script: SCRIPT,
|
|
};
|
|
|
|
const SCRIPT: &[Step] = &[
|
|
Step::DownAt("interaction-tiles", 296.0, 6.0),
|
|
Step::DragTo("interaction-tiles", 120.0, 120.0),
|
|
Step::Wait(100),
|
|
Step::Shot("band"),
|
|
Step::UpAt("interaction-tiles", 120.0, 120.0),
|
|
Step::DownAt("interaction-rotatable", 98.0, 22.0),
|
|
Step::DragTo("interaction-rotatable", 116.0, 70.0),
|
|
Step::UpAt("interaction-rotatable", 116.0, 70.0),
|
|
Step::Wait(100),
|
|
Step::Shot("turned"),
|
|
];
|
|
|
|
fn render(window: &mut Window, cx: &mut App) -> AnyElement {
|
|
div()
|
|
.child(pointer::drag_and_drop(window, cx))
|
|
.child(pointer::shapes(window, cx))
|
|
.into_any_element()
|
|
}
|