mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +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"
|
"en-tts": "no dialogues available to read"
|
||||||
},
|
},
|
||||||
"chat.status.initial" : {
|
"chat.status.initial" : {
|
||||||
"en": "Idle",
|
"en": "Use ← to raise menu",
|
||||||
"en-tts": "Idle"
|
"en-tts": "Use ← to raise menu"
|
||||||
},
|
},
|
||||||
"chat.help.navigation": {
|
"chat.help.navigation": {
|
||||||
"en": "use ↑ & ↓ to scroll thru old posts\nuse ← & → to show menus\nF1-F4 dont do anything yet.",
|
"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)
|
/// Set the status idle text (to be shown when exiting all busy states)
|
||||||
SetStatusIdleText,
|
SetStatusIdleText,
|
||||||
/// Update just the state of the busy animation, if any. Internal opcode.
|
/// Update just the state of the busy animation, if any. Internal opcode.
|
||||||
|
/// Will skip the update if called too often.
|
||||||
UpdateBusy,
|
UpdateBusy,
|
||||||
|
/// Force update the busy bar, without rate throttling. Internal opcode.
|
||||||
|
UpdateBusyForced,
|
||||||
/// exit the application
|
/// exit the application
|
||||||
Quit,
|
Quit,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -363,6 +363,9 @@ pub fn server(
|
||||||
Some(ChatOp::UpdateBusy) => {
|
Some(ChatOp::UpdateBusy) => {
|
||||||
ui.redraw_busy().expect("CHAT couldn't redraw");
|
ui.redraw_busy().expect("CHAT couldn't redraw");
|
||||||
}
|
}
|
||||||
|
Some(ChatOp::UpdateBusyForced) => {
|
||||||
|
ui.redraw_status_forced().expect("CHAT couldn't redraw");
|
||||||
|
}
|
||||||
Some(ChatOp::SetStatusText) => {
|
Some(ChatOp::SetStatusText) => {
|
||||||
let buffer = unsafe {
|
let buffer = unsafe {
|
||||||
Buffer::from_memory_message(msg.body.memory_message().unwrap())
|
Buffer::from_memory_message(msg.body.memory_message().unwrap())
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ pub(crate) struct Ui {
|
||||||
dialogue: Option<Dialogue>,
|
dialogue: Option<Dialogue>,
|
||||||
|
|
||||||
// Callbacks:
|
// Callbacks:
|
||||||
|
// callback to our own server
|
||||||
|
self_cid: CID,
|
||||||
// optional SID of the "Owner" Chat App to receive UI-events
|
// optional SID of the "Owner" Chat App to receive UI-events
|
||||||
app_cid: Option<CID>,
|
app_cid: Option<CID>,
|
||||||
// optional opcode ID to process UI-event msgs
|
// optional opcode ID to process UI-event msgs
|
||||||
|
|
@ -153,6 +155,7 @@ impl Ui {
|
||||||
pddb_dict: None,
|
pddb_dict: None,
|
||||||
pddb_key: None,
|
pddb_key: None,
|
||||||
dialogue: None,
|
dialogue: None,
|
||||||
|
self_cid: xous::connect(sid).unwrap(),
|
||||||
app_cid,
|
app_cid,
|
||||||
opcode_event,
|
opcode_event,
|
||||||
canvas,
|
canvas,
|
||||||
|
|
@ -637,6 +640,15 @@ impl Ui {
|
||||||
Ok(())
|
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
|
/// Returns `true` if the status bar is currently set for the busy animation
|
||||||
pub(crate) fn is_busy(&self) -> bool {
|
pub(crate) fn is_busy(&self) -> bool {
|
||||||
self.status_tv.busy_animation_state.is_some()
|
self.status_tv.busy_animation_state.is_some()
|
||||||
|
|
@ -646,7 +658,7 @@ impl Ui {
|
||||||
pub(crate) fn set_status_text(&mut self, msg: &str) {
|
pub(crate) fn set_status_text(&mut self, msg: &str) {
|
||||||
self.status_tv.clear_str();
|
self.status_tv.clear_str();
|
||||||
write!(self.status_tv, "{}", msg).ok();
|
write!(self.status_tv, "{}", msg).ok();
|
||||||
xous::send_message(self.app_cid.unwrap(),
|
xous::send_message(self.self_cid,
|
||||||
xous::Message::new_scalar(
|
xous::Message::new_scalar(
|
||||||
ChatOp::UpdateBusy as usize, 0, 0, 0, 0)
|
ChatOp::UpdateBusy as usize, 0, 0, 0, 0)
|
||||||
).ok();
|
).ok();
|
||||||
|
|
@ -659,9 +671,10 @@ impl Ui {
|
||||||
if self.status_tv.busy_animation_state.take().is_some() {
|
if self.status_tv.busy_animation_state.take().is_some() {
|
||||||
self.status_tv.clear_str();
|
self.status_tv.clear_str();
|
||||||
write!(self.status_tv, "{}", self.status_idle_text).ok();
|
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(
|
xous::Message::new_scalar(
|
||||||
ChatOp::UpdateBusy as usize, 0, 0, 0, 0)
|
ChatOp::UpdateBusyForced as usize, 0, 0, 0, 0)
|
||||||
).ok();
|
).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue