Expand plot axes thickness to fit their labels (#3921)

Expand the plot axis thickness as the contained plot axis labels get
wider.

This fixes a problem where the plot labels would otherwise get clipped.


![plot-axis-expansion](https://github.com/emilk/egui/assets/1148717/4500a26e-4a11-401d-9e8e-2d98d02ef3b7)
This commit is contained in:
Emil Ernerfeldt
2024-01-30 12:45:27 +01:00
committed by GitHub
parent 01597fe1a1
commit 527f4bfdf6
5 changed files with 332 additions and 268 deletions
+11 -2
View File
@@ -6,7 +6,7 @@ use crate::{
Color32, Context, FontId,
};
use epaint::{
text::{Fonts, Galley},
text::{Fonts, Galley, LayoutJob},
CircleShape, ClippedShape, RectShape, Rounding, Shape, Stroke,
};
@@ -436,9 +436,18 @@ impl Painter {
self.fonts(|f| f.layout(text, font_id, color, f32::INFINITY))
}
/// Lay out this text layut job in a galley.
///
/// Paint the results with [`Self::galley`].
#[inline]
#[must_use]
pub fn layout_job(&self, layout_job: LayoutJob) -> Arc<Galley> {
self.fonts(|f| f.layout_job(layout_job))
}
/// Paint text that has already been laid out in a [`Galley`].
///
/// You can create the [`Galley`] with [`Self::layout`].
/// You can create the [`Galley`] with [`Self::layout`] or [`Self::layout_job`].
///
/// Any uncolored parts of the [`Galley`] (using [`Color32::PLACEHOLDER`]) will be replaced with the given color.
///