Browse Source

Deprecate color::srgba function. Use Color32::from_rgb etc instead.

pull/92/head
Emil Ernerfeldt 4 years ago
parent
commit
64dd186daf
  1. 4
      CHANGELOG.md
  2. 21
      egui/src/paint/color.rs
  3. 4
      egui/src/paint/tessellator.rs
  4. 8
      egui/src/style.rs
  5. 4
      egui_demo_lib/src/apps/demo/widgets.rs

4
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

21
egui/src/paint/color.rs

@ -25,6 +25,7 @@ impl std::ops::IndexMut<usize> 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);
// ----------------------------------------------------------------------------

4
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,
)

8
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 {

4
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.",
);

Loading…
Cancel
Save