Browse Source

Make color-hex optional (#1632)

pull/1639/head
Erlend Walstad 3 years ago
committed by GitHub
parent
commit
f27f67b76b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      egui/Cargo.toml
  2. 4
      egui/src/lib.rs
  3. 2
      epaint/CHANGELOG.md
  4. 3
      epaint/Cargo.toml
  5. 3
      epaint/src/color.rs
  6. 1
      epaint/src/lib.rs

2
egui/Cargo.toml

@ -46,6 +46,8 @@ persistence = ["serde", "epaint/serde", "ron"]
# implement serde on most types.
serde = ["dep:serde", "epaint/serde"]
# Ease of use hex to Color32 macro
color-hex = ["epaint/color-hex"]
[dependencies]
epaint = { version = "0.18.1", path = "../epaint", default-features = false }

4
egui/src/lib.rs

@ -322,8 +322,10 @@ pub use epaint;
pub use epaint::emath;
pub use emath::{lerp, pos2, remap, remap_clamp, vec2, Align, Align2, NumExt, Pos2, Rect, Vec2};
#[cfg(feature = "color-hex")]
pub use epaint::hex_color;
pub use epaint::{
color, hex_color, mutex,
color, mutex,
text::{FontData, FontDefinitions, FontFamily, FontId, FontTweak},
textures::TexturesDelta,
ClippedPrimitive, Color32, ColorImage, FontImage, ImageData, Mesh, PaintCallback,

2
epaint/CHANGELOG.md

@ -4,7 +4,7 @@ All notable changes to the epaint crate will be documented in this file.
## Unreleased
* Optimize tessellation of filled circles by 10x or more ([#1616](https://github.com/emilk/egui/pull/1616)).
* Added `epaint::hex_rgb*!()` macros to create Color32's from hex strings ([#1596](https://github.com/emilk/egui/pull/1596)).
* Added `epaint::hex_color` macro to create Color32's from hex strings under the `color-hex` feature ([#1596](https://github.com/emilk/egui/pull/1596)).
## 0.18.1 - 2022-05-01
* Change `Shape::Callback` from `&dyn Any` to `&mut dyn Any` to support more backends.

3
epaint/Cargo.toml

@ -53,9 +53,8 @@ emath = { version = "0.18.0", path = "../emath" }
ab_glyph = "0.2.11"
nohash-hasher = "0.2"
color-hex = "0.2.0"
# Optional:
color-hex = { version = "0.2.0", optional = true }
ahash = { version = "0.7", default-features = false, features = ["std"] }
bytemuck = { version = "1.7.2", optional = true, features = ["derive"] }
cint = { version = "0.3.1", optional = true }

3
epaint/src/color.rs

@ -192,6 +192,7 @@ impl Color32 {
/// assert_eq!(hex_color!("#202122"), Color32::from_rgb(0x20, 0x21, 0x22));
/// assert_eq!(hex_color!("#abcdef12"), Color32::from_rgba_unmultiplied(0xab, 0xcd, 0xef, 0x12));
/// ```
#[cfg(feature = "color-hex")]
#[macro_export]
macro_rules! hex_color {
($s:literal) => {{
@ -205,6 +206,7 @@ macro_rules! hex_color {
}};
}
#[cfg(feature = "color-hex")]
#[test]
fn test_from_rgb_hex() {
assert_eq!(Color32::from_rgb(0x20, 0x21, 0x22), hex_color!("#202122"));
@ -214,6 +216,7 @@ fn test_from_rgb_hex() {
);
}
#[cfg(feature = "color-hex")]
#[test]
fn test_from_rgba_hex() {
assert_eq!(

1
epaint/src/lib.rs

@ -49,6 +49,7 @@ pub use emath::{pos2, vec2, Pos2, Rect, Vec2};
pub use ahash;
pub use emath;
#[cfg(feature = "color-hex")]
pub use color_hex;
/// The UV coordinate of a white region of the texture mesh.

Loading…
Cancel
Save