Replace a special Color32::PLACEHOLDER
with widget fallback color
#3727
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces a special
Color32::PLACEHOLDER
which, during text painting, will be replaced withTextShape::fallback_color
.The fallback color is mandatory to set in all text painting. Usually this comes from the current visual style.
This lets users color only parts of a
WidgetText
(using e.g. aLayoutJob
or aGalley
), where the uncolored parts (usingColor32::PLACEHOLDER
) will be replaced by a default widget color (e.g. blue for a hyperlink).For instance, you can color the
⚠️
-emoji red in a piece of text red and leave the rest of the text uncolored. The color of the rest of the text will then depend on wether or not you put that text in a label, a button, or a hyperlink.Overall this simplifies a lot of complexity in the code but comes with a few breaking changes:
TextShape::new
,Shape::galley
, andPainter::galley
now take a fallback color by argumentShape::galley_with_color
has been deprecated (useShape::galley
instead)Painter::galley_with_color
has been deprecated (usePainter::galley
instead)WidgetTextGalley
is gone (useArc<Galley>
instead)WidgetTextJob
is gone (useLayoutJob
instead)RichText::into_text_job
has been replaced withRichText::into_layout_job
WidgetText::into_text_job
has been replaced withWidgetText::into_layout_job