Skip to main content

rlvgl_widgets/
container.rs

1//! Simple container grouping child widgets.
2use rlvgl_core::draw::draw_widget_bg;
3use rlvgl_core::event::Event;
4use rlvgl_core::renderer::Renderer;
5use rlvgl_core::style::Style;
6use rlvgl_core::widget::{Rect, Widget};
7
8/// Empty widget used to group child widgets and provide background styling.
9pub struct Container {
10    bounds: Rect,
11    /// Visual style applied to the container background.
12    pub style: Style,
13}
14
15impl Container {
16    /// Create a new container with the specified bounds.
17    pub fn new(bounds: Rect) -> Self {
18        Self {
19            bounds,
20            style: Style::default(),
21        }
22    }
23}
24
25impl Widget for Container {
26    fn bounds(&self) -> Rect {
27        self.bounds
28    }
29
30    fn draw(&self, renderer: &mut dyn Renderer) {
31        draw_widget_bg(renderer, self.bounds, &self.style);
32    }
33
34    /// Containers are currently passive and do not react to events.
35    fn handle_event(&mut self, _event: &Event) -> bool {
36        false
37    }
38}