1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- use crate::{
- layout::{LayoutChildIter, LayoutNode, LayoutNodeAccess, LayoutNodeContainer},
- platform::{render::Painter, PlatformPainter, PlatformSpec, TextInterface},
- Component, Widget,
- };
- pub struct PlainGroup<P: PlatformSpec, C: Component> {
- lnode: LayoutNode,
- children: Vec<Box<dyn Widget<P, C>>>,
- }
- impl<P: PlatformSpec, C: Component> LayoutNodeContainer for PlainGroup<P, C> {
- fn layout_node(&self) -> &LayoutNode {
- &self.lnode
- }
- fn layout_child(&self, ndx: usize) -> Option<LayoutNodeAccess> {
- self.children.get(ndx).map(|w| w.layout_node())
- }
- fn layout_child_count(&self) -> usize {
- self.children.len()
- }
- }
- impl<P: PlatformSpec, C: Component> Widget<P, C> for PlainGroup<P, C> {
- fn layout_node(&self) -> LayoutNodeAccess {
- LayoutNodeAccess::new(self)
- }
- fn layout_node_mut(&mut self) -> &mut LayoutNode {
- &mut self.lnode
- }
- fn poll(
- &mut self,
- input_state: Option<&crate::input::InputState>,
- ) -> Vec<<C as Component>::Msg> {
- vec![]
- }
- fn render(&self, painter: &mut PlatformPainter<P>, ti: &P::Text) {
- for child in self.children.iter() {
- child.render(painter, ti);
- }
- }
- }
|