Browse Source

Use explicit `epaint` over `paint` alias (re-export)

egui reexports the `epaint` crate both under its original name
and under the alias `paint` (for historical reasons)
plot
Emil Ernerfeldt 4 years ago
parent
commit
7dad76b913
  1. 7
      egui/src/containers/collapsing_header.rs
  2. 3
      egui/src/containers/combo_box.rs
  3. 3
      egui/src/containers/frame.rs
  4. 4
      egui/src/containers/resize.rs
  5. 4
      egui/src/containers/scroll_area.rs
  6. 5
      egui/src/containers/window.rs
  7. 4
      egui/src/context.rs
  8. 3
      egui/src/frame_state.rs
  9. 2
      egui/src/input_state.rs
  10. 2
      egui/src/layout.rs
  11. 7
      egui/src/lib.rs
  12. 13
      egui/src/memory.rs
  13. 3
      egui/src/menu.rs
  14. 8
      egui/src/painter.rs
  15. 8
      egui/src/style.rs
  16. 2
      egui/src/ui.rs
  17. 6
      egui/src/widgets/color_picker.rs
  18. 2
      egui/src/widgets/image.rs
  19. 5
      egui/src/widgets/label.rs
  20. 7
      egui/src/widgets/text_edit.rs
  21. 6
      egui_demo_lib/benches/benchmark.rs
  22. 2
      egui_demo_lib/src/apps/color_test.rs
  23. 2
      egui_demo_lib/src/apps/demo/dancing_strings.rs
  24. 5
      egui_glium/src/painter.rs
  25. 7
      egui_web/src/webgl1.rs
  26. 7
      egui_web/src/webgl2.rs

7
egui/src/containers/collapsing_header.rs

@ -1,10 +1,7 @@
use std::hash::Hash;
use crate::{
paint::{Shape, TextStyle},
widgets::Label,
*,
};
use crate::{widgets::Label, *};
use epaint::{Shape, TextStyle};
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]

3
egui/src/containers/combo_box.rs

@ -1,4 +1,5 @@
use crate::{paint::Shape, style::WidgetVisuals, *};
use crate::{style::WidgetVisuals, *};
use epaint::Shape;
/// A drop-down selection menu with a descriptive label.
///

3
egui/src/containers/frame.rs

@ -1,6 +1,7 @@
//! Frame container
use crate::{layers::ShapeIdx, paint::*, *};
use crate::{layers::ShapeIdx, *};
use epaint::*;
/// Color and margin of a rectangular background of a [`Ui`].
#[derive(Clone, Copy, Debug, Default, PartialEq)]

4
egui/src/containers/resize.rs

