Crate rat_reloc

Crate rat_reloc 

Source
Expand description

semver stable crates.io Documentation License License

This crate is a part of rat-salsa.

§Rat-Reloc(ate)

This crate defines the trait RelocatableState

§Why?

Many widgets in rat-widget store one or more areas for mouse interaction.

And there are widgets that render other widgets to a temp Buffer and later dump parts of it to the main render Buffer. And then all the stored areas in the widget-state are wrong.

The RelocatableState trait gives the widgets that use such temp Buffers a hook to correct for any movement and clipping that has happened.

§Why so complicated?

  • This doesn’t affect normal rendering of a widget, it’s just and afterthought.
  • The widget doesn’t need to know what other widgets exist, it just has to provide the function to relocate its areas after rendering.

Macros§

impl_relocatable_state
Create the implementation of RelocatableState for the given list of struct members.

Traits§

RelocatableState
Widgets can be rendered to a temporary Buffer that will be dumped to the main render Buffer at a later point.

Functions§

relocate_area
Shift the area by offset and clip it.
relocate_areas
Shift the area by offset and clip it.
relocate_dark_offset
Clipping might introduce another offset by cutting away part of an area that a widgets internal offset refers to.
relocate_pos_tuple
Shift the position by offset and clip it. Returns None if the position is clipped.
relocate_position
Shift the position by offset and clip it. Returns None if the position is clipped.
relocate_positions
Shift the position by offset and clip it. Clipped positions are replaced with (0,0) for this function.