Remove wildcard imports (#5018)

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

I removed (I hope so) all wildcard imports I found.

For me on my pc this improved the build time:
- for egui -5s
- for eframe -12s

* [x] I have followed the instructions in the PR template
This commit is contained in:
Nicolas 2024-08-28 12:18:42 +02:00 committed by GitHub
parent 82036cf59a
commit 343c3d16c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
99 changed files with 423 additions and 208 deletions

View File

@ -118,6 +118,7 @@ unused_qualifications = "allow"
[workspace.lints.rustdoc]
all = "warn"
missing_crate_level_docs = "warn"
broken_intra_doc_links = "warn"
# See also clippy.toml
[workspace.lints.clippy]
@ -248,6 +249,7 @@ use_self = "warn"
useless_transmute = "warn"
verbose_file_reads = "warn"
wildcard_dependencies = "warn"
wildcard_imports = "warn"
zero_sized_map_values = "warn"
# TODO(emilk): enable more of these lints:
@ -262,4 +264,3 @@ unwrap_used = "allow" # TODO(emilk): We really wanna warn on thi
manual_range_contains = "allow" # this one is just worse imho
self_named_module_files = "allow" # Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602
significant_drop_tightening = "allow" # Too many false positives
wildcard_imports = "allow" # we do this a lot in egui

View File

@ -1,4 +1,4 @@
use super::*;
use super::{linear_f32_from_linear_u8, linear_u8_from_linear_f32, Color32, Hsva, HsvaGamma, Rgba};
use cint::{Alpha, ColorInterop, EncodedSrgb, Hsv, LinearSrgb, PremultipliedAlpha};
// ---- Color32 ----

View File

@ -474,4 +474,4 @@ mod profiling_scopes {
}
#[allow(unused_imports)]
pub(crate) use profiling_scopes::*;
pub(crate) use profiling_scopes::{profile_function, profile_scope};

View File

@ -1,4 +1,4 @@
//! Note that this file contains code very similar to [`wgpu_integration`].
//! Note that this file contains code very similar to [`super::wgpu_integration`].
//! When making changes to one you often also want to apply it to the other.
//!
//! This is also very complex code, and not very pretty.
@ -36,13 +36,13 @@ use egui::{
use egui_winit::accesskit_winit;
use crate::{
native::{epi_integration::EpiIntegration, winit_integration::create_egui_context},
App, AppCreator, CreationContext, NativeOptions, Result, Storage,
native::epi_integration::EpiIntegration, App, AppCreator, CreationContext, NativeOptions,
Result, Storage,
};
use super::{
winit_integration::{EventResult, UserEvent, WinitApp},
*,
epi_integration, event_loop_context,
winit_integration::{create_egui_context, EventResult, UserEvent, WinitApp},
};
// ----------------------------------------------------------------------------
@ -462,6 +462,8 @@ impl WinitApp for GlowWinitApp {
#[cfg(feature = "accesskit")]
fn on_accesskit_event(&mut self, event: accesskit_winit::Event) -> crate::Result<EventResult> {
use super::winit_integration;
if let Some(running) = &self.running {
let mut glutin = running.glutin.borrow_mut();
if let Some(viewport_id) = glutin.viewport_from_window.get(&event.window_id).copied() {

View File

@ -1,4 +1,4 @@
//! Note that this file contains code very similar to [`glow_integration`].
//! Note that this file contains code very similar to [`super::glow_integration`].
//! When making changes to one you often also want to apply it to the other.
//!
//! This is also very complex code, and not very pretty.
@ -29,7 +29,7 @@ use crate::{
App, AppCreator, CreationContext, NativeOptions, Result, Storage,
};
use super::{winit_integration::WinitApp, *};
use super::{epi_integration, event_loop_context, winit_integration, winit_integration::WinitApp};
// ----------------------------------------------------------------------------
// Types:

View File

@ -1,4 +1,9 @@
use super::*;
use super::{
button_from_mouse_event, location_hash, modifiers_from_kb_event, modifiers_from_mouse_event,
modifiers_from_wheel_event, pos_from_mouse_event, prefers_color_scheme_dark, primary_touch_pos,
push_touches, text_from_keyboard_event, theme_from_dark_mode, translate_key, AppRunner,
Closure, JsCast, JsValue, WebRunner,
};
use web_sys::EventTarget;
// TODO(emilk): there are more calls to `prevent_default` and `stop_propagaton`

View File

@ -43,7 +43,11 @@ pub use backend::*;
use wasm_bindgen::prelude::*;
use web_sys::MediaQueryList;
use input::*;
use input::{
button_from_mouse_event, modifiers_from_kb_event, modifiers_from_mouse_event,
modifiers_from_wheel_event, pos_from_mouse_event, primary_touch_pos, push_touches,
text_from_keyboard_event, translate_key,
};
// ----------------------------------------------------------------------------

View File

@ -433,4 +433,4 @@ mod profiling_scopes {
}
#[allow(unused_imports)]
pub(crate) use profiling_scopes::*;
pub(crate) use profiling_scopes::{profile_function, profile_scope};

View File

@ -26,7 +26,7 @@ use ahash::HashSet;
use raw_window_handle::HasDisplayHandle;
#[allow(unused_imports)]
pub(crate) use profiling_scopes::*;
pub(crate) use profiling_scopes::{profile_function, profile_scope};
use winit::{
dpi::{PhysicalPosition, PhysicalSize},

View File

@ -2,7 +2,10 @@
//! It has no frame or own size. It is potentially movable.
//! It is the foundation for windows and popups.
use crate::*;
use crate::{
emath, pos2, Align2, Context, Id, InnerResponse, LayerId, NumExt, Order, Pos2, Rect, Response,
Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetRect, WidgetWithState,
};
/// State of an [`Area`] that is persisted between frames.
///
@ -21,8 +24,8 @@ pub struct AreaState {
///
/// Area size is intentionally NOT persisted between sessions,
/// so that a bad tooltip or menu size won't be remembered forever.
/// A resizable [`Window`] remembers the size the user picked using
/// the state in the [`Resize`] container.
/// A resizable [`crate::Window`] remembers the size the user picked using
/// the state in the [`crate::Resize`] container.
#[cfg_attr(feature = "serde", serde(skip))]
pub size: Option<Vec2>,
@ -83,7 +86,7 @@ impl AreaState {
/// An area on the screen that can be moved by dragging.
///
/// This forms the base of the [`Window`] container.
/// This forms the base of the [`crate::Window`] container.
///
/// ```
/// # egui::__run_test_ctx(|ctx| {
@ -232,7 +235,7 @@ impl Area {
/// If the contents are smaller than this size, the area will shrink to fit the contents.
/// If the contents overflow, the area will grow.
///
/// If not set, [`style::Spacing::default_area_size`] will be used.
/// If not set, [`crate::style::Spacing::default_area_size`] will be used.
#[inline]
pub fn default_size(mut self, default_size: impl Into<Vec2>) -> Self {
self.default_size = default_size.into();

View File

@ -1,6 +1,9 @@
use std::hash::Hash;
use crate::*;
use crate::{
emath, epaint, pos2, remap, remap_clamp, vec2, Context, Id, InnerResponse, NumExt, Rect,
Response, Sense, Stroke, TextStyle, TextWrapMode, Ui, Vec2, WidgetInfo, WidgetText, WidgetType,
};
use epaint::Shape;
#[derive(Clone, Copy, Debug)]
@ -15,7 +18,7 @@ pub(crate) struct InnerState {
/// This is a a building block for building collapsing regions.
///
/// It is used by [`CollapsingHeader`] and [`Window`], but can also be used on its own.
/// It is used by [`CollapsingHeader`] and [`crate::Window`], but can also be used on its own.
///
/// See [`CollapsingState::show_header`] for how to show a collapsing header with a custom header.
#[derive(Clone, Debug)]

View File

@ -1,6 +1,10 @@
use epaint::Shape;
use crate::{style::WidgetVisuals, *};
use crate::{
epaint, style::WidgetVisuals, vec2, Align2, Context, Id, InnerResponse, NumExt, Painter,
PopupCloseBehavior, Rect, Response, ScrollArea, Sense, Stroke, TextStyle, TextWrapMode, Ui,
UiBuilder, Vec2, WidgetInfo, WidgetText, WidgetType,
};
#[allow(unused_imports)] // Documentation
use crate::style::Spacing;
@ -150,7 +154,7 @@ impl ComboBox {
/// Controls the wrap mode used for the selected text.
///
/// By default, [`Ui::wrap_mode`] will be used, which can be overridden with [`Style::wrap_mode`].
/// By default, [`Ui::wrap_mode`] will be used, which can be overridden with [`crate::Style::wrap_mode`].
///
/// Note that any `\n` in the text will always produce a new line.
#[inline]

View File

@ -1,7 +1,10 @@
//! Frame container
use crate::{layers::ShapeIdx, *};
use epaint::*;
use crate::{
epaint, layers::ShapeIdx, InnerResponse, Response, Sense, Style, Ui, UiBuilder, UiKind,
UiStackInfo,
};
use epaint::{Color32, Margin, Rect, Rounding, Shadow, Shape, Stroke};
/// Add a background, frame and/or margin to a rectangular background of a [`Ui`].
///

View File

@ -3,7 +3,7 @@
//! Panels can either be a child of a [`Ui`] (taking up a portion of the parent)
//! or be top-level (taking up a portion of the whole screen).
//!
//! Together with [`Window`] and [`Area`]:s, top-level panels are
//! Together with [`crate::Window`] and [`crate::Area`]:s, top-level panels are
//! the only places where you can put you widgets.
//!
//! The order in which you add panels matter!
@ -13,9 +13,12 @@
//!
//! ⚠ Always add any [`CentralPanel`] last.
//!
//! Add your [`Window`]:s after any top-level panels.
//! Add your [`crate::Window`]:s after any top-level panels.
use crate::*;
use crate::{
lerp, vec2, Align, Context, CursorIcon, Frame, Id, InnerResponse, LayerId, Layout, NumExt,
Rangef, Rect, Sense, Stroke, Ui, UiBuilder, UiKind, UiStackInfo, Vec2,
};
fn animate_expansion(ctx: &Context, id: Id, is_expanded: bool) -> f32 {
ctx.animate_bool_responsive(id, is_expanded)
@ -135,9 +138,9 @@ impl SidePanel {
/// If you want your panel to be resizable you also need a widget in it that
/// takes up more space as you resize it, such as:
/// * Wrapping text ([`Ui::horizontal_wrapped`]).
/// * A [`ScrollArea`].
/// * A [`Separator`].
/// * A [`TextEdit`].
/// * A [`crate::ScrollArea`].
/// * A [`crate::Separator`].
/// * A [`crate::TextEdit`].
/// * …
#[inline]
pub fn resizable(mut self, resizable: bool) -> Self {
@ -613,9 +616,9 @@ impl TopBottomPanel {
/// If you want your panel to be resizable you also need a widget in it that
/// takes up more space as you resize it, such as:
/// * Wrapping text ([`Ui::horizontal_wrapped`]).
/// * A [`ScrollArea`].
/// * A [`Separator`].
/// * A [`TextEdit`].
/// * A [`crate::ScrollArea`].
/// * A [`crate::Separator`].
/// * A [`crate::TextEdit`].
/// * …
#[inline]
pub fn resizable(mut self, resizable: bool) -> Self {
@ -633,7 +636,7 @@ impl TopBottomPanel {
}
/// The initial height of the [`TopBottomPanel`], including margins.
/// Defaults to [`style::Spacing::interact_size`].y, plus frame margins.
/// Defaults to [`crate::style::Spacing::interact_size`].y, plus frame margins.
#[inline]
pub fn default_height(mut self, default_height: f32) -> Self {
self.default_height = Some(default_height);
@ -1041,7 +1044,7 @@ impl TopBottomPanel {
///
/// ⚠ [`CentralPanel`] must be added after all other panels!
///
/// NOTE: Any [`Window`]s and [`Area`]s will cover the top-level [`CentralPanel`].
/// NOTE: Any [`crate::Window`]s and [`crate::Area`]s will cover the top-level [`CentralPanel`].
///
/// See the [module level docs](crate::containers::panel) for more details.
///

View File

@ -2,7 +2,11 @@
use frame_state::PerWidgetTooltipState;
use crate::*;
use crate::{
frame_state, vec2, AboveOrBelow, Align, Align2, Area, AreaState, Context, Frame, Id,
InnerResponse, Key, LayerId, Layout, Order, Pos2, Rect, Response, Sense, Ui, UiKind, Vec2,
Widget, WidgetText,
};
// ----------------------------------------------------------------------------
@ -322,14 +326,14 @@ pub fn was_tooltip_open_last_frame(ctx: &Context, widget_id: Id) -> bool {
pub enum PopupCloseBehavior {
/// Popup will be closed on click anywhere, inside or outside the popup.
///
/// It is used in [`ComboBox`].
/// It is used in [`crate::ComboBox`].
CloseOnClick,
/// Popup will be closed if the click happened somewhere else
/// but in the popup's body
CloseOnClickOutside,
/// Clicks will be ignored. Popup might be closed manually by calling [`Memory::close_popup`]
/// Clicks will be ignored. Popup might be closed manually by calling [`crate::Memory::close_popup`]
/// or by pressing the escape button
IgnoreClicks,
}
@ -358,7 +362,7 @@ pub fn popup_below_widget<R>(
///
/// The opened popup will have a minimum width matching its parent.
///
/// You must open the popup with [`Memory::open_popup`] or [`Memory::toggle_popup`].
/// You must open the popup with [`crate::Memory::open_popup`] or [`crate::Memory::toggle_popup`].
///
/// Returns `None` if the popup is not open.
///

View File

@ -1,4 +1,7 @@
use crate::*;
use crate::{
pos2, vec2, Align2, Color32, Context, CursorIcon, Id, NumExt, Rect, Response, Sense, Shape, Ui,
UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b,
};
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
@ -88,7 +91,7 @@ impl Resize {
/// Preferred / suggested height. Actual height will depend on contents.
///
/// Examples:
/// * if the contents is a [`ScrollArea`] then this decides the maximum size.
/// * if the contents is a [`crate::ScrollArea`] then this decides the maximum size.
/// * if the contents is a canvas, this decides the height of it,
/// * if the contents is text and buttons, then the `default_height` is ignored
/// and the height is picked automatically..

View File

@ -1,6 +1,9 @@
#![allow(clippy::needless_range_loop)]
use crate::*;
use crate::{
emath, epaint, frame_state, lerp, pos2, remap, remap_clamp, vec2, Context, Id, NumExt, Pos2,
Rangef, Rect, Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b,
};
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
@ -157,7 +160,7 @@ impl ScrollBarVisibility {
/// # });
/// ```
///
/// You can scroll to an element using [`Response::scroll_to_me`], [`Ui::scroll_to_cursor`] and [`Ui::scroll_to_rect`].
/// You can scroll to an element using [`crate::Response::scroll_to_me`], [`Ui::scroll_to_cursor`] and [`Ui::scroll_to_rect`].
#[derive(Clone, Debug)]
#[must_use = "You should call .show()"]
pub struct ScrollArea {
@ -367,7 +370,7 @@ impl ScrollArea {
/// * If `false`, the scroll area will not respond to user scrolling.
///
/// This can be used, for example, to optionally freeze scrolling while the user
/// is typing text in a [`TextEdit`] widget contained within the scroll area.
/// is typing text in a [`crate::TextEdit`] widget contained within the scroll area.
///
/// This controls both scrolling directions.
#[inline]

View File

@ -3,10 +3,13 @@
use std::sync::Arc;
use crate::collapsing_header::CollapsingState;
use crate::*;
use epaint::*;
use crate::{
Align, Align2, Context, CursorIcon, Id, InnerResponse, LayerId, NumExt, Order, Response, Sense,
TextStyle, Ui, UiKind, Vec2b, WidgetRect, WidgetText,
};
use epaint::{emath, pos2, vec2, Galley, Pos2, Rect, RectShape, Rounding, Shape, Stroke, Vec2};
use super::*;
use super::{area, resize, Area, Frame, Resize, ScrollArea};
/// Builder for a floating window which can be dragged, closed, collapsed, resized and scrolled (off by default).
///

View File

@ -4,24 +4,40 @@ use std::{borrow::Cow, cell::RefCell, panic::Location, sync::Arc, time::Duration
use containers::area::AreaState;
use epaint::{
emath::TSTransform, mutex::*, stats::*, text::Fonts, util::OrderedFloat, TessellationOptions, *,
emath, emath::TSTransform, mutex::RwLock, pos2, stats::PaintStats, tessellator, text::Fonts,
util::OrderedFloat, vec2, ClippedPrimitive, ClippedShape, Color32, ImageData, ImageDelta, Pos2,
Rect, TessellationOptions, TextureAtlas, TextureId, Vec2,
};
use crate::{
animation_manager::AnimationManager,
containers,
data::output::PlatformOutput,
epaint,
frame_state::FrameState,
input_state::*,
hit_test,
input_state::{InputState, MultiTouchInfo, PointerEvent},
interaction,
layers::GraphicLayers,
load,
load::{Bytes, Loaders, SizedTexture},
memory::Options,
menu,
os::OperatingSystem,
output::FullOutput,
resize, scroll_area,
util::IdTypeMap,
viewport::ViewportClass,
TextureHandle, ViewportCommand, *,
Align2, CursorIcon, DeferredViewportUiCallback, FontDefinitions, Grid, Id, ImmediateViewport,
ImmediateViewportRendererCallback, Key, KeyboardShortcut, Label, LayerId, Memory,
ModifierNames, NumExt, Order, Painter, RawInput, Response, RichText, ScrollArea, Sense, Style,
TextStyle, TextureHandle, TextureOptions, Ui, ViewportBuilder, ViewportCommand, ViewportId,
ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportOutput, Widget, WidgetRect, WidgetText,
};
#[cfg(feature = "accesskit")]
use crate::IdMap;
use self::{hit_test::WidgetHits, interaction::InteractionSnapshot};
/// Information given to the backend about when it is time to repaint the ui.
@ -723,7 +739,7 @@ impl Context {
/// Run the ui code for one frame.
///
/// Put your widgets into a [`SidePanel`], [`TopBottomPanel`], [`CentralPanel`], [`Window`] or [`Area`].
/// Put your widgets into a [`crate::SidePanel`], [`crate::TopBottomPanel`], [`crate::CentralPanel`], [`crate::Window`] or [`crate::Area`].
///
/// This will modify the internal reference to point to a new generation of [`Context`].
/// Any old clones of this [`Context`] will refer to the old [`Context`], which will not get new input.
@ -1224,7 +1240,7 @@ impl Context {
/// This is called by [`Response::widget_info`], but can also be called directly.
///
/// With some debug flags it will store the widget info in [`WidgetRects`] for later display.
/// With some debug flags it will store the widget info in [`crate::WidgetRects`] for later display.
#[inline]
pub fn register_widget_info(&self, id: Id, make_info: impl Fn() -> crate::WidgetInfo) {
#[cfg(debug_assertions)]
@ -1326,7 +1342,7 @@ impl Context {
/// Format the given shortcut in a human-readable way (e.g. `Ctrl+Shift+X`).
///
/// Can be used to get the text for [`Button::shortcut_text`].
/// Can be used to get the text for [`crate::Button::shortcut_text`].
pub fn format_shortcut(&self, shortcut: &KeyboardShortcut) -> String {
let os = self.os();
@ -1623,7 +1639,7 @@ impl Context {
self.options_mut(|opt| opt.style = style.into());
}
/// The [`Visuals`] used by all subsequent windows, panels etc.
/// The [`crate::Visuals`] used by all subsequent windows, panels etc.
///
/// You can also use [`Ui::visuals_mut`] to change the visuals of a single [`Ui`].
///
@ -1656,7 +1672,7 @@ impl Context {
/// The number of physical pixels for each logical point on this monitor.
///
/// This is given as input to egui via [`ViewportInfo::native_pixels_per_point`]
/// This is given as input to egui via [`crate::ViewportInfo::native_pixels_per_point`]
/// and cannot be changed.
#[inline(always)]
pub fn native_pixels_per_point(&self) -> Option<f32> {
@ -1744,7 +1760,7 @@ impl Context {
///
/// The given name can be useful for later debugging, and will be visible if you call [`Self::texture_ui`].
///
/// For how to load an image, see [`ImageData`] and [`ColorImage::from_rgba_unmultiplied`].
/// For how to load an image, see [`crate::ImageData`] and [`crate::ColorImage::from_rgba_unmultiplied`].
///
/// ```
/// struct MyImage {
@ -2263,7 +2279,7 @@ impl Context {
/// True if egui is currently interested in the pointer (mouse or touch).
///
/// Could be the pointer is hovering over a [`Window`] or the user is dragging a widget.
/// Could be the pointer is hovering over a [`crate::Window`] or the user is dragging a widget.
/// If `false`, the pointer is outside of any egui area and so
/// you may be interested in what it is doing (e.g. controlling your game).
/// Returns `false` if a drag started outside of egui and then moved over an egui area.
@ -2279,7 +2295,7 @@ impl Context {
self.memory(|m| m.interaction().is_using_pointer())
}
/// If `true`, egui is currently listening on text input (e.g. typing text in a [`TextEdit`]).
/// If `true`, egui is currently listening on text input (e.g. typing text in a [`crate::TextEdit`]).
pub fn wants_keyboard_input(&self) -> bool {
self.memory(|m| m.focused().is_some())
}
@ -2320,7 +2336,7 @@ impl Context {
/// If you detect a click or drag and wants to know where it happened, use this.
///
/// Latest position of the mouse, but ignoring any [`Event::PointerGone`]
/// Latest position of the mouse, but ignoring any [`crate::Event::PointerGone`]
/// if there were interactions this frame.
/// When tapping a touch screen, this will be the location of the touch.
#[inline(always)]
@ -2389,7 +2405,7 @@ impl Context {
/// Moves the given area to the top in its [`Order`].
///
/// [`Area`]:s and [`Window`]:s also do this automatically when being clicked on or interacted with.
/// [`crate::Area`]:s and [`crate::Window`]:s also do this automatically when being clicked on or interacted with.
pub fn move_to_top(&self, layer_id: LayerId) {
self.memory_mut(|mem| mem.areas_mut().move_to_top(layer_id));
}
@ -2397,7 +2413,7 @@ impl Context {
/// Mark the `child` layer as a sublayer of `parent`.
///
/// Sublayers are moved directly above the parent layer at the end of the frame. This is mainly
/// intended for adding a new [`Area`] inside a [`Window`].
/// intended for adding a new [`crate::Area`] inside a [`crate::Window`].
///
/// This currently only supports one level of nesting. If `parent` is a sublayer of another
/// layer, the behavior is unspecified.
@ -2582,7 +2598,7 @@ impl Context {
/// Show the state of egui, including its input and output.
pub fn inspection_ui(&self, ui: &mut Ui) {
use crate::containers::*;
use crate::containers::CollapsingHeader;
ui.label(format!("Is using pointer: {}", self.is_using_pointer()))
.on_hover_text(
@ -2985,7 +3001,7 @@ impl Context {
}
}
/// Release all memory and textures related to images used in [`Ui::image`] or [`Image`].
/// Release all memory and textures related to images used in [`Ui::image`] or [`crate::Image`].
///
/// If you attempt to load any images again, they will be reloaded from scratch.
pub fn forget_all_images(&self) {

View File

@ -2,7 +2,10 @@
use epaint::ColorImage;
use crate::{emath::*, Key, Theme, ViewportId, ViewportIdMap};
use crate::{
emath::{Pos2, Rect, Vec2},
Key, Theme, ViewportId, ViewportIdMap,
};
/// What the integrations provides to egui at the start of each frame.
///

View File

@ -5,7 +5,9 @@
//! The plugin registers itself onto a specific [`Context`]
//! to get callbacks on certain events ([`Context::on_begin_frame`], [`Context::on_end_frame`]).
use crate::*;
use crate::{
text, Align, Align2, Color32, Context, FontFamily, FontId, Id, Rect, Shape, Vec2, WidgetText,
};
/// Register this plugin on the given egui context,
/// so that it will be called every frame.

View File

@ -1,6 +1,9 @@
use ahash::{HashMap, HashSet};
use crate::{id::IdSet, *};
use crate::{id::IdSet, style, Align, Id, IdMap, LayerId, Rangef, Rect, Vec2, WidgetRects};
#[cfg(debug_assertions)]
use crate::{pos2, Align2, Color32, FontId, NumExt, Painter};
/// Reset at the start of each frame.
#[derive(Clone, Debug, Default)]
@ -184,12 +187,12 @@ pub struct FrameState {
pub tooltips: TooltipFrameState,
/// Starts off as the `screen_rect`, shrinks as panels are added.
/// The [`CentralPanel`] does not change this.
/// The [`crate::CentralPanel`] does not change this.
/// This is the area available to Window's.
pub available_rect: Rect,
/// Starts off as the `screen_rect`, shrinks as panels are added.
/// The [`CentralPanel`] retracts from this.
/// The [`crate::CentralPanel`] retracts from this.
pub unused_rect: Rect,
/// How much space is used by panels.

View File

@ -1,4 +1,10 @@
use crate::*;
use crate::{
vec2, Align2, Color32, Context, Id, InnerResponse, NumExt, Painter, Rect, Region, Style, Ui,
UiBuilder, Vec2,
};
#[cfg(debug_assertions)]
use crate::Stroke;
#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct State {
@ -382,7 +388,7 @@ impl Grid {
}
/// Change which row number the grid starts on.
/// This can be useful when you have a large [`Grid`] inside of [`ScrollArea::show_rows`].
/// This can be useful when you have a large [`crate::Grid`] inside of [`crate::ScrollArea::show_rows`].
#[inline]
pub fn start_row(mut self, start_row: usize) -> Self {
self.start_row = start_row;

View File

@ -1,10 +1,10 @@
//! Helpers for zooming the whole GUI of an app (changing [`Context::pixels_per_point`].
//!
use crate::*;
use crate::{Button, Context, Key, KeyboardShortcut, Modifiers, Ui};
/// The suggested keyboard shortcuts for global gui zooming.
pub mod kb_shortcuts {
use super::*;
use super::{Key, KeyboardShortcut, Modifiers};
/// Primary keyboard shortcut for zooming in (`Cmd` + `+`).
pub const ZOOM_IN: KeyboardShortcut = KeyboardShortcut::new(Modifiers::COMMAND, Key::Plus);

View File

@ -2,7 +2,7 @@ use ahash::HashMap;
use emath::TSTransform;
use crate::*;
use crate::{ahash, emath, LayerId, Pos2, WidgetRect, WidgetRects};
/// Result of a hit-test against [`WidgetRects`].
///
@ -333,6 +333,10 @@ fn find_closest(widgets: impl Iterator<Item = WidgetRect>, pos: Pos2) -> Option<
#[cfg(test)]
mod tests {
use emath::{pos2, vec2, Rect};
use crate::{Id, Sense};
use super::*;
fn wr(id: Id, sense: Sense, rect: Rect) -> WidgetRect {

View File

@ -1,7 +1,13 @@
mod touch_state;
use crate::data::input::*;
use crate::{emath::*, util::History};
use crate::data::input::{
Event, EventFilter, KeyboardShortcut, Modifiers, MouseWheelUnit, PointerButton, RawInput,
TouchDeviceId, ViewportInfo, NUM_POINTER_BUTTONS,
};
use crate::{
emath::{vec2, NumExt, Pos2, Rect, Vec2},
util::History,
};
use std::{
collections::{BTreeMap, HashSet},
time::Duration,

View File

@ -1,6 +1,6 @@
//! How mouse and touch interzcts with widgets.
use crate::*;
use crate::{hit_test, id, input_state, memory, Id, InputState, Key, WidgetRects};
use self::{hit_test::WidgetHits, id::IdSet, input_state::PointerEvent, memory::InteractionState};
@ -28,7 +28,7 @@ pub struct InteractionSnapshot {
/// Set the same frame a drag starts,
/// but unset the frame a drag ends.
///
/// NOTE: this may not have a corresponding [`WidgetRect`],
/// NOTE: this may not have a corresponding [`crate::WidgetRect`],
/// if this for instance is a drag-and-drop widget which
/// isn't painted whilst being dragged
pub dragged: Option<Id>,

View File

@ -1,5 +1,8 @@
//! Showing UI:s for egui/epaint types.
use crate::*;
use crate::{
epaint, memory, pos2, remap_clamp, vec2, Color32, CursorIcon, FontFamily, FontId, Label, Mesh,
NumExt, Rect, Response, Sense, Shape, Slider, TextStyle, TextWrapMode, Ui, Widget,
};
pub fn font_family_ui(ui: &mut Ui, font_family: &mut FontFamily) {
let families = ui.fonts(|f| f.families());

View File

@ -1,7 +1,7 @@
//! Handles paint layers, i.e. how things
//! are sometimes painted behind or in front of other things.
use crate::{Id, *};
use crate::{ahash, epaint, Id, IdMap, Rect};
use epaint::{emath::TSTransform, ClippedShape, Shape};
/// Different layer categories
@ -67,7 +67,7 @@ impl Order {
}
/// An identifier for a paint layer.
/// Also acts as an identifier for [`Area`]:s.
/// Also acts as an identifier for [`crate::Area`]:s.
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct LayerId {

View File

@ -1,4 +1,7 @@
use crate::{emath::*, Align};
use crate::{
emath::{pos2, vec2, Align2, NumExt, Pos2, Rect, Vec2},
Align,
};
use std::f32::INFINITY;
// ----------------------------------------------------------------------------

View File

@ -695,4 +695,4 @@ mod profiling_scopes {
}
#[allow(unused_imports)]
pub(crate) use profiling_scopes::*;
pub(crate) use profiling_scopes::{profile_function, profile_scope};

View File

@ -1,4 +1,7 @@
use super::*;
use super::{
generate_loader_id, Bytes, BytesLoadResult, BytesLoader, BytesPoll, Context, Cow, HashMap,
LoadError, Mutex,
};
/// Maps URI:s to [`Bytes`], e.g. found with `include_bytes!`.
///

View File

@ -1,4 +1,7 @@
use super::*;
use super::{
BytesLoader, Context, HashMap, ImagePoll, Mutex, SizeHint, SizedTexture, TextureHandle,
TextureLoadResult, TextureLoader, TextureOptions, TexturePoll,
};
#[derive(Default)]
pub struct DefaultTextureLoader {

View File

@ -361,7 +361,7 @@ impl Options {
ui.checkbox(reduce_texture_memory, "Reduce texture memory");
});
use crate::containers::*;
use crate::containers::CollapsingHeader;
CollapsingHeader::new("🎑 Style")
.default_open(true)
.show(ui, |ui| {

View File

@ -19,7 +19,12 @@ use super::{
style::WidgetVisuals, Align, Context, Id, InnerResponse, PointerState, Pos2, Rect, Response,
Sense, TextStyle, Ui, Vec2,
};
use crate::{widgets::*, *};
use crate::{
epaint, vec2,
widgets::{Button, ImageButton},
Align2, Area, Color32, Frame, Key, LayerId, Layout, NumExt, Order, Stroke, Style, TextWrapMode,
UiKind, WidgetText,
};
use epaint::mutex::RwLock;
use std::sync::Arc;
@ -77,8 +82,8 @@ fn set_menu_style(style: &mut Style) {
style.visuals.widgets.inactive.bg_stroke = Stroke::NONE;
}
/// The menu bar goes well in a [`TopBottomPanel::top`],
/// but can also be placed in a [`Window`].
/// The menu bar goes well in a [`crate::TopBottomPanel::top`],
/// but can also be placed in a [`crate::Window`].
/// In the latter case you may want to wrap it in [`Frame`].
pub fn bar<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
ui.horizontal(|ui| {

View File

@ -391,7 +391,7 @@ impl Painter {
/// Show an arrow starting at `origin` and going in the direction of `vec`, with the length `vec.length()`.
pub fn arrow(&self, origin: Pos2, vec: Vec2, stroke: impl Into<Stroke>) {
use crate::emath::*;
use crate::emath::Rot2;
let rot = Rot2::from_angle(std::f32::consts::TAU / 10.0);
let tip_length = vec.length() / 4.0;
let tip = origin + vec;

View File

@ -1,7 +1,10 @@
use crate::*;
use crate::{grid, vec2, Layout, Painter, Pos2, Rect, Region, Vec2};
#[cfg(debug_assertions)]
use crate::{Align2, Color32, Stroke};
pub(crate) struct Placer {
/// If set this will take precedence over [`layout`].
/// If set this will take precedence over [`crate::layout`].
grid: Option<grid::GridLayout>,
layout: Layout,
region: Region,

View File

@ -7,8 +7,10 @@ use std::{collections::BTreeMap, ops::RangeInclusive, sync::Arc};
use epaint::{Rounding, Shadow, Stroke};
use crate::{
ecolor::*, emath::*, ComboBox, CursorIcon, FontFamily, FontId, Grid, Margin, Response,
RichText, TextWrapMode, WidgetText,
ecolor::Color32,
emath::{pos2, vec2, Rangef, Rect, Vec2},
ComboBox, CursorIcon, FontFamily, FontId, Grid, Margin, Response, RichText, TextWrapMode,
WidgetText,
};
/// How to format numbers in e.g. a [`crate::DragValue`].
@ -361,7 +363,7 @@ pub struct Spacing {
/// Default (minimum) width of a [`ComboBox`].
pub combo_width: f32,
/// Default width of a [`TextEdit`].
/// Default width of a [`crate::TextEdit`].
pub text_edit_width: f32,
/// Checkboxes, radio button and collapsing headers have an icon at the start.
@ -887,7 +889,7 @@ pub struct Visuals {
pub selection: Selection,
/// The color used for [`Hyperlink`],
/// The color used for [`crate::Hyperlink`],
pub hyperlink_color: Color32,
/// Something just barely different from the background color.
@ -1489,7 +1491,10 @@ impl Default for Widgets {
// ----------------------------------------------------------------------------
use crate::{widgets::*, Ui};
use crate::{
widgets::{reset_button, Button, DragValue, Slider, Widget},
Ui,
};
impl Style {
pub fn ui(&mut self, ui: &mut crate::Ui) {

View File

@ -1,4 +1,7 @@
use epaint::{text::cursor::*, Galley};
use epaint::{
text::cursor::{CCursor, Cursor, PCursor},
Galley,
};
use crate::{os::OperatingSystem, Event, Id, Key, Modifiers};

View File

@ -1,8 +1,11 @@
//! Text cursor changes/interaction, without modifying the text.
use epaint::text::{cursor::*, Galley};
use epaint::text::{
cursor::{CCursor, Cursor},
Galley,
};
use crate::*;
use crate::{epaint, NumExt, Pos2, Rect, Response, Ui};
use super::{CCursorRange, CursorRange};

View File

@ -1,6 +1,6 @@
use std::sync::Arc;
use crate::*;
use crate::{pos2, vec2, Galley, Painter, Rect, Ui, Visuals};
use super::CursorRange;

View File

@ -6,9 +6,29 @@ use std::{any::Any, hash::Hash, sync::Arc};
use epaint::mutex::RwLock;
use crate::{
containers::*, ecolor::*, epaint::text::Fonts, layout::*, menu::MenuState, placer::Placer,
util::IdTypeMap, widgets::*, *,
containers::{CollapsingHeader, CollapsingResponse, Frame},
ecolor::Hsva,
emath, epaint,
epaint::text::Fonts,
frame_state, grid,
layout::{Direction, Layout},
menu,
menu::MenuState,
placer::Placer,
pos2, style,
util::IdTypeMap,
vec2, widgets,
widgets::{
color_picker, Button, Checkbox, DragValue, Hyperlink, Image, ImageSource, Label, Link,
RadioButton, SelectableLabel, Separator, Spinner, TextEdit, Widget,
},
Align, Color32, Context, CursorIcon, DragAndDrop, Id, InnerResponse, InputState, LayerId,
Memory, Order, Painter, PlatformOutput, Pos2, Rangef, Rect, Response, Rgba, RichText, Sense,
Style, TextStyle, TextWrapMode, UiBuilder, UiStack, UiStackInfo, Vec2, WidgetRect, WidgetText,
};
#[cfg(debug_assertions)]
use crate::Stroke;
// ----------------------------------------------------------------------------
/// This is what you use to place widgets.
@ -78,7 +98,7 @@ impl Ui {
/// Create a new top-level [`Ui`].
///
/// Normally you would not use this directly, but instead use
/// [`SidePanel`], [`TopBottomPanel`], [`CentralPanel`], [`Window`] or [`Area`].
/// [`crate::SidePanel`], [`crate::TopBottomPanel`], [`crate::CentralPanel`], [`crate::Window`] or [`crate::Area`].
pub fn new(ctx: Context, layer_id: LayerId, id: Id, ui_builder: UiBuilder) -> Self {
let UiBuilder {
id_source,
@ -1275,7 +1295,7 @@ impl Ui {
/// # Scrolling
impl Ui {
/// Adjust the scroll position of any parent [`ScrollArea`] so that the given [`Rect`] becomes visible.
/// Adjust the scroll position of any parent [`crate::ScrollArea`] so that the given [`Rect`] becomes visible.
///
/// If `align` is [`Align::TOP`] it means "put the top of the rect at the top of the scroll area", etc.
/// If `align` is `None`, it'll scroll enough to bring the cursor into view.
@ -1314,7 +1334,7 @@ impl Ui {
}
}
/// Adjust the scroll position of any parent [`ScrollArea`] so that the cursor (where the next widget goes) becomes visible.
/// Adjust the scroll position of any parent [`crate::ScrollArea`] so that the cursor (where the next widget goes) becomes visible.
///
/// If `align` is [`Align::TOP`] it means "put the top of the rect at the top of the scroll area", etc.
/// If `align` is not provided, it'll scroll enough to bring the cursor into view.
@ -1356,7 +1376,7 @@ impl Ui {
}
}
/// Scroll this many points in the given direction, in the parent [`ScrollArea`].
/// Scroll this many points in the given direction, in the parent [`crate::ScrollArea`].
///
/// The delta dictates how the _content_ (i.e. this UI) should move.
///
@ -1366,7 +1386,7 @@ impl Ui {
/// A positive Y-value indicates the content is being moved down,
/// as when swiping down on a touch-screen or track-pad with natural scrolling.
///
/// If this is called multiple times per frame for the same [`ScrollArea`], the deltas will be summed.
/// If this is called multiple times per frame for the same [`crate::ScrollArea`], the deltas will be summed.
///
/// /// See also: [`Response::scroll_to_me`], [`Ui::scroll_to_rect`], [`Ui::scroll_to_cursor`]
///
@ -1935,7 +1955,7 @@ impl Ui {
/// # });
/// ```
///
/// Using [`include_image`] is often the most ergonomic, and the path
/// Using [`crate::include_image`] is often the most ergonomic, and the path
/// will be resolved at compile-time and embedded in the binary.
/// When using a "file://" url on the other hand, you need to make sure
/// the files can be found in the right spot at runtime!

View File

@ -1,6 +1,6 @@
use ahash::HashMap;
use crate::*;
use crate::{Id, IdMap, LayerId, Rect, Sense, WidgetInfo};
/// Used to store each widget's [Id], [Rect] and [Sense] each frame.
///
@ -12,9 +12,9 @@ pub struct WidgetRect {
/// For interactive widgets, this better be globally unique.
/// If not there will be weird bugs,
/// and also big red warning test on the screen in debug builds
/// (see [`Options::warn_on_id_clash`]).
/// (see [`crate::Options::warn_on_id_clash`]).
///
/// You can ensure globally unique ids using [`Ui::push_id`].
/// You can ensure globally unique ids using [`crate::Ui::push_id`].
pub id: Id,
/// What layer the widget is on.
@ -44,8 +44,8 @@ pub struct WidgetRect {
/// Stores the [`WidgetRect`]s of all widgets generated during a single egui update/frame.
///
/// All [`Ui`]s have a [`WidgetRects`], but whether or not their rects are correct
/// depends on if [`Ui::interact_bg`] was ever called.
/// All [`crate::Ui`]s have a [`WidgetRects`], but whether or not their rects are correct
/// depends on if [`crate::Ui::interact_bg`] was ever called.
#[derive(Default, Clone)]
pub struct WidgetRects {
/// All widgets, in painting order.

View File

@ -1,4 +1,7 @@
use crate::*;
use crate::{
widgets, Align, Color32, Image, NumExt, Rect, Response, Rounding, Sense, Stroke, TextStyle,
TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetType,
};
/// Clickable button with text.
///
@ -72,7 +75,7 @@ impl<'a> Button<'a> {
/// Set the wrap mode for the text.
///
/// By default, [`Ui::wrap_mode`] will be used, which can be overridden with [`Style::wrap_mode`].
/// By default, [`crate::Ui::wrap_mode`] will be used, which can be overridden with [`crate::Style::wrap_mode`].
///
/// Note that any `\n` in the text will always produce a new line.
#[inline]
@ -157,7 +160,7 @@ impl<'a> Button<'a> {
///
/// Designed for menu buttons, for setting a keyboard shortcut text (e.g. `Ctrl+S`).
///
/// The text can be created with [`Context::format_shortcut`].
/// The text can be created with [`crate::Context::format_shortcut`].
#[inline]
pub fn shortcut_text(mut self, shortcut_text: impl Into<WidgetText>) -> Self {
self.shortcut_text = shortcut_text.into();

View File

@ -1,4 +1,7 @@
use crate::*;
use crate::{
epaint, pos2, vec2, NumExt, Response, Sense, Shape, TextStyle, Ui, Vec2, Widget, WidgetInfo,
WidgetText, WidgetType,
};
// TODO(emilk): allow checkbox without a text label
/// Boolean on/off control with text label.

View File

@ -1,8 +1,14 @@
//! Color picker widgets.
use crate::util::fixed_cache::FixedCache;
use crate::*;
use epaint::{ecolor::*, *};
use crate::{
epaint, lerp, remap_clamp, Area, Context, DragValue, Frame, Id, Key, Order, Painter, Response,
Sense, Ui, UiKind, Widget, WidgetInfo, WidgetType,
};
use epaint::{
ecolor::{Color32, Hsva, HsvaGamma, Rgba},
pos2, vec2, Mesh, Rect, Shape, Stroke, Vec2,
};
fn contrast_color(color: impl Into<Rgba>) -> Color32 {
if color.into().intensity() < 0.5 {

View File

@ -2,7 +2,10 @@
use std::{cmp::Ordering, ops::RangeInclusive};
use crate::*;
use crate::{
emath, text, Button, CursorIcon, Key, Modifiers, NumExt, Response, RichText, Sense, TextEdit,
TextWrapMode, Ui, Widget, WidgetInfo, MINUS_CHAR_STR,
};
// ----------------------------------------------------------------------------
@ -23,7 +26,7 @@ fn set(get_set_value: &mut GetSetValue<'_>, value: f64) {
(get_set_value)(Some(value));
}
/// A numeric value that you can change by dragging the number. More compact than a [`Slider`].
/// A numeric value that you can change by dragging the number. More compact than a [`crate::Slider`].
///
/// ```
/// # egui::__run_test_ui(|ui| {
@ -90,7 +93,7 @@ impl<'a> DragValue<'a> {
/// Sets valid range for the value.
///
/// By default all values are clamped to this range, even when not interacted with.
/// You can change this behavior by passing `false` to [`Slider::clamp_to_range`].
/// You can change this behavior by passing `false` to [`crate::Slider::clamp_to_range`].
#[deprecated = "Use `range` instead"]
#[inline]
pub fn clamp_range<Num: emath::Numeric>(mut self, range: RangeInclusive<Num>) -> Self {
@ -101,7 +104,7 @@ impl<'a> DragValue<'a> {
/// Sets valid range for dragging the value.
///
/// By default all values are clamped to this range, even when not interacted with.
/// You can change this behavior by passing `false` to [`Slider::clamp_to_range`].
/// You can change this behavior by passing `false` to [`crate::Slider::clamp_to_range`].
#[inline]
pub fn range<Num: emath::Numeric>(mut self, range: RangeInclusive<Num>) -> Self {
self.range = range.start().to_f64()..=range.end().to_f64();
@ -176,7 +179,7 @@ impl<'a> DragValue<'a> {
/// A custom formatter takes a `f64` for the numeric value and a `RangeInclusive<usize>` representing
/// the decimal range i.e. minimum and maximum number of decimal places shown.
///
/// The default formatter is [`Style::number_formatter`].
/// The default formatter is [`crate::Style::number_formatter`].
///
/// See also: [`DragValue::custom_parser`]
///

View File

@ -1,4 +1,7 @@
use crate::*;
use crate::{
epaint, text_selection, CursorIcon, Label, Response, Sense, Stroke, Ui, Widget, WidgetInfo,
WidgetText, WidgetType,
};
use self::text_selection::LabelSelectionState;

View File

@ -5,7 +5,8 @@ use epaint::RectShape;
use crate::{
load::{Bytes, SizeHint, SizedTexture, TextureLoadResult, TexturePoll},
*,
pos2, Align2, Color32, Context, Id, Mesh, Painter, Rect, Response, Rounding, Sense, Shape,
Spinner, Stroke, TextStyle, TextureOptions, Ui, Vec2, Widget,
};
/// A widget which displays an image.
@ -13,11 +14,11 @@ use crate::{
/// The task of actually loading the image is deferred to when the `Image` is added to the [`Ui`],
/// and how it is loaded depends on the provided [`ImageSource`]:
///
/// - [`ImageSource::Uri`] will load the image using the [asynchronous loading process][`load`].
/// - [`ImageSource::Bytes`] will also load the image using the [asynchronous loading process][`load`], but with lower latency.
/// - [`ImageSource::Uri`] will load the image using the [asynchronous loading process][`crate::load`].
/// - [`ImageSource::Bytes`] will also load the image using the [asynchronous loading process][`crate::load`], but with lower latency.
/// - [`ImageSource::Texture`] will use the provided texture.
///
/// See [`load`] for more information.
/// See [`crate::load`] for more information.
///
/// ### Examples
/// // Using it in a layout:
@ -248,7 +249,7 @@ impl<'a> Image<'a> {
/// Show a spinner when the image is loading.
///
/// By default this uses the value of [`Visuals::image_loading_spinners`].
/// By default this uses the value of [`crate::Visuals::image_loading_spinners`].
#[inline]
pub fn show_loading_spinner(mut self, show: bool) -> Self {
self.show_loading_spinner = Some(show);
@ -519,7 +520,7 @@ pub enum ImageSource<'a> {
/// Load the image from an existing texture.
///
/// The user is responsible for loading the texture, determining its size,
/// and allocating a [`TextureId`] for it.
/// and allocating a [`crate::TextureId`] for it.
Texture(SizedTexture),
/// Load the image from some raw bytes.
@ -530,7 +531,7 @@ pub enum ImageSource<'a> {
///
/// This instructs the [`Ui`] to cache the raw bytes, which are then further processed by any registered loaders.
///
/// See also [`include_image`] for an easy way to load and display static images.
/// See also [`crate::include_image`] for an easy way to load and display static images.
///
/// See [`crate::load`] for more information.
Bytes {

View File

@ -1,4 +1,7 @@
use crate::*;
use crate::{
widgets, Color32, Image, Rect, Response, Rounding, Sense, Ui, Vec2, Widget, WidgetInfo,
WidgetType,
};
/// A clickable image within a frame.
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]

View File

@ -1,6 +1,9 @@
use std::sync::Arc;
use crate::*;
use crate::{
epaint, pos2, text_selection, vec2, Align, Direction, FontSelection, Galley, Pos2, Response,
Sense, Stroke, TextWrapMode, Ui, Widget, WidgetInfo, WidgetText, WidgetType,
};
use self::text_selection::LabelSelectionState;
@ -46,7 +49,7 @@ impl Label {
/// Set the wrap mode for the text.
///
/// By default, [`Ui::wrap_mode`] will be used, which can be overridden with [`Style::wrap_mode`].
/// By default, [`crate::Ui::wrap_mode`] will be used, which can be overridden with [`crate::Style::wrap_mode`].
///
/// Note that any `\n` in the text will always produce a new line.
#[inline]

View File

@ -4,7 +4,7 @@
//! * `ui.add(Label::new("Text").text_color(color::red));`
//! * `if ui.add(Button::new("Click me")).clicked() { … }`
use crate::*;
use crate::{epaint, Response, Ui};
mod button;
mod checkbox;

View File

@ -1,4 +1,7 @@
use crate::*;
use crate::{
lerp, vec2, Color32, NumExt, Pos2, Rect, Response, Rgba, Rounding, Sense, Shape, Stroke,
TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetType,
};
enum ProgressBarText {
Custom(WidgetText),

View File

@ -1,4 +1,7 @@
use crate::*;
use crate::{
epaint, pos2, vec2, NumExt, Response, Sense, TextStyle, Ui, Vec2, Widget, WidgetInfo,
WidgetText, WidgetType,
};
/// One out of several alternatives, either selected or not.
///

View File

@ -1,8 +1,8 @@
use crate::*;
use crate::{NumExt, Response, Sense, TextStyle, Ui, Widget, WidgetInfo, WidgetText, WidgetType};
/// One out of several alternatives, either selected or not.
/// Will mark selected items with a different background color.
/// An alternative to [`RadioButton`] and [`Checkbox`].
/// An alternative to [`crate::RadioButton`] and [`crate::Checkbox`].
///
/// Usually you'd use [`Ui::selectable_value`] or [`Ui::selectable_label`] instead.
///

View File

@ -1,6 +1,6 @@
use crate::*;
use crate::{vec2, Response, Sense, Ui, Vec2, Widget};
/// A visual separator. A horizontal or vertical line (depending on [`Layout`]).
/// A visual separator. A horizontal or vertical line (depending on [`crate::Layout`]).
///
/// Usually you'd use the shorter version [`Ui::separator`].
///

View File

@ -2,7 +2,11 @@
use std::ops::RangeInclusive;
use crate::{style::HandleShape, *};
use crate::{
emath, epaint, lerp, pos2, remap, remap_clamp, style, style::HandleShape, vec2, Color32,
DragValue, EventFilter, Key, Label, NumExt, Pos2, Rangef, Rect, Response, Sense, TextStyle,
TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, MINUS_CHAR_STR,
};
// ----------------------------------------------------------------------------
@ -299,10 +303,10 @@ impl<'a> Slider<'a> {
/// Display trailing color behind the slider's circle. Default is OFF.
///
/// This setting can be enabled globally for all sliders with [`Visuals::slider_trailing_fill`].
/// This setting can be enabled globally for all sliders with [`crate::Visuals::slider_trailing_fill`].
/// Toggling it here will override the above setting ONLY for this individual slider.
///
/// The fill color will be taken from `selection.bg_fill` in your [`Visuals`], the same as a [`ProgressBar`].
/// The fill color will be taken from `selection.bg_fill` in your [`crate::Visuals`], the same as a [`crate::ProgressBar`].
#[inline]
pub fn trailing_fill(mut self, trailing_fill: bool) -> Self {
self.trailing_fill = Some(trailing_fill);
@ -311,7 +315,7 @@ impl<'a> Slider<'a> {
/// Change the shape of the slider handle
///
/// This setting can be enabled globally for all sliders with [`Visuals::handle_shape`].
/// This setting can be enabled globally for all sliders with [`crate::Visuals::handle_shape`].
/// Changing it here will override the above setting ONLY for this individual slider.
#[inline]
pub fn handle_shape(mut self, handle_shape: HandleShape) -> Self {
@ -324,7 +328,7 @@ impl<'a> Slider<'a> {
/// A custom formatter takes a `f64` for the numeric value and a `RangeInclusive<usize>` representing
/// the decimal range i.e. minimum and maximum number of decimal places shown.
///
/// The default formatter is [`Style::number_formatter`].
/// The default formatter is [`crate::Style::number_formatter`].
///
/// See also: [`Slider::custom_parser`]
///

View File

@ -1,14 +1,18 @@
use std::sync::Arc;
use epaint::text::{cursor::*, Galley, LayoutJob};
use epaint::text::{cursor::CCursor, Galley, LayoutJob};
use crate::{
epaint,
os::OperatingSystem,
output::OutputEvent,
text_selection,
text_selection::{
text_cursor_state::cursor_rect, visuals::paint_text_selection, CCursorRange, CursorRange,
},
*,
vec2, Align, Align2, Color32, Context, CursorIcon, Event, EventFilter, FontSelection, Id,
ImeEvent, Key, KeyboardShortcut, Margin, Modifiers, NumExt, Response, Sense, Shape, TextBuffer,
TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetWithState,
};
use super::{TextEditOutput, TextEditState};
@ -55,7 +59,7 @@ use super::{TextEditOutput, TextEditState};
/// See [`TextEdit::show`].
///
/// ## Other
/// The background color of a [`TextEdit`] is [`Visuals::extreme_bg_color`].
/// The background color of a [`crate::TextEdit`] is [`crate::Visuals::extreme_bg_color`].
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
pub struct TextEdit<'t> {
text: &'t mut dyn TextBuffer,
@ -205,7 +209,7 @@ impl<'t> TextEdit<'t> {
self
}
/// Pick a [`FontId`] or [`TextStyle`].
/// Pick a [`crate::FontId`] or [`TextStyle`].
#[inline]
pub fn font(mut self, font_selection: impl Into<FontSelection>) -> Self {
self.font_selection = font_selection.into();

View File

@ -2,9 +2,10 @@ use std::sync::Arc;
use crate::mutex::Mutex;
use crate::*;
use self::text_selection::{CCursorRange, CursorRange, TextCursorState};
use crate::{
text_selection::{CCursorRange, CursorRange, TextCursorState},
Context, Galley, Id,
};
pub type TextEditUndoer = crate::util::undoer::Undoer<(CCursorRange, String)>;

View File

@ -1,4 +1,9 @@
use egui::{containers::*, widgets::*, *};
use egui::{
containers::{CollapsingHeader, Frame},
emath, pos2,
widgets::Slider,
Color32, Painter, Pos2, Rect, Shape, Stroke, Ui, Vec2,
};
use std::f32::consts::TAU;
#[derive(PartialEq)]

View File

@ -53,7 +53,7 @@ impl FrameHistory {
}
fn graph(&mut self, ui: &mut egui::Ui) -> egui::Response {
use egui::*;
use egui::{emath, epaint, pos2, vec2, Pos2, Rect, Sense, Shape, Stroke, TextStyle};
ui.label("egui CPU usage history");

View File

@ -428,7 +428,7 @@ impl WrapApp {
}
fn ui_file_drag_and_drop(&mut self, ctx: &egui::Context) {
use egui::*;
use egui::{Align2, Color32, Id, LayerId, Order, TextStyle};
use std::fmt::Write as _;
// Preview hovering files:

View File

@ -1,4 +1,9 @@
use egui::{containers::*, epaint::PathStroke, *};
use egui::{
containers::{Frame, Window},
emath, epaint,
epaint::PathStroke,
hex_color, lerp, pos2, remap, vec2, Color32, Context, Pos2, Rect, Ui,
};
#[derive(Default)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]

View File

@ -1,4 +1,4 @@
use egui::*;
use egui::{vec2, Color32, Context, Frame, Id, Ui, Window};
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]

View File

@ -1,6 +1,9 @@
use super::*;
use super::{Demo, View};
use egui::*;
use egui::{
vec2, Align, Checkbox, CollapsingHeader, Color32, Context, FontId, Frame, Resize, RichText,
Sense, Slider, Stroke, TextFormat, TextStyle, Ui, Vec2, Window,
};
/// Showcase some ui code
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]

View File

@ -1,5 +1,8 @@
use egui::epaint::{CubicBezierShape, PathShape, QuadraticBezierShape};
use egui::*;
use egui::{
emath, epaint, pos2, Color32, Context, Frame, Grid, Pos2, Rect, Sense, Shape, Stroke, Ui, Vec2,
Widget, Window,
};
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]

View File

@ -1,4 +1,4 @@
use egui::*;
use egui::{emath, vec2, Color32, Context, Frame, Pos2, Rect, Sense, Stroke, Ui, Window};
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]

View File

@ -91,7 +91,7 @@ impl crate::View for PanZoom {
(
egui::Pos2::new(60.0, 60.0),
Box::new(|ui, state| {
use egui::epaint::*;
use egui::epaint::{pos2, CircleShape, Color32, QuadraticBezierShape, Stroke};
// Smiley face.
let painter = ui.painter();
painter.add(CircleShape::filled(pos2(0.0, -10.0), 1.0, Color32::YELLOW));

View File

@ -1,4 +1,7 @@
use egui::{scroll_area::ScrollBarVisibility, *};
use egui::{
pos2, scroll_area::ScrollBarVisibility, Align, Align2, Color32, DragValue, NumExt, Rect,
ScrollArea, Sense, Slider, Style, TextStyle, TextWrapMode, Ui, Vec2, Widget,
};
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[derive(Clone, Copy, Debug, PartialEq)]

View File

@ -1,4 +1,4 @@
use egui::{style::HandleShape, *};
use egui::{style::HandleShape, Slider, SliderOrientation, Ui};
use std::f64::INFINITY;
/// Showcase sliders

View File

@ -1,4 +1,4 @@
use egui::*;
use egui::{vec2, Align, Direction, Layout, Resize, Slider, Ui};
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]

View File

@ -16,7 +16,7 @@ impl crate::Demo for WindowResizeTest {
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
use egui::*;
use egui::{Resize, ScrollArea, TextEdit, Window};
Window::new("↔ auto-sized")
.open(open)

View File

@ -1,4 +1,6 @@
use egui::{text::CCursorRange, *};
use egui::{
text::CCursorRange, Key, KeyboardShortcut, Modifiers, ScrollArea, TextBuffer, TextEdit, Ui,
};
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]

View File

@ -1,5 +1,8 @@
use super::easy_mark_parser as easy_mark;
use egui::*;
use egui::{
vec2, Align, Align2, Hyperlink, Layout, Response, RichText, Sense, Separator, Shape, TextStyle,
Ui,
};
/// Parse and display a VERY simple and small subset of Markdown.
pub fn easy_mark(ui: &mut Ui, easy_mark: &str) {

View File

@ -1,6 +1,10 @@
use std::collections::HashMap;
use egui::{widgets::color_picker::show_color, TextureOptions, *};
use egui::{
epaint, lerp, pos2, vec2, widgets::color_picker::show_color, Align2, Color32, FontId, Image,
Mesh, Pos2, Rect, Response, Rgba, RichText, Sense, Shape, Stroke, TextureHandle,
TextureOptions, Ui, Vec2,
};
const GRADIENT_SIZE: Vec2 = vec2(256.0, 18.0);
@ -265,7 +269,6 @@ impl ColorTest {
}
fn vertex_gradient(ui: &mut Ui, bg_fill: Color32, gradient: &Gradient) -> Response {
use egui::epaint::*;
let (rect, response) = ui.allocate_at_least(GRADIENT_SIZE, Sense::hover());
if bg_fill != Default::default() {
let mut mesh = Mesh::default();

View File

@ -63,7 +63,7 @@ mod profiling_scopes {
}
#[allow(unused_imports)]
pub(crate) use profiling_scopes::*;
pub(crate) use profiling_scopes::profile_function;
// ---------------------------------------------------------------------------

View File

@ -139,4 +139,4 @@ mod profiling_scopes {
}
#[allow(unused_imports)]
pub(crate) use profiling_scopes::*;
pub(crate) use profiling_scopes::{profile_function, profile_scope};

View File

@ -1,6 +1,6 @@
//! One- and two-dimensional alignment ([`Align::Center`], [`Align2::LEFT_TOP`] etc).
use crate::*;
use crate::{pos2, vec2, Pos2, Rangef, Rect, Vec2};
/// left/center/right or top/center/bottom alignment for e.g. anchors and layouts.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]

View File

@ -101,7 +101,7 @@ impl Float for f64 {
// Keep this trait in private module, to avoid exposing its methods as extensions in user code
mod private {
use super::*;
use super::{Hash, Hasher};
pub trait FloatImpl {
fn is_nan(&self) -> bool;

View File

@ -1,7 +1,7 @@
use std::fmt;
use std::ops::{Add, AddAssign, Sub, SubAssign};
use crate::*;
use crate::{lerp, Div, Mul, Vec2};
/// A position on screen.
///

View File

@ -1,7 +1,7 @@
use std::f32::INFINITY;
use std::fmt;
use crate::*;
use crate::{lerp, pos2, vec2, Div, Mul, Pos2, Rangef, Rot2, Vec2};
/// A rectangular region of space.
///

View File

@ -1,6 +1,9 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use epaint::{tessellator::Path, *};
use epaint::{
pos2, tessellator::Path, ClippedShape, Color32, Mesh, PathStroke, Pos2, Rect, Shape, Stroke,
TessellationOptions, Tessellator, TextureAtlas, Vec2,
};
fn single_dashed_lines(c: &mut Criterion) {
c.bench_function("single_dashed_lines", move |b| {

View File

@ -4,7 +4,7 @@
use std::ops::Range;
use crate::{shape::Shape, Color32, PathShape, PathStroke};
use emath::*;
use emath::{Pos2, Rect, RectTransform};
// ----------------------------------------------------------------------------
@ -762,6 +762,8 @@ fn cubic_for_each_local_extremum<F: FnMut(f32)>(p0: f32, p1: f32, p2: f32, p3: f
#[cfg(test)]
mod tests {
use emath::pos2;
use super::*;
#[test]

View File

@ -171,4 +171,4 @@ mod profiling_scopes {
}
#[allow(unused_imports)]
pub(crate) use profiling_scopes::*;
pub(crate) use profiling_scopes::{profile_function, profile_scope};

View File

@ -1,5 +1,5 @@
use crate::*;
use emath::*;
use crate::{emath, Color32, TextureId, WHITE_UV};
use emath::{Pos2, Rect, Rot2, TSTransform, Vec2};
/// The 2D vertex type.
///

View File

@ -1,4 +1,4 @@
use super::*;
use super::{Color32, Margin, Rect, RectShape, Rounding, Vec2};
/// The color and fuzziness of a fuzzy shape.
///

View File

@ -7,7 +7,7 @@ use crate::{
text::{FontId, Fonts, Galley},
Color32, Mesh, Stroke, TextureId,
};
use emath::*;
use emath::{pos2, Align2, Pos2, Rangef, Rect, TSTransform, Vec2};
pub use crate::{CubicBezierShape, QuadraticBezierShape};

View File

@ -1,6 +1,9 @@
use std::sync::Arc;
use crate::*;
use crate::{
color, CircleShape, Color32, ColorMode, CubicBezierShape, EllipseShape, Mesh, PathShape,
QuadraticBezierShape, RectShape, Shape, TextShape,
};
/// Remember to handle [`Color32::PLACEHOLDER`] specially!
pub fn adjust_colors(

View File

@ -1,6 +1,6 @@
//! Collect statistics about what is being painted.
use crate::*;
use crate::{ClippedShape, Galley, Mesh, Primitive, Shape};
/// Size of the elements in a vector/array.
#[derive(Clone, Copy, PartialEq)]

View File

@ -2,7 +2,7 @@
use std::{fmt::Debug, sync::Arc};
use super::*;
use super::{emath, Color32, ColorMode, Pos2, Rect};
/// Describes the width and color of a line.
///

View File

@ -6,8 +6,12 @@
#![allow(clippy::identity_op)]
use crate::texture_atlas::PreparedDisc;
use crate::*;
use emath::*;
use crate::{
color, emath, stroke, CircleShape, ClippedPrimitive, ClippedShape, Color32, CubicBezierShape,
EllipseShape, Mesh, PathShape, Primitive, QuadraticBezierShape, RectShape, Rounding, Shape,
Stroke, TextShape, TextureId, Vertex, WHITE_UV,
};
use emath::{pos2, remap, vec2, NumExt, Pos2, Rect, Rot2, Vec2};
use self::color::ColorMode;
use self::stroke::PathStroke;
@ -338,7 +342,7 @@ impl Path {
}
pub fn add_circle(&mut self, center: Pos2, radius: f32) {
use precomputed_vertices::*;
use precomputed_vertices::{CIRCLE_128, CIRCLE_16, CIRCLE_32, CIRCLE_64, CIRCLE_8};
// These cutoffs are based on a high-dpi display. TODO(emilk): use pixels_per_point here?
// same cutoffs as in add_circle_quadrant
@ -520,7 +524,7 @@ impl Path {
pub mod path {
//! Helpers for constructing paths
use crate::shape::Rounding;
use emath::*;
use emath::{pos2, Pos2, Rect};
/// overwrites existing points
pub fn rounded_rectangle(path: &mut Vec<Pos2>, rect: Rect, rounding: Rounding) {
@ -589,7 +593,7 @@ pub mod path {
// - quadrant 3: right top
// * angle 4 * TAU / 4 = right
pub fn add_circle_quadrant(path: &mut Vec<Pos2>, center: Pos2, radius: f32, quadrant: f32) {
use super::precomputed_vertices::*;
use super::precomputed_vertices::{CIRCLE_128, CIRCLE_16, CIRCLE_32, CIRCLE_64, CIRCLE_8};
// These cutoffs are based on a high-dpi display. TODO(emilk): use pixels_per_point here?
// same cutoffs as in add_circle
@ -1171,7 +1175,7 @@ pub struct Tessellator {
options: TessellationOptions,
font_tex_size: [usize; 2],
/// See [`TextureAtlas::prepared_discs`].
/// See [`crate::TextureAtlas::prepared_discs`].
prepared_discs: Vec<PreparedDisc>,
/// size of feathering in points. normally the size of a physical pixel. 0.0 if disabled
@ -1191,7 +1195,7 @@ impl Tessellator {
/// * `options`: tessellation quality
/// * `shapes`: what to tessellate
/// * `font_tex_size`: size of the font texture. Required to normalize glyph uv rectangles when tessellating text.
/// * `prepared_discs`: What [`TextureAtlas::prepared_discs`] returns. Can safely be set to an empty vec.
/// * `prepared_discs`: What [`crate::TextureAtlas::prepared_discs`] returns. Can safely be set to an empty vec.
pub fn new(
pixels_per_point: f32,
options: TessellationOptions,
@ -1902,7 +1906,7 @@ impl Tessellator {
/// * `options`: tessellation quality
/// * `shapes`: what to tessellate
/// * `font_tex_size`: size of the font texture. Required to normalize glyph uv rectangles when tessellating text.
/// * `prepared_discs`: What [`TextureAtlas::prepared_discs`] returns. Can safely be set to an empty vec.
/// * `prepared_discs`: What [`crate::TextureAtlas::prepared_discs`] returns. Can safely be set to an empty vec.
///
/// The implementation uses a [`Tessellator`].
///

View File

@ -92,7 +92,7 @@ impl FontImpl {
assert!(scale_in_pixels > 0.0);
assert!(pixels_per_point > 0.0);
use ab_glyph::*;
use ab_glyph::{Font, ScaleFont};
let scaled = ab_glyph_font.as_scaled(scale_in_pixels);
let ascent = scaled.ascent() / pixels_per_point;
let descent = scaled.descent() / pixels_per_point;

View File

@ -1,7 +1,7 @@
use std::ops::RangeInclusive;
use std::sync::Arc;
use emath::*;
use emath::{pos2, vec2, Align, NumExt, Pos2, Rect, Vec2};
use crate::{stroke::PathStroke, text::font::Font, Color32, Mesh, Stroke, Vertex};

View File

@ -4,9 +4,12 @@
use std::ops::Range;
use std::sync::Arc;
use super::{cursor::*, font::UvRect};
use super::{
cursor::{CCursor, Cursor, PCursor, RCursor},
font::UvRect,
};
use crate::{Color32, FontId, Mesh, Stroke};
use emath::*;
use emath::{pos2, vec2, Align, NumExt, OrderedFloat, Pos2, Rect, Vec2};
/// Describes the task of laying out text.
///

View File

@ -43,7 +43,7 @@ impl eframe::App for MyApp {
}
fn custom_window_frame(ctx: &egui::Context, title: &str, add_contents: impl FnOnce(&mut egui::Ui)) {
use egui::*;
use egui::{CentralPanel, UiBuilder};
let panel_frame = egui::Frame {
fill: ctx.style().visuals.window_fill(),
@ -77,7 +77,7 @@ fn custom_window_frame(ctx: &egui::Context, title: &str, add_contents: impl FnOn
}
fn title_bar_ui(ui: &mut egui::Ui, title_bar_rect: eframe::epaint::Rect, title: &str) {
use egui::*;
use egui::{vec2, Align2, FontId, Id, PointerButton, Sense, UiBuilder};
let painter = ui.painter();

View File

@ -86,7 +86,7 @@ impl eframe::App for MyApp {
/// Preview hovering files:
fn preview_files_being_dropped(ctx: &egui::Context) {
use egui::*;
use egui::{Align2, Color32, Id, LayerId, Order, TextStyle};
use std::fmt::Write as _;
if !ctx.input(|i| i.raw.hovered_files.is_empty()) {

View File

@ -2,7 +2,7 @@
#![allow(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui;
use egui::*;
use egui::{Key, ScrollArea};
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).

View File

@ -1,7 +1,7 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui::*;
use eframe::egui::{popup_below_widget, CentralPanel, ComboBox, Id, PopupCloseBehavior};
fn main() -> Result<(), eframe::Error> {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).

View File

@ -9,7 +9,7 @@ set -x
# Checks all tests, lints etc.
# Basically does what the CI does.
cargo +1.75.0 install --quiet typos-cli
cargo +1.76.0 install --quiet typos-cli
export RUSTFLAGS="-D warnings"
export RUSTDOCFLAGS="-D warnings" # https://github.com/emilk/egui/pull/1454
@ -20,8 +20,9 @@ typos
cargo fmt --all -- --check
cargo doc --quiet --lib --no-deps --all-features
cargo doc --quiet --document-private-items --no-deps --all-features
cargo clippy --quiet --all-targets --all-features -- -D warnings
cargo clippy --all-targets --all-features --release -- -D warnings # we need to check release mode too
./scripts/clippy_wasm.sh
cargo check --quiet --all-targets