Function draw_list_rows

Source
pub fn draw_list_rows(
    rect: Rect,
    rows: &[ListRow],
    style: ListStyle,
    text: &mut TextSystem,
) -> Vec<DrawCmd>
Expand description

Draws complete rows from the top of rect until the next row would overflow.

A row whose bottom is exactly rect’s bottom is included. Each included row emits a transparent background plus two text commands, and optionally a trailing rounded square. Horizontal content is not clipped by this helper.

§Examples

use ailloli_ui_core::{Color, FontId, Rect};
use ailloli_ui_text::TextSystem;
use ailloli_ui_widgets::controls::list::{draw_list_rows, ListRow, ListStyle};
let rows = vec![ListRow {
    title: "One".into(),
    subtitle: "First".into(),
    right_icon_bg: None,
}];
let style = ListStyle {
    row_h: 44.0,
    radius: 8.0,
    title_fg: Color::WHITE,
    subtitle_fg: Color::WHITE,
    font: FontId::Ui,
    title_px: 14,
    subtitle_px: 12,
};
let mut text = TextSystem::new();
let commands = draw_list_rows(Rect::new(0.0, 0.0, 200.0, 44.0), &rows, style, &mut text);
assert_eq!(commands.len(), 3);