Skip to main content

BaseShape

Trait BaseShape 

Source
pub trait BaseShape {
Show 17 methods // Required method fn gui_rect(&self) -> Rect; // Provided methods fn title(&self) -> Option<ShapeLabel<'_>> { ... } fn type_label(&self) -> Option<ShapeLabel<'_>> { ... } fn constrain_resize_delta(&self, delta: Vec2) -> Vec2 { ... } fn pin(&self, id: PinId) -> Option<&Pin> { ... } fn anchor_point_with_rect(&self, rect: Rect, id: PinId) -> Option<Pos2> { ... } fn pin_position(&self, location: PinLocation) -> Option<Pos2> { ... } fn pin_drop_candidate( &self, pin_id: PinId, side: PinSide, raw_offset_px: f32, ) -> Option<u32> { ... } fn pin_text_rect<R: Renderer>( &self, id: PinId, painter: &Style<'_, R>, ) -> Option<Rect> { ... } fn pin_type_rect<R: Renderer>( &self, id: PinId, painter: &Style<'_, R>, ) -> Option<Rect> { ... } fn tag_text_rect_for<R: Renderer>( &self, id: PinId, text: &str, painter: &Style<'_, R>, ) -> Option<Rect> { ... } fn pin_stub_rect(&self, id: PinId) -> Option<Rect> { ... } fn render_ng<R: Renderer>( &self, mode: RenderMode, painter: &mut Style<'_, R>, ) { ... } fn new_pin_locations(&self) -> Vec<PinLocation> { ... } fn title_anchor(&self) -> Option<Pos2> { ... } fn type_anchor(&self) -> Option<Pos2> { ... } fn resizable(&self) -> bool { ... }
}
Expand description

BaseShape is what every shape can answer without knowing the document: where it sits, what its labels are, where its pins hang, and how it paints. Writes are not here — they are commits, emitted by crate::edit against the document the gesture read.

Required Methods§

Source

fn gui_rect(&self) -> Rect

Provided Methods§

Source

fn title(&self) -> Option<ShapeLabel<'_>>

Source

fn type_label(&self) -> Option<ShapeLabel<'_>>

Source

fn constrain_resize_delta(&self, delta: Vec2) -> Vec2

Source

fn pin(&self, id: PinId) -> Option<&Pin>

Source

fn anchor_point_with_rect(&self, rect: Rect, id: PinId) -> Option<Pos2>

Source

fn pin_position(&self, location: PinLocation) -> Option<Pos2>

Source

fn pin_drop_candidate( &self, pin_id: PinId, side: PinSide, raw_offset_px: f32, ) -> Option<u32>

The slot a dragged pin would snap to (its grid offset), or None if no free slot is available. Read-only: the drop’s own write is crate::edit::geometry::move_pin, and both resolve the same slot so the preview lands where the commit will.

Source

fn pin_text_rect<R: Renderer>( &self, id: PinId, painter: &Style<'_, R>, ) -> Option<Rect>

Source

fn pin_type_rect<R: Renderer>( &self, id: PinId, painter: &Style<'_, R>, ) -> Option<Rect>

Bounding box of a pin’s type label (the smaller second line below the name), for hit-testing a double-click on the type. None for shapes without such a pin.

Source

fn tag_text_rect_for<R: Renderer>( &self, id: PinId, text: &str, painter: &Style<'_, R>, ) -> Option<Rect>

Bounding box of a pin’s tag label (drawn above the stub line), sized for an explicit text. None if the shape has no such pin. Callers pass the “+tag” placeholder for an empty tag so the prompt stays a hit/edit target.

Source

fn pin_stub_rect(&self, id: PinId) -> Option<Rect>

Clickable hit region around a pin’s stub (the red line).

Source

fn render_ng<R: Renderer>(&self, mode: RenderMode, painter: &mut Style<'_, R>)

Render this shape. A block draws its own tag label from its decorations, so no external id is needed.

Source

fn new_pin_locations(&self) -> Vec<PinLocation>

Source

fn title_anchor(&self) -> Option<Pos2>

Source

fn type_anchor(&self) -> Option<Pos2>

Source

fn resizable(&self) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl BaseShape for Area

Source§

fn title(&self) -> Option<ShapeLabel<'_>>

Source§

fn gui_rect(&self) -> Rect

Source§

fn title_anchor(&self) -> Option<Pos2>

Source§

fn resizable(&self) -> bool

Source§

fn render_ng<R: Renderer>(&self, mode: RenderMode, painter: &mut Style<'_, R>)

Implementors§