Skip to content

Commit

Permalink
fix(egui-extras): move WithAlpha trait to crate top-level to fix pack…
Browse files Browse the repository at this point in the history
…aging error
  • Loading branch information
spmadden committed Jul 9, 2024
1 parent b303891 commit bbb2b96
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 12 additions & 0 deletions libraries/egui_extras/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ pub mod visuals;
pub mod build {
include!(concat!(env!("OUT_DIR"), "/builders.rs"));
}

pub trait WithAlpha {
#[must_use]
fn with_alpha(self, alpha: u8) -> Self;
}
impl WithAlpha for egui::Color32 {
#[must_use]
fn with_alpha(self, alpha: u8) -> Self {
let [r, g, b, _] = self.to_srgba_unmultiplied();
egui::Color32::from_rgba_unmultiplied(r, g, b, alpha)
}
}
14 changes: 1 addition & 13 deletions libraries/egui_extras/src/styles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use std::sync::Arc;

use eframe::{CreationContext, Frame, Storage};
use egui::{Color32, Context, Style};
use egui::{Context, Style};

///
/// Implementation of `eframe::App` that automatically saves the state of the
Expand Down Expand Up @@ -45,15 +45,3 @@ impl eframe::App for StylePersistingApp {
}
}
}

pub trait WithAlpha {
#[must_use]
fn with_alpha(self, alpha: u8) -> Self;
}
impl WithAlpha for Color32 {
#[must_use]
fn with_alpha(self, alpha: u8) -> Self {
let [r, g, b, _] = self.to_srgba_unmultiplied();
Color32::from_rgba_unmultiplied(r, g, b, alpha)
}
}
2 changes: 1 addition & 1 deletion libraries/egui_extras/src/visuals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2024 IROX Contributors
//

use crate::styles::WithAlpha;
use crate::WithAlpha;
use egui::color_picker::show_color;
use egui::{vec2, RichText};

Expand Down

0 comments on commit bbb2b96

Please sign in to comment.