clear ui, when loading bin
This commit is contained in:
@@ -28,7 +28,7 @@ use crate::{
|
||||
},
|
||||
scsi::MSC_SHUTDOWN,
|
||||
storage::{SDCARD, SdCard},
|
||||
ui::{SELECTIONS, ui_handler},
|
||||
ui::{SELECTIONS, clear_selection, ui_handler},
|
||||
usb::usb_handler,
|
||||
};
|
||||
use abi_sys::EntryFn;
|
||||
@@ -140,7 +140,9 @@ async fn userland_task() {
|
||||
{
|
||||
ENABLE_UI.store(false, Ordering::Release);
|
||||
UI_CHANGE.signal(());
|
||||
// clear_fb();
|
||||
|
||||
clear_selection().await;
|
||||
|
||||
MSC_SHUTDOWN.signal(());
|
||||
}
|
||||
|
||||
@@ -151,7 +153,6 @@ async fn userland_task() {
|
||||
{
|
||||
ENABLE_UI.store(true, Ordering::Release);
|
||||
UI_CHANGE.signal(());
|
||||
// clear_fb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ use embedded_graphics::{
|
||||
Drawable,
|
||||
mono_font::{MonoTextStyle, ascii::FONT_9X15},
|
||||
pixelcolor::Rgb565,
|
||||
prelude::{Dimensions, Point, RgbColor, Size},
|
||||
primitives::Rectangle,
|
||||
prelude::{Dimensions, Point, Primitive, RgbColor, Size},
|
||||
primitives::{PrimitiveStyle, Rectangle},
|
||||
text::Text,
|
||||
};
|
||||
use embedded_layout::{
|
||||
@@ -50,12 +50,25 @@ pub async fn ui_handler() {
|
||||
}
|
||||
}
|
||||
|
||||
if SELECTIONS.lock().await.changed {
|
||||
let changed = SELECTIONS.lock().await.changed;
|
||||
if changed {
|
||||
clear_selection().await;
|
||||
draw_selection().await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn clear_selection() {
|
||||
let sel = SELECTIONS.lock().await;
|
||||
|
||||
if let Some(area) = sel.last_bounds {
|
||||
Rectangle::new(area.top_left, area.size)
|
||||
.into_styled(PrimitiveStyle::with_fill(Rgb565::BLACK))
|
||||
.draw(unsafe { &mut FRAMEBUFFER })
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
async fn draw_selection() {
|
||||
let file_names: Vec<FileName> = {
|
||||
let guard = SELECTIONS.lock().await;
|
||||
@@ -99,12 +112,14 @@ async fn draw_selection() {
|
||||
// ));
|
||||
// }
|
||||
|
||||
LinearLayout::vertical(chain)
|
||||
let layout = LinearLayout::vertical(chain)
|
||||
.with_alignment(horizontal::Center)
|
||||
.arrange()
|
||||
.align_to(&display_area, horizontal::Center, vertical::Center)
|
||||
.draw(unsafe { &mut FRAMEBUFFER })
|
||||
.unwrap();
|
||||
.align_to(&display_area, horizontal::Center, vertical::Center);
|
||||
|
||||
SELECTIONS.lock().await.last_bounds = Some(layout.bounds());
|
||||
|
||||
layout.draw(unsafe { &mut FRAMEBUFFER }).unwrap();
|
||||
}
|
||||
|
||||
let mut sel = SELECTIONS.lock().await;
|
||||
@@ -113,6 +128,9 @@ async fn draw_selection() {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SelectionList {
|
||||
// allows easy clearing of selection ui,
|
||||
// based on previous bounds
|
||||
last_bounds: Option<Rectangle>,
|
||||
current_selection: u16,
|
||||
selections: Vec<FileName>,
|
||||
changed: bool,
|
||||
@@ -121,6 +139,7 @@ pub struct SelectionList {
|
||||
impl SelectionList {
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
last_bounds: None,
|
||||
selections: Vec::new(),
|
||||
current_selection: 0,
|
||||
changed: false,
|
||||
|
||||
Reference in New Issue
Block a user