compactify the slider layout

this saves some empty vertical space allowing for more info
on the screen while sliders happen
This commit is contained in:
bunnie 2025-05-23 12:56:32 +08:00
parent f8bbf97724
commit 0b07c58336
3 changed files with 10 additions and 7 deletions

View file

@ -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")
}

View file

@ -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);

View file

@ -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();