mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
@@ -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));
|
||||
};
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ impl Widgets {
|
||||
// Trick so we don't have to add spaces in the text below:
|
||||
ui.spacing_mut().item_spacing.x = ui.fonts()[TextStyle::Body].glyph_width(' ');
|
||||
|
||||
ui.add(Label::new("Text can have").text_color(Color32::from_rgb(110, 255, 110)));
|
||||
ui.label(RichText::new("Text can have").color(Color32::from_rgb(110, 255, 110)));
|
||||
ui.colored_label(Color32::from_rgb(128, 140, 255), "color"); // Shortcut version
|
||||
ui.label("and tooltips.").on_hover_text(
|
||||
"This is a multiline tooltip that demonstrates that you can easily add tooltips to any element.\nThis is the second line.\nThis is the third.",
|
||||
@@ -365,7 +365,7 @@ impl SubTree {
|
||||
) -> Action {
|
||||
if depth > 0
|
||||
&& ui
|
||||
.add(Button::new("delete").text_color(Color32::RED))
|
||||
.button(RichText::new("delete").color(Color32::RED))
|
||||
.clicked()
|
||||
{
|
||||
return Action::Delete;
|
||||
@@ -565,12 +565,7 @@ fn text_layout_ui(ui: &mut egui::Ui) {
|
||||
},
|
||||
);
|
||||
|
||||
job.wrap_width = ui.available_width();
|
||||
|
||||
let galley = ui.fonts().layout_job(job);
|
||||
|
||||
let (response, painter) = ui.allocate_painter(galley.size(), Sense::hover());
|
||||
painter.add(Shape::galley(response.rect.min, galley));
|
||||
ui.label(job);
|
||||
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.add(crate::__egui_github_link_file_line!());
|
||||
|
||||
@@ -465,7 +465,7 @@ fn lorem_ipsum(ui: &mut egui::Ui, text: &str) {
|
||||
ui.with_layout(
|
||||
egui::Layout::top_down(egui::Align::LEFT).with_cross_justify(true),
|
||||
|ui| {
|
||||
ui.add(egui::Label::new(text).weak());
|
||||
ui.label(egui::RichText::new(text).weak());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ fn lorem_ipsum(ui: &mut egui::Ui) {
|
||||
ui.with_layout(
|
||||
egui::Layout::top_down(egui::Align::LEFT).with_cross_justify(true),
|
||||
|ui| {
|
||||
ui.add(egui::Label::new(crate::LOREM_IPSUM_LONG).small().weak());
|
||||
ui.label(egui::RichText::new(crate::LOREM_IPSUM_LONG).small().weak());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -116,9 +116,9 @@ impl epi::App for HttpApp {
|
||||
}
|
||||
Err(error) => {
|
||||
// This should only happen if the fetch API isn't available or something similar.
|
||||
ui.add(
|
||||
egui::Label::new(if error.is_empty() { "Error" } else { error })
|
||||
.text_color(egui::Color32::RED),
|
||||
ui.colored_label(
|
||||
egui::Color32::RED,
|
||||
if error.is_empty() { "Error" } else { error },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user