Add Shape::galley_with_color (#1461)
This commit is contained in:
parent
68d5806b41
commit
dffab1c737
3 changed files with 17 additions and 5 deletions
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
use epaint::{
|
use epaint::{
|
||||||
mutex::{Arc, RwLockReadGuard, RwLockWriteGuard},
|
mutex::{Arc, RwLockReadGuard, RwLockWriteGuard},
|
||||||
text::{Fonts, Galley},
|
text::{Fonts, Galley},
|
||||||
CircleShape, RectShape, Rounding, Shape, Stroke, TextShape,
|
CircleShape, RectShape, Rounding, Shape, Stroke,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Helper to paint shapes and text to a specific region on a specific layer.
|
/// Helper to paint shapes and text to a specific region on a specific layer.
|
||||||
|
@ -403,10 +403,7 @@ impl Painter {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn galley_with_color(&self, pos: Pos2, galley: Arc<Galley>, text_color: Color32) {
|
pub fn galley_with_color(&self, pos: Pos2, galley: Arc<Galley>, text_color: Color32) {
|
||||||
if !galley.is_empty() {
|
if !galley.is_empty() {
|
||||||
self.add(TextShape {
|
self.add(Shape::galley_with_color(pos, galley, text_color));
|
||||||
override_text_color: Some(text_color),
|
|
||||||
..TextShape::new(pos, galley)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ All notable changes to the epaint crate will be documented in this file.
|
||||||
* Renamed `AlphaImage` to `FontImage` to discourage any other use for it ([#1412](https://github.com/emilk/egui/pull/1412)).
|
* Renamed `AlphaImage` to `FontImage` to discourage any other use for it ([#1412](https://github.com/emilk/egui/pull/1412)).
|
||||||
* Dark text is darker and more readable on bright backgrounds ([#1412](https://github.com/emilk/egui/pull/1412)).
|
* Dark text is darker and more readable on bright backgrounds ([#1412](https://github.com/emilk/egui/pull/1412)).
|
||||||
* Fix panic when tessellating a [`Shape::Vec`] containing meshes with differing `TextureId`:s ([#1445](https://github.com/emilk/egui/pull/1445)).
|
* Fix panic when tessellating a [`Shape::Vec`] containing meshes with differing `TextureId`:s ([#1445](https://github.com/emilk/egui/pull/1445)).
|
||||||
|
* Added `Shape::galley_with_color` which adds the functionality of `Painter::galley_with_color` into the Shape enum. ([#1461](https://github.com/emilk/egui/pull/1461))
|
||||||
|
|
||||||
|
|
||||||
## 0.17.0 - 2022-02-22
|
## 0.17.0 - 2022-02-22
|
||||||
|
|
|
@ -179,6 +179,20 @@ impl Shape {
|
||||||
TextShape::new(pos, galley).into()
|
TextShape::new(pos, galley).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
/// The text color in the [`Galley`] will be replaced with the given color.
|
||||||
|
pub fn galley_with_color(
|
||||||
|
pos: Pos2,
|
||||||
|
galley: crate::mutex::Arc<Galley>,
|
||||||
|
text_color: Color32,
|
||||||
|
) -> Self {
|
||||||
|
TextShape {
|
||||||
|
override_text_color: Some(text_color),
|
||||||
|
..TextShape::new(pos, galley)
|
||||||
|
}
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn mesh(mesh: Mesh) -> Self {
|
pub fn mesh(mesh: Mesh) -> Self {
|
||||||
crate::epaint_assert!(mesh.is_valid());
|
crate::epaint_assert!(mesh.is_valid());
|
||||||
Self::Mesh(mesh)
|
Self::Mesh(mesh)
|
||||||
|
|
Loading…
Reference in a new issue