anathema_default_widgets/stacks/
hstack.rs

1use anathema_geometry::Size;
2use anathema_value_resolver::AttributeStorage;
3use anathema_widgets::error::Result;
4use anathema_widgets::layout::{Constraints, LayoutCtx, PositionCtx};
5use anathema_widgets::{LayoutForEach, PositionChildren, Widget, WidgetId};
6
7use super::Stack;
8use crate::layout::Axis;
9
10pub struct HStack(Stack);
11
12impl Default for HStack {
13    fn default() -> Self {
14        HStack(Stack(Axis::Horizontal))
15    }
16}
17
18impl Widget for HStack {
19    fn layout<'bp>(
20        &mut self,
21        children: LayoutForEach<'_, 'bp>,
22        constraints: Constraints,
23        id: WidgetId,
24        ctx: &mut LayoutCtx<'_, 'bp>,
25    ) -> Result<Size> {
26        self.0.layout(children, constraints, id, ctx)
27    }
28
29    fn position<'bp>(
30        &mut self,
31        children: PositionChildren<'_, 'bp>,
32        attributes: WidgetId,
33        attribute_storage: &AttributeStorage<'bp>,
34        ctx: PositionCtx,
35    ) {
36        self.0.position(children, attributes, attribute_storage, ctx)
37    }
38}