diff --git a/CHANGELOG.md b/CHANGELOG.md index 3353634b3..941fdfe75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * `RepaintSignal` now implements `Sync` so it can be sent to a background thread. +### Deprecated + +* Deprecated `color::srgba`. + ## 0.6.0 - 2020-12-26 diff --git a/egui/src/paint/color.rs b/egui/src/paint/color.rs index d837048ff..a4a6c8a30 100644 --- a/egui/src/paint/color.rs +++ b/egui/src/paint/color.rs @@ -25,6 +25,7 @@ impl std::ops::IndexMut for Color32 { } // TODO: remove ? +#[deprecated = "Replaced by Color32::from_rgb… family of functions."] pub const fn srgba(r: u8, g: u8, b: u8, a: u8) -> Color32 { Color32::from_rgba_premultiplied(r, g, b, a) } @@ -108,16 +109,16 @@ impl Color32 { // ---------------------------------------------------------------------------- -pub const TRANSPARENT: Color32 = srgba(0, 0, 0, 0); -pub const BLACK: Color32 = srgba(0, 0, 0, 255); -pub const LIGHT_GRAY: Color32 = srgba(220, 220, 220, 255); -pub const GRAY: Color32 = srgba(160, 160, 160, 255); -pub const WHITE: Color32 = srgba(255, 255, 255, 255); -pub const RED: Color32 = srgba(255, 0, 0, 255); -pub const GREEN: Color32 = srgba(0, 255, 0, 255); -pub const BLUE: Color32 = srgba(0, 0, 255, 255); -pub const YELLOW: Color32 = srgba(255, 255, 0, 255); -pub const LIGHT_BLUE: Color32 = srgba(140, 160, 255, 255); +pub const TRANSPARENT: Color32 = Color32::from_rgba_premultiplied(0, 0, 0, 0); +pub const BLACK: Color32 = Color32::from_rgb(0, 0, 0); +pub const LIGHT_GRAY: Color32 = Color32::from_rgb(220, 220, 220); +pub const GRAY: Color32 = Color32::from_rgb(160, 160, 160); +pub const WHITE: Color32 = Color32::from_rgb(255, 255, 255); +pub const RED: Color32 = Color32::from_rgb(255, 0, 0); +pub const GREEN: Color32 = Color32::from_rgb(0, 255, 0); +pub const BLUE: Color32 = Color32::from_rgb(0, 0, 255); +pub const YELLOW: Color32 = Color32::from_rgb(255, 255, 0); +pub const LIGHT_BLUE: Color32 = Color32::from_rgb(140, 160, 255); // ---------------------------------------------------------------------------- diff --git a/egui/src/paint/tessellator.rs b/egui/src/paint/tessellator.rs index 326dfe029..0d5aad49f 100644 --- a/egui/src/paint/tessellator.rs +++ b/egui/src/paint/tessellator.rs @@ -7,7 +7,7 @@ use { super::{ - color::{self, srgba, Color32, Rgba, TRANSPARENT}, + color::{self, Color32, Rgba, TRANSPARENT}, *, }, crate::math::*, @@ -929,7 +929,7 @@ pub fn tessellate_paint_commands( rect: *clip_rect, corner_radius: 0.0, fill: Default::default(), - stroke: Stroke::new(2.0, srgba(150, 255, 150, 255)), + stroke: Stroke::new(2.0, Color32::from_rgb(150, 255, 150)), }, triangles, ) diff --git a/egui/src/style.rs b/egui/src/style.rs index f84ec0e1b..19ced1f02 100644 --- a/egui/src/style.rs +++ b/egui/src/style.rs @@ -303,28 +303,28 @@ impl Default for Widgets { bg_fill: Rgba::luminance_alpha(0.10, 0.5).into(), bg_stroke: Stroke::new(2.0, WHITE), corner_radius: 4.0, - fg_fill: srgba(120, 120, 200, 255), + fg_fill: Color32::from_rgb(120, 120, 200), fg_stroke: Stroke::new(2.0, WHITE), }, hovered: WidgetVisuals { bg_fill: Rgba::luminance_alpha(0.06, 0.5).into(), bg_stroke: Stroke::new(1.0, Rgba::white_alpha(0.5)), corner_radius: 4.0, - fg_fill: srgba(100, 100, 150, 255), + fg_fill: Color32::from_rgb(100, 100, 150), fg_stroke: Stroke::new(1.5, Color32::gray(240)), }, inactive: WidgetVisuals { bg_fill: Rgba::luminance_alpha(0.04, 0.5).into(), bg_stroke: Stroke::new(1.0, Rgba::white_alpha(0.06)), // default window outline. Should be pretty readable corner_radius: 4.0, - fg_fill: srgba(60, 60, 80, 255), + fg_fill: Color32::from_rgb(60, 60, 80), fg_stroke: Stroke::new(1.0, Color32::gray(200)), // Should NOT look grayed out! }, disabled: WidgetVisuals { bg_fill: Rgba::luminance_alpha(0.02, 0.5).into(), bg_stroke: Stroke::new(0.5, Color32::gray(70)), corner_radius: 4.0, - fg_fill: srgba(50, 50, 50, 255), + fg_fill: Color32::from_rgb(50, 50, 50), fg_stroke: Stroke::new(1.0, Color32::gray(140)), // Should look grayed out }, noninteractive: WidgetVisuals { diff --git a/egui_demo_lib/src/apps/demo/widgets.rs b/egui_demo_lib/src/apps/demo/widgets.rs index b280b31bd..318a7df1e 100644 --- a/egui_demo_lib/src/apps/demo/widgets.rs +++ b/egui_demo_lib/src/apps/demo/widgets.rs @@ -48,8 +48,8 @@ impl Widgets { ui.add(crate::__egui_github_link_file_line!()); ui.horizontal_wrapped_for_text(TextStyle::Body, |ui| { - ui.add(Label::new("Text can have").text_color(srgba(110, 255, 110, 255))); - ui.colored_label(srgba(128, 140, 255, 255), "color"); // Shortcut version + ui.add(Label::new("Text can have").text_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.", );