mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add forced redraw function, fix misdirected message
- rapid redraws are normally aborted by this routine. offer a forced redraw in the case that a "final state" has to be rendered without fail. - fix a misdirected message (sending it to app instead of to ui by accident)
This commit is contained in:
parent
ae7ee770ee
commit
5aefcac8ec
4 changed files with 24 additions and 5 deletions
|
|
@ -20,8 +20,8 @@
|
|||
"en-tts": "no dialogues available to read"
|
||||
},
|
||||
"chat.status.initial" : {
|
||||
"en": "Idle",
|
||||
"en-tts": "Idle"
|
||||
"en": "Use ← to raise menu",
|
||||
"en-tts": "Use ← to raise menu"
|
||||
},
|
||||
"chat.help.navigation": {
|
||||
"en": "use ↑ & ↓ to scroll thru old posts\nuse ← & → to show menus\nF1-F4 dont do anything yet.",
|
||||
|
|
|
|||
|
|
@ -43,7 +43,10 @@ pub enum ChatOp {
|
|||
/// Set the status idle text (to be shown when exiting all busy states)
|
||||
SetStatusIdleText,
|
||||
/// Update just the state of the busy animation, if any. Internal opcode.
|
||||
/// Will skip the update if called too often.
|
||||
UpdateBusy,
|
||||
/// Force update the busy bar, without rate throttling. Internal opcode.
|
||||
UpdateBusyForced,
|
||||
/// exit the application
|
||||
Quit,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -363,6 +363,9 @@ pub fn server(
|
|||
Some(ChatOp::UpdateBusy) => {
|
||||
ui.redraw_busy().expect("CHAT couldn't redraw");
|
||||
}
|
||||
Some(ChatOp::UpdateBusyForced) => {
|
||||
ui.redraw_status_forced().expect("CHAT couldn't redraw");
|
||||
}
|
||||
Some(ChatOp::SetStatusText) => {
|
||||
let buffer = unsafe {
|
||||
Buffer::from_memory_message(msg.body.memory_message().unwrap())
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ pub(crate) struct Ui {
|
|||
dialogue: Option<Dialogue>,
|
||||
|
||||
// Callbacks:
|
||||
// callback to our own server
|
||||
self_cid: CID,
|
||||
// optional SID of the "Owner" Chat App to receive UI-events
|
||||
app_cid: Option<CID>,
|
||||
// optional opcode ID to process UI-event msgs
|
||||
|
|
@ -153,6 +155,7 @@ impl Ui {
|
|||
pddb_dict: None,
|
||||
pddb_key: None,
|
||||
dialogue: None,
|
||||
self_cid: xous::connect(sid).unwrap(),
|
||||
app_cid,
|
||||
opcode_event,
|
||||
canvas,
|
||||
|
|
@ -637,6 +640,15 @@ impl Ui {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Update the status bar, without any throttling
|
||||
pub(crate) fn redraw_status_forced(&mut self) -> Result<(), xous::Error> {
|
||||
self.gam.post_textview(&mut self.status_tv)?;
|
||||
self.gam.redraw().expect("couldn't redraw screen");
|
||||
let curtime = self.tt.elapsed_ms();
|
||||
self.status_last_update_ms = curtime;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns `true` if the status bar is currently set for the busy animation
|
||||
pub(crate) fn is_busy(&self) -> bool {
|
||||
self.status_tv.busy_animation_state.is_some()
|
||||
|
|
@ -646,7 +658,7 @@ impl Ui {
|
|||
pub(crate) fn set_status_text(&mut self, msg: &str) {
|
||||
self.status_tv.clear_str();
|
||||
write!(self.status_tv, "{}", msg).ok();
|
||||
xous::send_message(self.app_cid.unwrap(),
|
||||
xous::send_message(self.self_cid,
|
||||
xous::Message::new_scalar(
|
||||
ChatOp::UpdateBusy as usize, 0, 0, 0, 0)
|
||||
).ok();
|
||||
|
|
@ -659,9 +671,10 @@ impl Ui {
|
|||
if self.status_tv.busy_animation_state.take().is_some() {
|
||||
self.status_tv.clear_str();
|
||||
write!(self.status_tv, "{}", self.status_idle_text).ok();
|
||||
xous::send_message(self.app_cid.unwrap(),
|
||||
// force the update, to ensure the idle state text is actually rendered
|
||||
xous::send_message(self.self_cid,
|
||||
xous::Message::new_scalar(
|
||||
ChatOp::UpdateBusy as usize, 0, 0, 0, 0)
|
||||
ChatOp::UpdateBusyForced as usize, 0, 0, 0, 0)
|
||||
).ok();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue