pub struct Group {
pub rect: TileRect,
pub layout: GroupLayout,
pub clip: bool,
pub border: Option<Border>,
}Expand description
A layout container that manages children with coordinate translation.
§Examples
use dotzuki_renderer::layout_engine::elements::group::{Group, GroupLayout};
use dotzuki_engine::render::TileRect;
let group = Group::new(TileRect::new(0, 0, 10, 10))
.with_layout(GroupLayout::Vertical { gap: 1 })
.with_clip(true);Fields§
§rect: TileRectThe group’s bounding rectangle in screen-absolute tile coordinates.
layout: GroupLayoutHow children are positioned within the group.
clip: boolWhether child rendering is clipped to rect.
border: Option<Border>Optional border rendered around the group.
Implementations§
Source§impl Group
impl Group
Sourcepub fn new(rect: TileRect) -> Self
pub fn new(rect: TileRect) -> Self
Create a new group with absolute layout, no clip, and no border.
Sourcepub fn with_layout(self, layout: GroupLayout) -> Self
pub fn with_layout(self, layout: GroupLayout) -> Self
Set the layout mode.
Sourcepub fn with_border(self, border: Border) -> Self
pub fn with_border(self, border: Border) -> Self
Attach a border to the group.
Sourcepub fn to_absolute(&self, tx: u32, ty: u32) -> TilePos
pub fn to_absolute(&self, tx: u32, ty: u32) -> TilePos
Translate a group-relative tile position to screen-absolute.
Adds the group’s top-left offset to the given coordinates. This is the core coordinate translation used when rendering children that specify their positions relative to the group.
Sourcepub fn rect_to_absolute(&self, relative: TileRect) -> TileRect
pub fn rect_to_absolute(&self, relative: TileRect) -> TileRect
Translate a group-relative tile rectangle to screen-absolute.
Sourcepub fn child_rect(
&self,
child: &LayoutElement,
_index: usize,
ctx: &DataContext,
) -> TileRect
pub fn child_rect( &self, child: &LayoutElement, _index: usize, ctx: &DataContext, ) -> TileRect
Compute the screen-absolute rectangle for a child element.
For GroupLayout::Absolute, the child’s own rect.tx/rect.ty
are treated as offsets from the group origin.
For automatic layouts (GroupLayout::Horizontal /
GroupLayout::Vertical), the child’s explicit tx/ty are
overridden by the computed layout position; the child still
controls its own tw/th.
Sourcepub fn layout_offset(
&self,
index: usize,
children: &[LayoutElement],
) -> (u32, u32)
pub fn layout_offset( &self, index: usize, children: &[LayoutElement], ) -> (u32, u32)
Compute the layout offset for the child at index from the actual
child list.
Returns the (x, y) offset in tiles from the group origin that this child should be placed at, based on the layout mode and the actual widths/heights of previous children.
For GroupLayout::Absolute, always returns (0, 0) — the child’s
own rect.tx/rect.ty are used directly.
Sourcepub fn resolve_children(
&self,
children: &[LayoutElement],
ctx: &DataContext,
) -> Vec<ChildRect>
pub fn resolve_children( &self, children: &[LayoutElement], ctx: &DataContext, ) -> Vec<ChildRect>
Resolve all children to their screen-absolute rectangles.
Returns a vector of ChildRect in the same order as children,
each with a computed absolute position based on the layout mode.
Sourcepub fn render_border(&self, painter: &mut dyn Painter)
pub fn render_border(&self, painter: &mut dyn Painter)
Render the group’s border (if any) into the given Painter.
This does not render children — it only draws the group’s own border or background fill. Child rendering is handled by the layout engine’s element dispatch.
Sourcepub fn render(
&self,
children: &[LayoutElement],
ctx: &DataContext,
render_ctx: &RenderContext<'_>,
painter: &mut dyn Painter,
registry: &ElementRegistry,
) -> Result<(), RenderError>
pub fn render( &self, children: &[LayoutElement], ctx: &DataContext, render_ctx: &RenderContext<'_>, painter: &mut dyn Painter, registry: &ElementRegistry, ) -> Result<(), RenderError>
Render the group including border and children via the layout engine.
When clip is enabled, pixels outside rect should be masked.
Current implementation renders all visible children; clipping is
a future enhancement for when a clip-stack is added to the painter.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Group
impl RefUnwindSafe for Group
impl Send for Group
impl Sync for Group
impl Unpin for Group
impl UnsafeUnpin for Group
impl UnwindSafe for Group
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.