This commit is contained in:
sxyazi 2024-11-13 11:13:44 +08:00
parent 65f1fb9c90
commit d33dc4ff01
No known key found for this signature in database

View file

@ -20,20 +20,19 @@ impl Utils {
pub(super) fn redraw_with(lua: &Lua) -> mlua::Result<Function> { pub(super) fn redraw_with(lua: &Lua) -> mlua::Result<Function> {
lua.create_function(|lua, c: Table| { lua.create_function(|lua, c: Table| {
let id: mlua::String = c.get("_id")?; let id: mlua::String = c.get("_id")?;
let id = id.to_str()?;
let mut layout = LAYOUT.get(); let mut layout = LAYOUT.get();
match id.as_ref() { match id.as_bytes().as_ref() {
"current" => layout.current = *c.raw_get::<crate::elements::Rect>("_area")?, b"current" => layout.current = *c.raw_get::<crate::elements::Rect>("_area")?,
"preview" => layout.preview = *c.raw_get::<crate::elements::Rect>("_area")?, b"preview" => layout.preview = *c.raw_get::<crate::elements::Rect>("_area")?,
"progress" => layout.progress = *c.raw_get::<crate::elements::Rect>("_area")?, b"progress" => layout.progress = *c.raw_get::<crate::elements::Rect>("_area")?,
_ => {} _ => {}
} }
LAYOUT.set(layout); LAYOUT.set(layout);
match c.call_method::<Table>("redraw", ()) { match c.call_method::<Table>("redraw", ()) {
Err(e) => { Err(e) => {
error!("Failed to `redraw()` the `{id}` component:\n{e}"); error!("Failed to `redraw()` the `{}` component:\n{e}", id.display());
lua.create_table() lua.create_table()
} }
ok => ok, ok => ok,