button: elide the label against a minimal inset instead of the horizontal padding
`draw_text_button` elided the label against the granted width less twice `PAD_H`. That padding is 24 design px resolved through the widget-scaling mode, up to 36 logical px in fluid mode, so on a scale-2 laptop each side took 72 physical px off the label area. A PIN key pinned at 80 logical px kept 16 px for its digit: "1" fitted, "2" onwards did not, and `elide` returned "..." although that did not fit either. loginmanager's keys, at 56 dp, ended with a negative area and drew no digit at all. Icon buttons never went through that cut, which is why backspace and OK still showed. The padding belongs to the preferred size of an auto-width button, whose granted rect already contains it, so it has nothing to protect at draw time. A pinned width, or a row shrunk below its preferred width, may leave less than the padding; the label now keeps only `LABEL_INSET`, 4 design px, off the frame and uses the rest of the rect before eliding.
This commit is contained in:
@@ -415,8 +415,9 @@ impl<Msg: Clone> Button<Msg>
|
||||
let fs = self.label_font_size( canvas );
|
||||
let text_y = rect.y + (rect.height + fs) / 2.0 - 2.0;
|
||||
// `rect` is what the layout granted, which is not always the
|
||||
// preferred width: a row that cannot fit its children shrinks them.
|
||||
let label = super::elide( canvas, label, fs, rect.width - canvas.geom_px( theme::PAD_H ) * 2.0 );
|
||||
// preferred width: a pinned width or a shrunk row may leave less
|
||||
// than the padding, so only the inset is kept off the label.
|
||||
let label = super::elide( canvas, label, fs, rect.width - canvas.geom_px( theme::LABEL_INSET ) * 2.0 );
|
||||
let text_c = self.paint_frame( canvas, rect, focused );
|
||||
let text_w = canvas.measure_text( &label, fs );
|
||||
canvas.draw_text(
|
||||
|
||||
Reference in New Issue
Block a user