mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Merge branch 'master' into multiples_viewports
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user