1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 06:40:06 -04:00

Rich text for all widgets (#855)

Introduce `RichText` and `WidgetText`
This commit is contained in:
Emil Ernerfeldt
2021-11-01 21:30:10 +01:00
committed by GitHub
parent 9378cd5c6e
commit 09b8269326
30 changed files with 1121 additions and 712 deletions

View File

@@ -42,13 +42,10 @@ impl super::View for FontBook {
ui.horizontal_wrapped(|ui| {
ui.spacing_mut().item_spacing.x = 0.0;
ui.label("You can add more characters by installing additional fonts with ");
ui.add(
egui::Hyperlink::from_label_and_url(
"Context::set_fonts",
"https://docs.rs/egui/latest/egui/struct.Context.html#method.set_fonts",
)
.text_style(egui::TextStyle::Monospace),
);
ui.add(egui::Hyperlink::from_label_and_url(
egui::RichText::new("Context::set_fonts").text_style(egui::TextStyle::Monospace),
"https://docs.rs/egui/latest/egui/struct.Context.html#method.set_fonts",
));
ui.label(".");
});
@@ -90,10 +87,13 @@ impl super::View for FontBook {
for (&chr, name) in named_chars {
if filter.is_empty() || name.contains(filter) || *filter == chr.to_string() {
let button = egui::Button::new(chr).text_style(text_style).frame(false);
let button = egui::Button::new(
egui::RichText::new(chr.to_string()).text_style(text_style),
)
.frame(false);
let tooltip_ui = |ui: &mut egui::Ui| {
ui.add(egui::Label::new(chr).text_style(text_style));
ui.label(egui::RichText::new(chr.to_string()).text_style(text_style));
ui.label(format!("{}\nU+{:X}\n\nClick to copy", name, chr as u32));
};