Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgsaa committed Oct 10, 2024
1 parent 438234a commit 3378493
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
17 changes: 10 additions & 7 deletions examples/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ impl App for ExampleApp {
}

if ui.button("Rich text").clicked() {
customize_toast(self.toasts.success(
egui::RichText::new(self.caption.clone())
.color(Color32::GREEN)
.background_color(Color32::DARK_GRAY)
.size(self.font_size)
.italics()
.underline()));
customize_toast(
self.toasts.success(
egui::RichText::new(self.caption.clone())
.color(Color32::GREEN)
.background_color(Color32::DARK_GRAY)
.size(self.font_size)
.italics()
.underline(),
),
);
}

if ui.button("Custom").clicked() {
Expand Down
12 changes: 7 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ pub use toast::*;
mod anchor;
pub use anchor::*;

use crate::ToastCaption::{Simple, WidgetText};
#[doc(hidden)]
pub use egui::__run_test_ctx;
use egui::{vec2, Align, Color32, Context, FontId, FontSelection, Id, LayerId, Order, Rect, RichText, Rounding, Shadow, Stroke, TextWrapMode, Vec2};
use egui::text::TextWrapping;
use crate::ToastCaption::{Simple, WidgetText};
use egui::{
vec2, Align, Color32, Context, FontId, FontSelection, Id, LayerId, Order, Rect, RichText,
Rounding, Shadow, Stroke, TextWrapMode, Vec2,
};

pub(crate) const TOAST_WIDTH: f32 = 180.;
pub(crate) const TOAST_HEIGHT: f32 = 34.;
Expand Down Expand Up @@ -239,12 +242,11 @@ impl Toasts {

let widget_text = match toast.caption {
Simple(ref string) => egui::widget_text::WidgetText::from(
RichText::new(string).color(visuals.fg_stroke.color)
RichText::new(string).color(visuals.fg_stroke.color),
),
WidgetText(ref widget_text) => widget_text.to_owned()
WidgetText(ref widget_text) => widget_text.to_owned(),
};


let caption_galley = widget_text.into_galley_impl(
ctx,
ctx.style().as_ref(),
Expand Down
2 changes: 1 addition & 1 deletion src/toast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,4 @@ impl From<RichText> for ToastCaption {
fn from(text: RichText) -> Self {
Self::WidgetText(text.into())
}
}
}

0 comments on commit 3378493

Please sign in to comment.