@ -281,7 +281,7 @@ impl Resize {
if self.with_stroke && corner_response.is_some() {
let rect = Rect::from_min_size(content_ui.min_rect().left_top(), state.desired_size);
let rect = rect.expand(2.0); // breathing room for content
ui.painter().add(paint::Shape::Rect {
ui.painter().add(epaint::Shape::Rect {
rect,
corner_radius: 3.0,
fill: Default::default(),
@ -314,7 +314,7 @@ impl Resize {
}
}
use crate::paint::Stroke;
use epaint::Stroke;
pub fn paint_resize_corner(ui: &mut Ui, response: &Response) {
let stroke = ui.style().interact(response).fg_stroke;

4
egui/src/containers/scroll_area.rs

@ -328,7 +328,7 @@ impl Prepared {
let visuals = ui.style().interact(&response);
ui.painter().add(paint::Shape::Rect {
ui.painter().add(epaint::Shape::Rect {
rect: outer_scroll_rect,
corner_radius,
fill: ui.visuals().extreme_bg_color,
@ -337,7 +337,7 @@ impl Prepared {
// stroke: visuals.bg_stroke,
});
ui.painter().add(paint::Shape::Rect {
ui.painter().add(epaint::Shape::Rect {
rect: handle_rect.expand(-2.0),
corner_radius,
fill: visuals.bg_fill,

5
egui/src/containers/window.rs

@ -1,6 +1,7 @@
// WARNING: the code in here is horrible. It is a behemoth that needs breaking up into simpler parts.
use crate::{paint::*, widgets::*, *};
use crate::{widgets::*, *};
use epaint::*;
use super::*;
@ -611,7 +612,7 @@ fn paint_frame_interaction(
interaction: WindowInteraction,
visuals: style::WidgetVisuals,
) {
use paint::tessellator::path::add_circle_quadrant;
use epaint::tessellator::path::add_circle_quadrant;
let cr = ui.visuals().window_corner_radius;
let Rect { min, max } = rect;

4
egui/src/context.rs

@ -12,9 +12,9 @@ use crate::{
input_state::*,
layers::GraphicLayers,
mutex::{Mutex, MutexGuard},
paint::{stats::*, text::Fonts, *},
*,
};
use epaint::{stats::*, text::Fonts, *};
// ----------------------------------------------------------------------------
@ -383,7 +383,7 @@ impl Context {
/// The egui texture, containing font characters etc.
/// Not valid until first call to [`CtxRef::begin_frame()`].
/// That's because since we don't know the proper `pixels_per_point` until then.
pub fn texture(&self) -> Arc<paint::Texture> {
pub fn texture(&self) -> Arc<epaint::Texture> {
self.fonts().texture()
}

3
egui/src/frame_state.rs

@ -1,4 +1,5 @@
use crate::{paint::ahash, *};
use crate::*;
use epaint::ahash;
/// State that is collected during a frame and then cleared.
/// Short-term (single frame) memory.

2
egui/src/input_state.rs

@ -491,7 +491,7 @@ impl InputState {
events,
} = self;
ui.style_mut().body_text_style = crate::paint::TextStyle::Monospace;
ui.style_mut().body_text_style = epaint::TextStyle::Monospace;
ui.collapsing("Raw Input", |ui| raw.ui(ui));
crate::containers::CollapsingHeader::new("🖱 Pointer")

2
egui/src/layout.rs

@ -538,7 +538,7 @@ impl Layout {
stroke: epaint::Stroke,
painter: &crate::Painter,
) {
use crate::paint::*;
use epaint::*;
let cursor = region.cursor;

7
egui/src/lib.rs

@ -121,11 +121,14 @@ mod ui;
pub mod util;
pub mod widgets;
pub use epaint as paint;
pub use epaint;
pub use epaint::emath;
// Can't add deprecation notice due to https://github.com/rust-lang/rust/issues/30827
pub use emath as math;
pub use epaint as paint; // historical reasons
// Can't add deprecation notice due to https://github.com/rust-lang/rust/issues/30827
pub use emath as math; // historical reasons
pub use emath::{
clamp, lerp, pos2, remap, remap_clamp, vec2, Align, Align2, NumExt, Pos2, Rect, Vec2,

13
egui/src/memory.rs

@ -1,13 +1,10 @@
use std::collections::{HashMap, HashSet};
use crate::{
area, collapsing_header, menu,
paint::color::{Color32, Hsva},
resize, scroll_area,
util::Cache,
widgets::text_edit,
window, Id, LayerId, Pos2, Rect, Style,
area, collapsing_header, menu, resize, scroll_area, util::Cache, widgets::text_edit, window,
Id, LayerId, Pos2, Rect, Style,
};
use epaint::color::{Color32, Hsva};
// ----------------------------------------------------------------------------
@ -68,9 +65,9 @@ pub(crate) struct Options {
#[cfg_attr(feature = "persistence", serde(skip))]
pub(crate) style: std::sync::Arc<Style>,
/// Controls the tessellator.
pub(crate) tessellation_options: crate::paint::TessellationOptions,
pub(crate) tessellation_options: epaint::TessellationOptions,
/// Font sizes etc.
pub(crate) font_definitions: crate::paint::text::FontDefinitions,
pub(crate) font_definitions: epaint::text::FontDefinitions,
}
// ----------------------------------------------------------------------------

3
egui/src/menu.rs

@ -15,7 +15,8 @@
//! }
//! ```
use crate::{paint::Stroke, widgets::*, *};
use crate::{widgets::*, *};
use epaint::Stroke;
/// What is saved between frames.
#[derive(Clone, Copy, Debug, Default)]

8
egui/src/painter.rs

@ -1,12 +1,12 @@
use crate::{
emath::{Align2, Pos2, Rect, Vec2},
layers::{LayerId, ShapeIdx},
paint::{
text::{Fonts, Galley, TextStyle},
Shape, Stroke,
},
Color32, CtxRef,
};
use epaint::{
text::{Fonts, Galley, TextStyle},
Shape, Stroke,
};
/// Helper to paint shapes and text to a specific region on a specific layer.
///

8
egui/src/style.rs

@ -2,12 +2,8 @@
#![allow(clippy::if_same_then_else)]
use crate::{
color::*,
emath::*,
paint::{Shadow, Stroke, TextStyle},
Response,
};
use crate::{color::*, emath::*, Response};
use epaint::{Shadow, Stroke, TextStyle};
/// Specifies the look and feel of a [`Ui`].
#[derive(Clone, Debug, PartialEq)]

2
egui/src/ui.rs

@ -3,7 +3,7 @@
use std::hash::Hash;
use crate::{
color::*, containers::*, layout::*, mutex::MutexGuard, paint::text::Fonts, placer::Placer,
color::*, containers::*, epaint::text::Fonts, layout::*, mutex::MutexGuard, placer::Placer,
widgets::*, *,
};

6
egui/src/widgets/color_picker.rs

@ -1,9 +1,7 @@
//! Color picker widgets.
use crate::{
paint::{color::*, *},
*,
};
use crate::*;
use epaint::{color::*, *};
fn contrast_color(color: impl Into<Rgba>) -> Color32 {
if color.into().intensity() < 0.5 {

2
egui/src/widgets/image.rs

@ -47,7 +47,7 @@ impl Image {
}
pub fn paint_at(&self, ui: &mut Ui, rect: Rect) {
use paint::*;
use epaint::*;
let Self {
texture_id,
uv,

5
egui/src/widgets/label.rs

@ -1,4 +1,5 @@
use crate::{paint::Galley, *};
use crate::*;
use epaint::Galley;
/// Static text.
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
@ -135,7 +136,7 @@ impl Label {
font.layout_multiline(self.text.clone(), wrap_width) // TODO: avoid clone
}
pub fn font_height(&self, fonts: &paint::text::Fonts, style: &Style) -> f32 {
pub fn font_height(&self, fonts: &epaint::text::Fonts, style: &Style) -> f32 {
let text_style = self.text_style_or_default(style);
fonts[text_style].row_height()
}

7
egui/src/widgets/text_edit.rs

@ -1,8 +1,5 @@
use crate::{
paint::{text::cursor::*, *},
util::undoer::Undoer,
*,
};
use crate::{util::undoer::Undoer, *};
use epaint::{text::cursor::*, *};
#[derive(Clone, Debug, Default)]
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]

6
egui_demo_lib/benches/benchmark.rs

@ -60,7 +60,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let pixels_per_point = 1.0;
let wrap_width = 512.0;
let text_style = egui::TextStyle::Body;
let fonts = egui::paint::text::Fonts::from_definitions(
let fonts = egui::epaint::text::Fonts::from_definitions(
pixels_per_point,
egui::FontDefinitions::default(),
);
@ -70,8 +70,8 @@ pub fn criterion_benchmark(c: &mut Criterion) {
});
let galley = font.layout_multiline(LOREM_IPSUM_LONG.to_owned(), wrap_width);
let mut tesselator = egui::paint::Tessellator::from_options(Default::default());
let mut mesh = egui::paint::Mesh::default();
let mut tesselator = egui::epaint::Tessellator::from_options(Default::default());
let mut mesh = egui::epaint::Mesh::default();
c.bench_function("tesselate text", |b| {
b.iter(|| {
let fake_italics = false;

2
egui_demo_lib/src/apps/color_test.rs

@ -299,7 +299,7 @@ impl ColorTest {
}
fn vertex_gradient(ui: &mut Ui, bg_fill: Color32, gradient: &Gradient) -> Response {
use egui::paint::*;
use egui::epaint::*;
let (rect, response) = ui.allocate_at_least(GRADIENT_SIZE, Sense::hover());
if bg_fill != Default::default() {
let mut mesh = Mesh::default();

2
egui_demo_lib/src/apps/demo/dancing_strings.rs

@ -54,7 +54,7 @@ impl super::View for DancingStrings {
.collect();
let thickness = 10.0 / mode;
shapes.push(paint::Shape::line(
shapes.push(epaint::Shape::line(
points,
Stroke::new(thickness, Color32::from_additive_luminance(196)),
));

5
egui_glium/src/painter.rs

@ -1,7 +1,10 @@
#![allow(deprecated)] // legacy implement_vertex macro
use {
egui::{emath::clamp, paint::Mesh, Color32, Rect},
egui::{
emath::{clamp, Rect},
epaint::{Color32, Mesh},
},
glium::{
implement_vertex,
index::PrimitiveType,

7
egui_web/src/webgl1.rs

@ -5,9 +5,8 @@ use {
};
use egui::{
emath::clamp,
paint::{Color32, Texture},
vec2,
emath::{clamp, vec2},
epaint::{Color32, Texture},
};
type Gl = WebGlRenderingContext;
@ -263,7 +262,7 @@ impl WebGlPainter {
}
}
fn paint_mesh(&self, mesh: &egui::paint::Mesh16) -> Result<(), JsValue> {
fn paint_mesh(&self, mesh: &egui::epaint::Mesh16) -> Result<(), JsValue> {
debug_assert!(mesh.is_valid());
let mut positions: Vec<f32> = Vec::with_capacity(2 * mesh.vertices.len());

7
egui_web/src/webgl2.rs

@ -7,9 +7,8 @@ use {
};
use egui::{
emath::clamp,
paint::{Color32, Texture},
vec2,
emath::{clamp, vec2},
epaint::{Color32, Texture},
};
type Gl = WebGl2RenderingContext;
@ -253,7 +252,7 @@ impl WebGl2Painter {
}
}
fn paint_mesh(&self, mesh: &egui::paint::Mesh16) -> Result<(), JsValue> {
fn paint_mesh(&self, mesh: &egui::epaint::Mesh16) -> Result<(), JsValue> {
debug_assert!(mesh.is_valid());
let mut positions: Vec<f32> = Vec::with_capacity(2 * mesh.vertices.len());

Loading…
Cancel
Save