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