mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 21:00:03 -04:00
Merge branch 'master' into multiples_viewports
This commit is contained in:
38
.github/workflows/spelling_and_links.yml
vendored
Normal file
38
.github/workflows/spelling_and_links.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
name: Check spelling and links
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
typos:
|
||||
# https://github.com/crate-ci/typos
|
||||
# Add exceptions to _typos.toml
|
||||
# install and run locally: cargo install typos-cli && typos
|
||||
name: typos
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Actions Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check spelling of entire workspace
|
||||
uses: crate-ci/typos@master
|
||||
# Disabled: too many names of crates and user-names etc
|
||||
# spellcheck:
|
||||
# name: Spellcheck
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# - uses: streetsidesoftware/cspell-action@v2
|
||||
# with:
|
||||
# files: "**/*.md"
|
||||
linkinator:
|
||||
name: linkinator
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: jprochazk/linkinator-action@main
|
||||
with:
|
||||
linksToSkip: "https://crates.io/crates/.*, http://localhost:.*" # Avoid crates.io rate-limiting
|
||||
retry: true
|
||||
retryErrors: true
|
||||
retryErrorsCount: 5
|
||||
retryErrorsJitter: 2000
|
||||
|
||||
17
.github/workflows/typos.yml
vendored
17
.github/workflows/typos.yml
vendored
@@ -1,17 +0,0 @@
|
||||
# https://github.com/crate-ci/typos
|
||||
# Add exceptions to _typos.toml
|
||||
# install and run locally: cargo install typos-cli && typos
|
||||
|
||||
name: Spell Check
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
name: Spell Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Actions Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check spelling of entire workspace
|
||||
uses: crate-ci/typos@master
|
||||
@@ -329,7 +329,7 @@ egui_extras::install_image_loaders(egui_ctx);
|
||||
|
||||
### Contributors 🙏
|
||||
* [4JX](https://github.com/4JX)
|
||||
* [AlexxxRu](https://github.com/AlexxxRu)
|
||||
* [a-liashenko](https://github.com/a-liashenko)
|
||||
* [ascclemens](https://github.com/ascclemens)
|
||||
* [awaken1ng](https://github.com/awaken1ng)
|
||||
* [bigfarts](https://github.com/bigfarts)
|
||||
@@ -425,7 +425,7 @@ egui_extras::install_image_loaders(egui_ctx);
|
||||
* [4JX](https://github.com/4JX)
|
||||
* [55nknown](https://github.com/55nknown)
|
||||
* [AlanRace](https://github.com/AlanRace)
|
||||
* [AlexxxRu](https://github.com/AlexxxRu)
|
||||
* [a-liashenko](https://github.com/a-liashenko)
|
||||
* [awaken1ng](https://github.com/awaken1ng)
|
||||
* [BctfN0HUK7Yg](https://github.com/BctfN0HUK7Yg)
|
||||
* [Bromeon](https://github.com/Bromeon)
|
||||
|
||||
104
Cargo.lock
generated
104
Cargo.lock
generated
@@ -108,14 +108,15 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.3"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
|
||||
checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"version_check",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -445,6 +446,12 @@ version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.21.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2"
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "1.3.3"
|
||||
@@ -503,6 +510,9 @@ name = "bitflags"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block"
|
||||
@@ -1311,7 +1321,7 @@ dependencies = [
|
||||
"enum-map",
|
||||
"image",
|
||||
"log",
|
||||
"mime_guess",
|
||||
"mime_guess2",
|
||||
"puffin",
|
||||
"resvg",
|
||||
"serde",
|
||||
@@ -2437,10 +2447,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||
|
||||
[[package]]
|
||||
name = "mime_guess"
|
||||
version = "2.0.4"
|
||||
name = "mime_guess2"
|
||||
version = "2.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
|
||||
checksum = "25a3333bb1609500601edc766a39b4c1772874a4ce26022f4d866854dc020c41"
|
||||
dependencies = [
|
||||
"mime",
|
||||
"unicase",
|
||||
@@ -2884,11 +2894,11 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
|
||||
|
||||
[[package]]
|
||||
name = "plist"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5329b8f106a176ab0dce4aae5da86bfcb139bb74fb00882859e03745011f3635"
|
||||
checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.21.4",
|
||||
"indexmap 1.9.3",
|
||||
"line-wrap",
|
||||
"quick-xml",
|
||||
@@ -3023,9 +3033,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.26.0"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd"
|
||||
checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
@@ -3216,13 +3226,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ron"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "300a51053b1cb55c80b7a9fde4120726ddf25ca241a1cbb926626f62fb136bff"
|
||||
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bitflags 1.3.2",
|
||||
"base64 0.21.4",
|
||||
"bitflags 2.4.0",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3275,14 +3286,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.20.9"
|
||||
version = "0.21.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99"
|
||||
checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8"
|
||||
dependencies = [
|
||||
"log",
|
||||
"ring",
|
||||
"rustls-webpki",
|
||||
"sct",
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.101.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3967,17 +3988,17 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
||||
|
||||
[[package]]
|
||||
name = "ureq"
|
||||
version = "2.6.2"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "338b31dd1314f68f3aabf3ed57ab922df95ffcd902476ca7ba3c4ce7b908c46d"
|
||||
checksum = "f5ccd538d4a604753ebc2f17cd9946e89b77bf87f6a8e2309667c6f2e87855e3"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.21.4",
|
||||
"flate2",
|
||||
"log",
|
||||
"once_cell",
|
||||
"rustls",
|
||||
"rustls-webpki",
|
||||
"url",
|
||||
"webpki",
|
||||
"webpki-roots",
|
||||
]
|
||||
|
||||
@@ -4006,7 +4027,7 @@ version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b5b7c2b30845b3348c067ca3d09e20cc6e327c288f0ca4c48698712abf432e9"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64 0.13.1",
|
||||
"data-url",
|
||||
"flate2",
|
||||
"imagesize",
|
||||
@@ -4257,24 +4278,11 @@ dependencies = [
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki"
|
||||
version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.22.6"
|
||||
version = "0.25.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
|
||||
dependencies = [
|
||||
"webpki",
|
||||
]
|
||||
checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc"
|
||||
|
||||
[[package]]
|
||||
name = "wgpu"
|
||||
@@ -4809,6 +4817,26 @@ dependencies = [
|
||||
"zvariant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "686b7e407015242119c33dab17b8f61ba6843534de936d94368856528eae4dcc"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.7.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "020f3dfe25dfc38dfea49ce62d5d45ecdd7f0d8a724fa63eb36b6eba4ec76806"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.37",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zvariant"
|
||||
version = "3.15.0"
|
||||
|
||||
@@ -298,7 +298,7 @@ Yes! You can customize the colors, spacing, fonts and sizes of everything using
|
||||
|
||||
This is not yet as powerful as say CSS, [but this is going to improve soon](https://github.com/emilk/egui/issues/3284).
|
||||
|
||||
Here is an example (from https://github.com/AlexxxRu/TinyPomodoro):
|
||||
Here is an example (from https://github.com/a-liashenko/TinyPomodoro):
|
||||
|
||||
<img src="media/pompodoro-skin.png" width="50%">
|
||||
|
||||
@@ -332,7 +332,7 @@ If you want to embed 3D into an egui view there are two options.
|
||||
|
||||
#### `Shape::Callback`
|
||||
Example:
|
||||
* <https://github.com/emilk/egui/blob/master/examples/custom_3d_glow.rs>
|
||||
* <https://github.com/emilk/egui/blob/master/examples/custom_3d_glow/src/main.rs>
|
||||
|
||||
`Shape::Callback` will call your code when egui gets painted, to show anything using whatever the background rendering context is. When using [`eframe`](https://github.com/emilk/egui/tree/master/crates/eframe) this will be [`glow`](https://github.com/grovesNL/glow). Other integrations will give you other rendering contexts, if they support `Shape::Callback` at all.
|
||||
|
||||
|
||||
@@ -16,14 +16,14 @@ pub struct Color32(pub(crate) [u8; 4]);
|
||||
impl std::ops::Index<usize> for Color32 {
|
||||
type Output = u8;
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn index(&self, index: usize) -> &u8 {
|
||||
&self.0[index]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::IndexMut<usize> for Color32 {
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: usize) -> &mut u8 {
|
||||
&mut self.0[index]
|
||||
}
|
||||
@@ -63,23 +63,24 @@ impl Color32 {
|
||||
/// An ugly color that is planned to be replaced before making it to the screen.
|
||||
pub const TEMPORARY_COLOR: Color32 = Color32::from_rgb(64, 254, 0);
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn from_rgb(r: u8, g: u8, b: u8) -> Self {
|
||||
Self([r, g, b, 255])
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn from_rgb_additive(r: u8, g: u8, b: u8) -> Self {
|
||||
Self([r, g, b, 0])
|
||||
}
|
||||
|
||||
/// From `sRGBA` with premultiplied alpha.
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn from_rgba_premultiplied(r: u8, g: u8, b: u8, a: u8) -> Self {
|
||||
Self([r, g, b, a])
|
||||
}
|
||||
|
||||
/// From `sRGBA` WITHOUT premultiplied alpha.
|
||||
#[inline]
|
||||
pub fn from_rgba_unmultiplied(r: u8, g: u8, b: u8, a: u8) -> Self {
|
||||
if a == 255 {
|
||||
Self::from_rgb(r, g, b) // common-case optimization
|
||||
@@ -99,80 +100,83 @@ impl Color32 {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn from_gray(l: u8) -> Self {
|
||||
Self([l, l, l, 255])
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn from_black_alpha(a: u8) -> Self {
|
||||
Self([0, 0, 0, a])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_white_alpha(a: u8) -> Self {
|
||||
Rgba::from_white_alpha(linear_f32_from_linear_u8(a)).into()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn from_additive_luminance(l: u8) -> Self {
|
||||
Self([l, l, l, 0])
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn is_opaque(&self) -> bool {
|
||||
self.a() == 255
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn r(&self) -> u8 {
|
||||
self.0[0]
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn g(&self) -> u8 {
|
||||
self.0[1]
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn b(&self) -> u8 {
|
||||
self.0[2]
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn a(&self) -> u8 {
|
||||
self.0[3]
|
||||
}
|
||||
|
||||
/// Returns an opaque version of self
|
||||
#[inline]
|
||||
pub fn to_opaque(self) -> Self {
|
||||
Rgba::from(self).to_opaque().into()
|
||||
}
|
||||
|
||||
/// Returns an additive version of self
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn additive(self) -> Self {
|
||||
let [r, g, b, _] = self.to_array();
|
||||
Self([r, g, b, 0])
|
||||
}
|
||||
|
||||
/// Is the alpha=0 ?
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn is_additive(self) -> bool {
|
||||
self.a() == 0
|
||||
}
|
||||
|
||||
/// Premultiplied RGBA
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn to_array(&self) -> [u8; 4] {
|
||||
[self.r(), self.g(), self.b(), self.a()]
|
||||
}
|
||||
|
||||
/// Premultiplied RGBA
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn to_tuple(&self) -> (u8, u8, u8, u8) {
|
||||
(self.r(), self.g(), self.b(), self.a())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_srgba_unmultiplied(&self) -> [u8; 4] {
|
||||
Rgba::from(*self).to_srgba_unmultiplied()
|
||||
}
|
||||
@@ -198,6 +202,7 @@ impl Color32 {
|
||||
///
|
||||
/// This is using linear space, which is not perceptually even.
|
||||
/// You may want to use [`Self::gamma_multiply`] instead.
|
||||
#[inline]
|
||||
pub fn linear_multiply(self, factor: f32) -> Color32 {
|
||||
crate::ecolor_assert!(0.0 <= factor && factor <= 1.0);
|
||||
// As an unfortunate side-effect of using premultiplied alpha
|
||||
|
||||
@@ -21,11 +21,13 @@ pub struct Hsva {
|
||||
}
|
||||
|
||||
impl Hsva {
|
||||
#[inline]
|
||||
pub fn new(h: f32, s: f32, v: f32, a: f32) -> Self {
|
||||
Self { h, s, v, a }
|
||||
}
|
||||
|
||||
/// From `sRGBA` with premultiplied alpha
|
||||
#[inline]
|
||||
pub fn from_srgba_premultiplied(srgba: [u8; 4]) -> Self {
|
||||
Self::from_rgba_premultiplied(
|
||||
linear_f32_from_gamma_u8(srgba[0]),
|
||||
@@ -36,6 +38,7 @@ impl Hsva {
|
||||
}
|
||||
|
||||
/// From `sRGBA` without premultiplied alpha
|
||||
#[inline]
|
||||
pub fn from_srgba_unmultiplied(srgba: [u8; 4]) -> Self {
|
||||
Self::from_rgba_unmultiplied(
|
||||
linear_f32_from_gamma_u8(srgba[0]),
|
||||
@@ -46,6 +49,7 @@ impl Hsva {
|
||||
}
|
||||
|
||||
/// From linear RGBA with premultiplied alpha
|
||||
#[inline]
|
||||
pub fn from_rgba_premultiplied(r: f32, g: f32, b: f32, a: f32) -> Self {
|
||||
#![allow(clippy::many_single_char_names)]
|
||||
if a == 0.0 {
|
||||
@@ -61,12 +65,14 @@ impl Hsva {
|
||||
}
|
||||
|
||||
/// From linear RGBA without premultiplied alpha
|
||||
#[inline]
|
||||
pub fn from_rgba_unmultiplied(r: f32, g: f32, b: f32, a: f32) -> Self {
|
||||
#![allow(clippy::many_single_char_names)]
|
||||
let (h, s, v) = hsv_from_rgb([r, g, b]);
|
||||
Hsva { h, s, v, a }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_additive_rgb(rgb: [f32; 3]) -> Self {
|
||||
let (h, s, v) = hsv_from_rgb(rgb);
|
||||
Hsva {
|
||||
@@ -77,11 +83,13 @@ impl Hsva {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_rgb(rgb: [f32; 3]) -> Self {
|
||||
let (h, s, v) = hsv_from_rgb(rgb);
|
||||
Hsva { h, s, v, a: 1.0 }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_srgb([r, g, b]: [u8; 3]) -> Self {
|
||||
Self::from_rgb([
|
||||
linear_f32_from_gamma_u8(r),
|
||||
@@ -92,14 +100,17 @@ impl Hsva {
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#[inline]
|
||||
pub fn to_opaque(self) -> Self {
|
||||
Self { a: 1.0, ..self }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_rgb(&self) -> [f32; 3] {
|
||||
rgb_from_hsv((self.h, self.s, self.v))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_srgb(&self) -> [u8; 3] {
|
||||
let [r, g, b] = self.to_rgb();
|
||||
[
|
||||
@@ -109,6 +120,7 @@ impl Hsva {
|
||||
]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_rgba_premultiplied(&self) -> [f32; 4] {
|
||||
let [r, g, b, a] = self.to_rgba_unmultiplied();
|
||||
let additive = a < 0.0;
|
||||
@@ -120,12 +132,14 @@ impl Hsva {
|
||||
}
|
||||
|
||||
/// Represents additive colors using a negative alpha.
|
||||
#[inline]
|
||||
pub fn to_rgba_unmultiplied(&self) -> [f32; 4] {
|
||||
let Hsva { h, s, v, a } = *self;
|
||||
let [r, g, b] = rgb_from_hsv((h, s, v));
|
||||
[r, g, b, a]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_srgba_premultiplied(&self) -> [u8; 4] {
|
||||
let [r, g, b, a] = self.to_rgba_premultiplied();
|
||||
[
|
||||
@@ -136,6 +150,7 @@ impl Hsva {
|
||||
]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_srgba_unmultiplied(&self) -> [u8; 4] {
|
||||
let [r, g, b, a] = self.to_rgba_unmultiplied();
|
||||
[
|
||||
@@ -148,30 +163,35 @@ impl Hsva {
|
||||
}
|
||||
|
||||
impl From<Hsva> for Rgba {
|
||||
#[inline]
|
||||
fn from(hsva: Hsva) -> Rgba {
|
||||
Rgba(hsva.to_rgba_premultiplied())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Rgba> for Hsva {
|
||||
#[inline]
|
||||
fn from(rgba: Rgba) -> Hsva {
|
||||
Self::from_rgba_premultiplied(rgba.0[0], rgba.0[1], rgba.0[2], rgba.0[3])
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Hsva> for Color32 {
|
||||
#[inline]
|
||||
fn from(hsva: Hsva) -> Color32 {
|
||||
Color32::from(Rgba::from(hsva))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Color32> for Hsva {
|
||||
#[inline]
|
||||
fn from(srgba: Color32) -> Hsva {
|
||||
Hsva::from(Rgba::from(srgba))
|
||||
}
|
||||
}
|
||||
|
||||
/// All ranges in 0-1, rgb is linear.
|
||||
#[inline]
|
||||
pub fn hsv_from_rgb([r, g, b]: [f32; 3]) -> (f32, f32, f32) {
|
||||
#![allow(clippy::many_single_char_names)]
|
||||
let min = r.min(g.min(b));
|
||||
@@ -195,6 +215,7 @@ pub fn hsv_from_rgb([r, g, b]: [f32; 3]) -> (f32, f32, f32) {
|
||||
}
|
||||
|
||||
/// All ranges in 0-1, rgb is linear.
|
||||
#[inline]
|
||||
pub fn rgb_from_hsv((h, s, v): (f32, f32, f32)) -> [f32; 3] {
|
||||
#![allow(clippy::many_single_char_names)]
|
||||
let h = (h.fract() + 1.0).fract(); // wrap
|
||||
|
||||
@@ -13,20 +13,20 @@ pub struct Rgba(pub(crate) [f32; 4]);
|
||||
impl std::ops::Index<usize> for Rgba {
|
||||
type Output = f32;
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn index(&self, index: usize) -> &f32 {
|
||||
&self.0[index]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::IndexMut<usize> for Rgba {
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn index_mut(&mut self, index: usize) -> &mut f32 {
|
||||
&mut self.0[index]
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub(crate) fn f32_hash<H: std::hash::Hasher>(state: &mut H, f: f32) {
|
||||
if f == 0.0 {
|
||||
state.write_u8(0);
|
||||
@@ -57,17 +57,17 @@ impl Rgba {
|
||||
pub const GREEN: Rgba = Rgba::from_rgb(0.0, 1.0, 0.0);
|
||||
pub const BLUE: Rgba = Rgba::from_rgb(0.0, 0.0, 1.0);
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn from_rgba_premultiplied(r: f32, g: f32, b: f32, a: f32) -> Self {
|
||||
Self([r, g, b, a])
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn from_rgba_unmultiplied(r: f32, g: f32, b: f32, a: f32) -> Self {
|
||||
Self([r * a, g * a, b * a, a])
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn from_srgba_premultiplied(r: u8, g: u8, b: u8, a: u8) -> Self {
|
||||
let r = linear_f32_from_gamma_u8(r);
|
||||
let g = linear_f32_from_gamma_u8(g);
|
||||
@@ -76,7 +76,7 @@ impl Rgba {
|
||||
Self::from_rgba_premultiplied(r, g, b, a)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn from_srgba_unmultiplied(r: u8, g: u8, b: u8, a: u8) -> Self {
|
||||
let r = linear_f32_from_gamma_u8(r);
|
||||
let g = linear_f32_from_gamma_u8(g);
|
||||
@@ -85,16 +85,17 @@ impl Rgba {
|
||||
Self::from_rgba_premultiplied(r * a, g * a, b * a, a)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn from_rgb(r: f32, g: f32, b: f32) -> Self {
|
||||
Self([r, g, b, 1.0])
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub const fn from_gray(l: f32) -> Self {
|
||||
Self([l, l, l, 1.0])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_luminance_alpha(l: f32, a: f32) -> Self {
|
||||
crate::ecolor_assert!(0.0 <= l && l <= 1.0);
|
||||
crate::ecolor_assert!(0.0 <= a && a <= 1.0);
|
||||
@@ -102,34 +103,34 @@ impl Rgba {
|
||||
}
|
||||
|
||||
/// Transparent black
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn from_black_alpha(a: f32) -> Self {
|
||||
crate::ecolor_assert!(0.0 <= a && a <= 1.0);
|
||||
Self([0.0, 0.0, 0.0, a])
|
||||
}
|
||||
|
||||
/// Transparent white
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn from_white_alpha(a: f32) -> Self {
|
||||
crate::ecolor_assert!(0.0 <= a && a <= 1.0, "a: {}", a);
|
||||
Self([a, a, a, a])
|
||||
}
|
||||
|
||||
/// Return an additive version of this color (alpha = 0)
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn additive(self) -> Self {
|
||||
let [r, g, b, _] = self.0;
|
||||
Self([r, g, b, 0.0])
|
||||
}
|
||||
|
||||
/// Is the alpha=0 ?
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn is_additive(self) -> bool {
|
||||
self.a() == 0.0
|
||||
}
|
||||
|
||||
/// Multiply with e.g. 0.5 to make us half transparent
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn multiply(self, alpha: f32) -> Self {
|
||||
Self([
|
||||
alpha * self[0],
|
||||
@@ -139,22 +140,22 @@ impl Rgba {
|
||||
])
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn r(&self) -> f32 {
|
||||
self.0[0]
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn g(&self) -> f32 {
|
||||
self.0[1]
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn b(&self) -> f32 {
|
||||
self.0[2]
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn a(&self) -> f32 {
|
||||
self.0[3]
|
||||
}
|
||||
@@ -166,6 +167,7 @@ impl Rgba {
|
||||
}
|
||||
|
||||
/// Returns an opaque version of self
|
||||
#[inline]
|
||||
pub fn to_opaque(&self) -> Self {
|
||||
if self.a() == 0.0 {
|
||||
// Additive or fully transparent black.
|
||||
@@ -181,18 +183,19 @@ impl Rgba {
|
||||
}
|
||||
|
||||
/// Premultiplied RGBA
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn to_array(&self) -> [f32; 4] {
|
||||
[self.r(), self.g(), self.b(), self.a()]
|
||||
}
|
||||
|
||||
/// Premultiplied RGBA
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
pub fn to_tuple(&self) -> (f32, f32, f32, f32) {
|
||||
(self.r(), self.g(), self.b(), self.a())
|
||||
}
|
||||
|
||||
/// unmultiply the alpha
|
||||
#[inline]
|
||||
pub fn to_rgba_unmultiplied(&self) -> [f32; 4] {
|
||||
let a = self.a();
|
||||
if a == 0.0 {
|
||||
@@ -204,6 +207,7 @@ impl Rgba {
|
||||
}
|
||||
|
||||
/// unmultiply the alpha
|
||||
#[inline]
|
||||
pub fn to_srgba_unmultiplied(&self) -> [u8; 4] {
|
||||
let [r, g, b, a] = self.to_rgba_unmultiplied();
|
||||
[
|
||||
@@ -218,7 +222,7 @@ impl Rgba {
|
||||
impl std::ops::Add for Rgba {
|
||||
type Output = Rgba;
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn add(self, rhs: Rgba) -> Rgba {
|
||||
Rgba([
|
||||
self[0] + rhs[0],
|
||||
@@ -232,7 +236,7 @@ impl std::ops::Add for Rgba {
|
||||
impl std::ops::Mul<Rgba> for Rgba {
|
||||
type Output = Rgba;
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn mul(self, other: Rgba) -> Rgba {
|
||||
Rgba([
|
||||
self[0] * other[0],
|
||||
@@ -246,7 +250,7 @@ impl std::ops::Mul<Rgba> for Rgba {
|
||||
impl std::ops::Mul<f32> for Rgba {
|
||||
type Output = Rgba;
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn mul(self, factor: f32) -> Rgba {
|
||||
Rgba([
|
||||
self[0] * factor,
|
||||
@@ -260,7 +264,7 @@ impl std::ops::Mul<f32> for Rgba {
|
||||
impl std::ops::Mul<Rgba> for f32 {
|
||||
type Output = Rgba;
|
||||
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
fn mul(self, rgba: Rgba) -> Rgba {
|
||||
Rgba([
|
||||
self * rgba[0],
|
||||
|
||||
@@ -332,12 +332,12 @@ impl Resize {
|
||||
|
||||
use epaint::Stroke;
|
||||
|
||||
pub fn paint_resize_corner(ui: &mut Ui, response: &Response) {
|
||||
pub fn paint_resize_corner(ui: &Ui, response: &Response) {
|
||||
let stroke = ui.style().interact(response).fg_stroke;
|
||||
paint_resize_corner_with_style(ui, &response.rect, stroke, Align2::RIGHT_BOTTOM);
|
||||
}
|
||||
|
||||
pub fn paint_resize_corner_with_style(ui: &mut Ui, rect: &Rect, stroke: Stroke, corner: Align2) {
|
||||
pub fn paint_resize_corner_with_style(ui: &Ui, rect: &Rect, stroke: Stroke, corner: Align2) {
|
||||
let painter = ui.painter();
|
||||
let cp = painter.round_pos_to_pixels(corner.pos_in_rect(rect));
|
||||
let mut w = 2.0;
|
||||
|
||||
@@ -429,7 +429,7 @@ impl<'open> Window<'open> {
|
||||
.map_or((None, None), |ir| (Some(ir.inner), Some(ir.response)));
|
||||
|
||||
let outer_rect = frame.end(&mut area_content_ui).rect;
|
||||
paint_resize_corner(&mut area_content_ui, &possible, outer_rect, frame_stroke);
|
||||
paint_resize_corner(&area_content_ui, &possible, outer_rect, frame_stroke);
|
||||
|
||||
// END FRAME --------------------------------
|
||||
|
||||
@@ -448,7 +448,7 @@ impl<'open> Window<'open> {
|
||||
|
||||
if let Some(interaction) = interaction {
|
||||
paint_frame_interaction(
|
||||
&mut area_content_ui,
|
||||
&area_content_ui,
|
||||
outer_rect,
|
||||
interaction,
|
||||
ctx.style().visuals.widgets.active,
|
||||
@@ -456,7 +456,7 @@ impl<'open> Window<'open> {
|
||||
} else if let Some(hover_interaction) = hover_interaction {
|
||||
if ctx.input(|i| i.pointer.has_pointer()) {
|
||||
paint_frame_interaction(
|
||||
&mut area_content_ui,
|
||||
&area_content_ui,
|
||||
outer_rect,
|
||||
hover_interaction,
|
||||
ctx.style().visuals.widgets.hovered,
|
||||
@@ -476,12 +476,7 @@ impl<'open> Window<'open> {
|
||||
}
|
||||
}
|
||||
|
||||
fn paint_resize_corner(
|
||||
ui: &mut Ui,
|
||||
possible: &PossibleInteractions,
|
||||
outer_rect: Rect,
|
||||
stroke: Stroke,
|
||||
) {
|
||||
fn paint_resize_corner(ui: &Ui, possible: &PossibleInteractions, outer_rect: Rect, stroke: Stroke) {
|
||||
let corner = if possible.resize_right && possible.resize_bottom {
|
||||
Align2::RIGHT_BOTTOM
|
||||
} else if possible.resize_left && possible.resize_bottom {
|
||||
@@ -758,7 +753,7 @@ fn resize_hover(
|
||||
|
||||
/// Fill in parts of the window frame when we resize by dragging that part
|
||||
fn paint_frame_interaction(
|
||||
ui: &mut Ui,
|
||||
ui: &Ui,
|
||||
rect: Rect,
|
||||
interaction: WindowInteraction,
|
||||
visuals: style::WidgetVisuals,
|
||||
|
||||
@@ -1523,7 +1523,7 @@ impl Context {
|
||||
});
|
||||
|
||||
#[cfg_attr(not(feature = "accesskit"), allow(unused_mut))]
|
||||
let mut platform_output: PlatformOutput = self.output_mut(|o| std::mem::take(o));
|
||||
let mut platform_output: PlatformOutput = self.output_mut(std::mem::take);
|
||||
|
||||
#[cfg(feature = "accesskit")]
|
||||
{
|
||||
|
||||
@@ -221,7 +221,7 @@ impl GridLayout {
|
||||
self.col += 1;
|
||||
}
|
||||
|
||||
fn paint_row(&mut self, cursor: &mut Rect, painter: &Painter) {
|
||||
fn paint_row(&mut self, cursor: &Rect, painter: &Painter) {
|
||||
// handle row color painting based on color-picker function
|
||||
let Some(color_picker) = self.color_picker.as_ref() else {
|
||||
return;
|
||||
@@ -433,9 +433,9 @@ impl Grid {
|
||||
|
||||
// paint first incoming row
|
||||
if is_color {
|
||||
let mut cursor = ui.cursor();
|
||||
let cursor = ui.cursor();
|
||||
let painter = ui.painter();
|
||||
grid.paint_row(&mut cursor, painter);
|
||||
grid.paint_row(&cursor, painter);
|
||||
}
|
||||
|
||||
ui.set_grid(grid);
|
||||
|
||||
@@ -608,7 +608,7 @@ impl MenuState {
|
||||
}
|
||||
|
||||
/// Sense button interaction opening and closing submenu.
|
||||
fn submenu_button_interaction(&mut self, ui: &mut Ui, sub_id: Id, button: &Response) {
|
||||
fn submenu_button_interaction(&mut self, ui: &Ui, sub_id: Id, button: &Response) {
|
||||
let pointer = ui.input(|i| i.pointer.clone());
|
||||
let open = self.is_open(sub_id);
|
||||
if self.moving_towards_current_submenu(&pointer) {
|
||||
|
||||
@@ -317,7 +317,7 @@ fn color_picker_hsvag_2d(ui: &mut Ui, hsva: &mut HsvaGamma, alpha: Alpha) {
|
||||
color_slider_2d(ui, s, v, |s, v| HsvaGamma { s, v, ..opaque }.into());
|
||||
}
|
||||
|
||||
//// Shows a color picker where the user can change the given [`Hsva`] color.
|
||||
/// Shows a color picker where the user can change the given [`Hsva`] color.
|
||||
///
|
||||
/// Returns `true` on change.
|
||||
pub fn color_picker_hsva_2d(ui: &mut Ui, hsva: &mut Hsva, alpha: Alpha) -> bool {
|
||||
|
||||
@@ -269,7 +269,7 @@ impl<'a> Image<'a> {
|
||||
self.size.calc_size(available_size, original_image_size)
|
||||
}
|
||||
|
||||
pub fn load_and_calc_size(&self, ui: &mut Ui, available_size: Vec2) -> Option<Vec2> {
|
||||
pub fn load_and_calc_size(&self, ui: &Ui, available_size: Vec2) -> Option<Vec2> {
|
||||
let image_size = self.load_for_size(ui.ctx(), available_size).ok()?.size()?;
|
||||
Some(self.size.calc_size(available_size, image_size))
|
||||
}
|
||||
@@ -317,7 +317,7 @@ impl<'a> Image<'a> {
|
||||
/// # });
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn paint_at(&self, ui: &mut Ui, rect: Rect) {
|
||||
pub fn paint_at(&self, ui: &Ui, rect: Rect) {
|
||||
paint_texture_load_result(
|
||||
ui,
|
||||
&self.load_for_size(ui.ctx(), rect.size()),
|
||||
|
||||
@@ -548,7 +548,7 @@ impl<'a> Slider<'a> {
|
||||
}
|
||||
|
||||
/// Just the slider, no text
|
||||
fn slider_ui(&mut self, ui: &mut Ui, response: &Response) {
|
||||
fn slider_ui(&mut self, ui: &Ui, response: &Response) {
|
||||
let rect = &response.rect;
|
||||
let position_range = self.position_range(rect);
|
||||
|
||||
|
||||
@@ -876,7 +876,7 @@ fn ccursor_from_accesskit_text_position(
|
||||
/// Check for (keyboard) events to edit the cursor and/or text.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn events(
|
||||
ui: &mut crate::Ui,
|
||||
ui: &crate::Ui,
|
||||
state: &mut TextEditState,
|
||||
text: &mut dyn TextBuffer,
|
||||
galley: &mut Arc<Galley>,
|
||||
@@ -1089,7 +1089,7 @@ fn events(
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
fn paint_cursor_selection(
|
||||
ui: &mut Ui,
|
||||
ui: &Ui,
|
||||
painter: &Painter,
|
||||
pos: Pos2,
|
||||
galley: &Galley,
|
||||
@@ -1131,7 +1131,7 @@ fn paint_cursor_selection(
|
||||
}
|
||||
|
||||
fn paint_cursor_end(
|
||||
ui: &mut Ui,
|
||||
ui: &Ui,
|
||||
row_height: f32,
|
||||
painter: &Painter,
|
||||
pos: Pos2,
|
||||
|
||||
@@ -62,7 +62,7 @@ pub struct BackendPanel {
|
||||
}
|
||||
|
||||
impl BackendPanel {
|
||||
pub fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
pub fn update(&mut self, ctx: &egui::Context, frame: &eframe::Frame) {
|
||||
self.frame_history
|
||||
.on_new_frame(ctx.input(|i| i.time), frame.info().cpu_usage);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ all-features = true
|
||||
|
||||
|
||||
[features]
|
||||
default = ["dep:mime_guess"]
|
||||
default = ["dep:mime_guess2"]
|
||||
|
||||
## Shorthand for enabling the different types of image loaders (`file`, `http`, `image`, `svg`).
|
||||
all_loaders = ["file", "http", "image", "svg"]
|
||||
@@ -33,7 +33,7 @@ all_loaders = ["file", "http", "image", "svg"]
|
||||
datepicker = ["chrono"]
|
||||
|
||||
## Add support for loading images from `file://` URIs.
|
||||
file = ["dep:mime_guess"]
|
||||
file = ["dep:mime_guess2"]
|
||||
|
||||
## Add support for loading images via HTTP.
|
||||
http = ["dep:ehttp"]
|
||||
@@ -83,7 +83,7 @@ document-features = { version = "0.2", optional = true }
|
||||
image = { version = "0.24", optional = true, default-features = false }
|
||||
|
||||
# file feature
|
||||
mime_guess = { version = "2.0.4", optional = true, default-features = false }
|
||||
mime_guess2 = { version = "2", optional = true, default-features = false }
|
||||
|
||||
puffin = { version = "0.16", optional = true }
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ impl BytesLoader for FileLoader {
|
||||
let result = match std::fs::read(&path) {
|
||||
Ok(bytes) => {
|
||||
#[cfg(feature = "mime_guess")]
|
||||
let mime = mime_guess::from_path(&path)
|
||||
let mime = mime_guess2::from_path(&path)
|
||||
.first_raw()
|
||||
.map(|v| v.to_owned());
|
||||
|
||||
|
||||
@@ -665,7 +665,7 @@ fn tessellate_row(
|
||||
point_scale: PointScale,
|
||||
job: &LayoutJob,
|
||||
format_summary: &FormatSummary,
|
||||
row: &mut Row,
|
||||
row: &Row,
|
||||
) -> RowVisuals {
|
||||
if row.glyphs.is_empty() {
|
||||
return Default::default();
|
||||
|
||||
@@ -35,6 +35,7 @@ deny = [
|
||||
|
||||
skip = [
|
||||
{ name = "arrayvec" }, # old version via tiny-skiaz
|
||||
{ name = "base64" }, # small crate, old version from usvg
|
||||
{ name = "libloading" }, # wgpu-hal itself depends on 0.8 while some of its dependencies, like ash and d3d12, depend on 0.7
|
||||
{ name = "memoffset" }, # tiny dependency
|
||||
{ name = "nix" }, # old version via winit
|
||||
|
||||
Reference in New Issue
Block a user