From a13d46e66d3d12fdafe1fc4358fddddde6bd825f Mon Sep 17 00:00:00 2001 From: Minijackson Date: Fri, 20 Jan 2023 16:42:12 +0100 Subject: lua-bindings: simplify sigure by passing as self --- lua-bindings/src/lib.rs | 44 +++----------------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) (limited to 'lua-bindings/src') diff --git a/lua-bindings/src/lib.rs b/lua-bindings/src/lib.rs index 53622de..2cce0f5 100644 --- a/lua-bindings/src/lib.rs +++ b/lua-bindings/src/lib.rs @@ -741,25 +741,9 @@ fn draw(lua: &Lua, params: LuaTable) -> LuaResult<()> { } } - let bounds = bounds.unwrap(); - - // TODO: it would be nicer to do in Lua - let bounds_top = bounds.top(runtime.solver_ctx()); - let top_constraint = runtime - .solver_ctx() - .float_eq(bounds_top, CoreFloat::Fixed(0.0)); - runtime.solver_ctx().constrain(top_constraint); - - let bounds_left = bounds.left(runtime.solver_ctx()); - let left_constraint = runtime - .solver_ctx() - .float_eq(bounds_left, CoreFloat::Fixed(0.0)); - runtime.solver_ctx().constrain(left_constraint); - - runtime.render(bounds); + runtime.render(bounds.unwrap()); }); - let content: LuaValue = params.get("content")?; let _output: LuaTable = params.get("output")?; let figure = complex_shape(lua, ())?; @@ -776,30 +760,8 @@ fn draw(lua: &Lua, params: LuaTable) -> LuaResult<()> { .unwrap() }); - match content { - // TODO: this doesn't stop the runtime thread? - LuaValue::Table(table) => table.call_method("draw", figure).unwrap(), - - // TODO: switch to enum - // LuaValue::UserData(user_data) => { - // if user_data.is::() { - // let text = user_data - // .borrow::() - // .expect("Couldn't borrow Text user data"); - // - // SENDER.with(|f| { - // f.borrow_mut() - // .as_ref() - // .expect("Not currently drawing") - // .send(Message::AddDrawable(CoreShape::Text(text.0.clone()))) - // .expect("Could not send shape"); - // }) - // } else { - // panic!("Non-drawable passed to draw"); - // } - // } - _ => panic!("Non-drawable passed to draw"), - } + // TODO: this doesn't stop the runtime thread? + let () = params.call_function("draw", figure).unwrap(); SENDER.with(|s| { *s.borrow_mut() = None; -- cgit v1.2.3