Files
creaturedex/src/views/menu_item.rs
T

33 lines
928 B
Rust

use alloc::boxed::Box;
use core::error;
use crate::peripherals::Peripherals;
use embedded_graphics::Drawable;
use embedded_graphics::draw_target::DrawTarget;
use embedded_graphics::mono_font::MonoTextStyle;
use embedded_graphics::mono_font::ascii::FONT_10X20;
use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::prelude::Point;
use embedded_graphics::prelude::RgbColor;
use embedded_graphics::text::Text;
pub fn show<D>(display: &mut D, name: &str, position: i32, selected: i32)
where
D: DrawTarget<Color = Rgb565>,
D::Error: core::fmt::Debug,
{
let style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
let selected_style = MonoTextStyle::new(&FONT_10X20, Rgb565::BLUE);
Text::new(
name,
Point::new(40, 40 + position * 40),
if position == selected {
selected_style
} else {
style
},
)
.draw(display)
.unwrap();
}