From 0b07c583362bf405d390c940124c5c25911790f0 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 23 May 2025 12:56:32 +0800 Subject: [PATCH] compactify the slider layout this saves some empty vertical space allowing for more info on the screen while sliders happen --- libs/ux-api/src/service/gfx.rs | 2 +- libs/ux-api/src/widgets/modal.rs | 4 +++- libs/ux-api/src/widgets/slider.rs | 11 ++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libs/ux-api/src/service/gfx.rs b/libs/ux-api/src/service/gfx.rs index 15ec5a122..1232a869b 100644 --- a/libs/ux-api/src/service/gfx.rs +++ b/libs/ux-api/src/service/gfx.rs @@ -721,7 +721,7 @@ impl Gfx { let buf = match Buffer::into_buf(list) { Ok(b) => b, Err(e) => { - log::info!("size {}", size); + log::info!("Size {} won't fit", size); log::error!("err: {:?}", e); panic!("error") } diff --git a/libs/ux-api/src/widgets/modal.rs b/libs/ux-api/src/widgets/modal.rs index 8e0000bb8..d363ea852 100644 --- a/libs/ux-api/src/widgets/modal.rs +++ b/libs/ux-api/src/widgets/modal.rs @@ -111,6 +111,7 @@ impl<'a> Modal<'a> { self.gfx.clear().unwrap(); } let mut cur_height = self.margin; + log::debug!("start {}", cur_height); if let Some(mut tv) = self.top_text.as_mut() { if do_redraw { self.gfx.draw_textview(&mut tv).expect("couldn't draw text"); @@ -123,7 +124,7 @@ impl<'a> Modal<'a> { y }; cur_height += y_clip; - log::trace!("top_tv height: {}", y_clip); + log::debug!(" top_tv height: {}", y_clip); self.top_memoized_height = Some(y_clip); } else { log::warn!("text bounds didn't compute setting to max"); @@ -138,6 +139,7 @@ impl<'a> Modal<'a> { self.top_dirty = false; } + log::debug!(" action @ {}", self.line_height); let action_height = self.action.height(self.line_height, self.margin, &self); let action_resolver: Box<&dyn ActionApi> = Box::new(&self.action); diff --git a/libs/ux-api/src/widgets/slider.rs b/libs/ux-api/src/widgets/slider.rs index 96273fb8c..b4d1d0bfd 100644 --- a/libs/ux-api/src/widgets/slider.rs +++ b/libs/ux-api/src/widgets/slider.rs @@ -91,6 +91,7 @@ impl ActionApi for Slider { fn set_action_opcode(&mut self, op: u32) { self.action_opcode = op } fn redraw(&self, at_height: isize, modal: &Modal) { + log::debug!(" slider @ {}", at_height); let color = PixelColor::Light; let fill_color = PixelColor::Dark; @@ -130,7 +131,7 @@ impl ActionApi for Slider { // render current setting tv.bounds_computed = None; tv.bounds_hint = TextBounds::GrowableFromTl( - Point::new(offset, at_height + modal.margin + modal.line_height * 2 + modal.margin), + Point::new(offset, at_height + modal.margin + modal.line_height * 1), maxwidth, ); modal.gfx.draw_textview(&mut tv).expect("couldn't draw legend"); @@ -139,10 +140,10 @@ impl ActionApi for Slider { // the actual slider let mut draw_list = ObjectList::new(); let outer_rect = Rectangle::new_with_style( - Point::new(modal.margin * 2, modal.margin + modal.line_height + at_height), + Point::new(modal.margin * 2, modal.margin + modal.line_height * 0 + at_height), Point::new( modal.canvas_width - modal.margin * 2, - modal.margin + modal.line_height * 2 + at_height, + modal.margin + modal.line_height * 1 + at_height, ), DrawStyle::new(fill_color, color, 2), ); @@ -151,8 +152,8 @@ impl ActionApi for Slider { let slider_point = (total_width * (self.action_payload - self.min) as isize) / (self.max - self.min) as isize; let inner_rect = Rectangle::new_with_style( - Point::new(modal.margin * 2, modal.margin + modal.line_height + at_height), - Point::new(modal.margin * 2 + slider_point, modal.margin + modal.line_height * 2 + at_height), + Point::new(modal.margin * 2, modal.margin + modal.line_height * 0 + at_height), + Point::new(modal.margin * 2 + slider_point, modal.margin + modal.line_height * 1 + at_height), DrawStyle::new(color, color, 1), ); draw_list.push(ClipObjectType::Rect(inner_rect)).unwrap();