diff --git a/src/widget/button/mod.rs b/src/widget/button/mod.rs index 10c820d..8ff627f 100644 --- a/src/widget/button/mod.rs +++ b/src/widget/button/mod.rs @@ -415,8 +415,9 @@ impl Button 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( diff --git a/src/widget/button/theme.rs b/src/widget/button/theme.rs index e941697..a0a87b5 100644 --- a/src/widget/button/theme.rs +++ b/src/widget/button/theme.rs @@ -46,3 +46,6 @@ pub const HEIGHT: f32 = 48.0; pub const RADIUS: f32 = 100.0; pub const FONT_SIZE: f32 = 16.0; pub const PAD_H: f32 = 24.0; +/// Smallest gap kept between the label and the frame when the button +/// is narrower than its preferred width (a pinned width, a shrunk row). +pub const LABEL_INSET: f32 = 4.0;