pub struct BlockShape<'a> {
pub block: &'a Block,
pub pins: Vec<(PinId, &'a Pin)>,
pub structure: Structure,
}Expand description
A block with the pins the caller resolved for it. In the document a pin is its own entity owned by the block, so nothing about a block’s boundary can be read off the block alone; the scope that draws it hands the set in, in the order it wants them painted.
Fields§
§block: &'a Block§pins: Vec<(PinId, &'a Pin)>§structure: StructureWhether the block holds blocks of its own — crate::path::structure,
resolved by the scope that built the shape, since a block’s interior is
no more readable off the block alone than its pins are.
Implementations§
Source§impl<'a> BlockShape<'a>
impl<'a> BlockShape<'a>
pub fn new( block: &'a Block, pins: Vec<(PinId, &'a Pin)>, structure: Structure, ) -> Self
pub fn rect(&self) -> Rect
Sourcepub fn lock(&self) -> InterfaceLock
pub fn lock(&self) -> InterfaceLock
The block’s InterfaceLock state, for passing to functions that branch on it.
Sourcepub fn accent_role(&self) -> Role
pub fn accent_role(&self) -> Role
The Role the block’s outline strokes with, chosen by its accent
role register: Accent1..=Accent8 →
Role::Accent0..Role::Accent7, the plain Accent0 →
Role::AccentDefault.
fn offsets(&self) -> impl Iterator<Item = u32> + '_
pub fn is_pin_location_available(&self, location: PinLocation) -> bool
Sourcepub fn is_pin_location_available_excluding(
&self,
location: PinLocation,
except: Option<PinId>,
) -> bool
pub fn is_pin_location_available_excluding( &self, location: PinLocation, except: Option<PinId>, ) -> bool
Like Self::is_pin_location_available, but ignores the pin except
(so a pin being dragged doesn’t block its own move).
Sourcepub fn resize_pin_shift(&self, new_height: f32) -> u32
pub fn resize_pin_shift(&self, new_height: f32) -> u32
How many slots every pin shifts up when the block is resized to
new_height (see the free resize_pin_shift).
Sourcepub fn pin_anchor_at(&self, rect: Rect, side: PinSide, offset: u32) -> Pos2
pub fn pin_anchor_at(&self, rect: Rect, side: PinSide, offset: u32) -> Pos2
Where a pin sitting at (side, offset) anchors its wire when the
block is drawn at rect — the slot-parameterized core of
BaseShape::anchor_point_with_rect, shared with drag previews that
preview a pin at a hypothetical slot without moving it. Applies the same
upward shift the block’s render preview uses, so a route re-routed
against a shrunk preview rect tracks where the pin will land; at the
block’s real height the shift is zero.
fn title_label(&self) -> ShapeLabel<'a>
fn type_label_of(&self) -> ShapeLabel<'a>
Sourcefn committed_rect(&self, mode: RenderMode) -> Rect
fn committed_rect(&self, mode: RenderMode) -> Rect
The grid-committed rect a block renders its frame and pins at for mode
(a drag/resize preview snaps to grid on commit). Shared by
BaseShape::render_ng and Self::render_pins_ng so the body and pin
passes stay aligned.
Sourcepub fn render_pins_ng<R: Renderer>(
&self,
accents: ShapeAccents<'_>,
mode: RenderMode,
painter: &mut Style<'_, R>,
)
pub fn render_pins_ng<R: Renderer>( &self, accents: ShapeAccents<'_>, mode: RenderMode, painter: &mut Style<'_, R>, )
Draw only the block’s pin layer for mode — stubs, names, tags, the
selection placeholders, and the drag/resize previews. Split out of
BaseShape::render_ng so the scene can draw it in a later pass, on top
of a block’s icon (see crate::widget::DrawingPasses).
Trait Implementations§
Source§impl BaseShape for BlockShape<'_>
impl BaseShape for BlockShape<'_>
Source§fn pin_drop_candidate(
&self,
pin_id: PinId,
side: PinSide,
raw_offset_px: f32,
) -> Option<u32>
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 near the raw drop position. Tries the nearest slot,
then the adjacent slot on the other side of the raw drop position. The
drop’s own write (crate::edit::geometry::move_pin) is handed the slot
this resolved, so the live preview lands exactly where the commit will.
fn title(&self) -> Option<ShapeLabel<'_>>
fn type_label(&self) -> Option<ShapeLabel<'_>>
fn gui_rect(&self) -> Rect
fn pin(&self, id: PinId) -> Option<&Pin>
fn anchor_point_with_rect(&self, rect: Rect, id: PinId) -> Option<Pos2>
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>
fn pin_type_rect<R: Renderer>( &self, id: PinId, painter: &Style<'_, R>, ) -> Option<Rect>
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>
fn tag_text_rect_for<R: Renderer>( &self, id: PinId, text: &str, painter: &Style<'_, R>, ) -> Option<Rect>
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>
fn pin_stub_rect(&self, id: PinId) -> Option<Rect>
fn new_pin_locations(&self) -> Vec<PinLocation>
fn pin_position(&self, location: PinLocation) -> Option<Pos2>
fn title_anchor(&self) -> Option<Pos2>
fn type_anchor(&self) -> Option<Pos2>
fn resizable(&self) -> bool
Source§fn render_ng<R: Renderer>(&self, mode: RenderMode, painter: &mut Style<'_, R>)
fn render_ng<R: Renderer>(&self, mode: RenderMode, painter: &mut Style<'_, R>)
tag label from its
decorations, so no external id is needed.fn constrain_resize_delta(&self, delta: Vec2) -> Vec2
Auto Trait Implementations§
impl<'a> Freeze for BlockShape<'a>
impl<'a> RefUnwindSafe for BlockShape<'a>
impl<'a> Send for BlockShape<'a>
impl<'a> Sync for BlockShape<'a>
impl<'a> Unpin for BlockShape<'a>
impl<'a> UnsafeUnpin for BlockShape<'a>
impl<'a> UnwindSafe for BlockShape<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more