From 1d0848ebd2aa7e4225b1aec6658f62838aaf480d Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 22 Apr 2022 09:20:52 -0400 Subject: [PATCH] simplify target_size --- src/function_entry.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/function_entry.rs b/src/function_entry.rs index 2c74146..101b8cc 100644 --- a/src/function_entry.rs +++ b/src/function_entry.rs @@ -116,20 +116,14 @@ impl FunctionEntry { // target size of text edit box let target_size = vec2(ui.available_width(), { - // need to get whether or not the text box has focus so it can be used to get the animated bool value - let had_focus = ui.ctx().memory().has_focus(te_id); - // get the animated bool that stores how "in focus" the text box is - let gotten_focus_value = ui.ctx().animate_bool(te_id, had_focus); - - // multiplier for row_width - let multiplier = if gotten_focus_value == 1.0 { - 2.5 - } else { - 1.0 + (gotten_focus_value * 1.5) + let gotten_focus_value = { + let ctx = ui.ctx(); + let had_focus = ctx.memory().has_focus(te_id); + ctx.animate_bool(te_id, had_focus) }; - row_height * multiplier + row_height * (1.0 + (gotten_focus_value * 1.5)) }); let re = ui.add_sized(