mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Misc cleanup (#3381)
* Give credit to recent big-time contributors in the main README.md * Better named profiling scopes * Document everything in memory.rs * Better doc-strings * Add a section about dependencies to the main README.md * Improve egui_extras docs * fix typos
This commit is contained in:
@@ -970,7 +970,7 @@ mod glow_integration {
|
||||
if window.is_minimized() == Some(true) {
|
||||
// On Mac, a minimized Window uses up all CPU:
|
||||
// https://github.com/emilk/egui/issues/325
|
||||
crate::profile_scope!("bg_sleep");
|
||||
crate::profile_scope!("minimized_sleep");
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
}
|
||||
|
||||
@@ -1417,7 +1417,7 @@ mod wgpu_integration {
|
||||
if window.is_minimized() == Some(true) {
|
||||
// On Mac, a minimized Window uses up all CPU:
|
||||
// https://github.com/emilk/egui/issues/325
|
||||
crate::profile_scope!("bg_sleep");
|
||||
crate::profile_scope!("minimized_sleep");
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,8 @@ pub struct PlatformOutput {
|
||||
pub mutable_text_under_cursor: bool,
|
||||
|
||||
/// Screen-space position of text edit cursor (used for IME).
|
||||
///
|
||||
/// Iff `Some`, the user is editing text.
|
||||
pub text_cursor_pos: Option<crate::Pos2>,
|
||||
|
||||
#[cfg(feature = "accesskit")]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![warn(missing_docs)] // Let's keep this file well-documented.` to memory.rs
|
||||
|
||||
use epaint::{emath::Rangef, vec2, Vec2};
|
||||
|
||||
use crate::{area, window, EventFilter, Id, IdMap, InputState, LayerId, Pos2, Rect, Style};
|
||||
@@ -17,6 +19,7 @@ use crate::{area, window, EventFilter, Id, IdMap, InputState, LayerId, Pos2, Rec
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
pub struct Memory {
|
||||
/// Global egui options.
|
||||
pub options: Options,
|
||||
|
||||
/// This map stores some superficial state for all widgets with custom [`Id`]s.
|
||||
@@ -627,21 +630,25 @@ impl Memory {
|
||||
self.interaction.focus.focused_widget = None;
|
||||
}
|
||||
|
||||
/// Is any widget being dragged?
|
||||
#[inline(always)]
|
||||
pub fn is_anything_being_dragged(&self) -> bool {
|
||||
self.interaction.drag_id.is_some()
|
||||
}
|
||||
|
||||
/// Is this specific widget being dragged?
|
||||
#[inline(always)]
|
||||
pub fn is_being_dragged(&self, id: Id) -> bool {
|
||||
self.interaction.drag_id == Some(id)
|
||||
}
|
||||
|
||||
/// Set which widget is being dragged.
|
||||
#[inline(always)]
|
||||
pub fn set_dragged_id(&mut self, id: Id) {
|
||||
self.interaction.drag_id = Some(id);
|
||||
}
|
||||
|
||||
/// Stop dragging any widget.
|
||||
#[inline(always)]
|
||||
pub fn stop_dragging(&mut self) {
|
||||
self.interaction.drag_id = None;
|
||||
@@ -663,22 +670,29 @@ impl Memory {
|
||||
/// Popups are things like combo-boxes, color pickers, menus etc.
|
||||
/// Only one can be be open at a time.
|
||||
impl Memory {
|
||||
/// Is the given popup open?
|
||||
pub fn is_popup_open(&self, popup_id: Id) -> bool {
|
||||
self.popup == Some(popup_id) || self.everything_is_visible()
|
||||
}
|
||||
|
||||
/// Is any popup open?
|
||||
pub fn any_popup_open(&self) -> bool {
|
||||
self.popup.is_some() || self.everything_is_visible()
|
||||
}
|
||||
|
||||
/// Open the given popup, and close all other.
|
||||
pub fn open_popup(&mut self, popup_id: Id) {
|
||||
self.popup = Some(popup_id);
|
||||
}
|
||||
|
||||
/// Close the open popup, if any.
|
||||
pub fn close_popup(&mut self) {
|
||||
self.popup = None;
|
||||
}
|
||||
|
||||
/// Toggle the given popup between closed and open.
|
||||
///
|
||||
/// Note: at most one popup can be open at one time.
|
||||
pub fn toggle_popup(&mut self, popup_id: Id) {
|
||||
if self.is_popup_open(popup_id) {
|
||||
self.close_popup();
|
||||
|
||||
@@ -7,3 +7,15 @@
|
||||

|
||||
|
||||
This is a crate that adds some features on top top of [`egui`](https://github.com/emilk/egui). This crate is for experimental features, and features that require big dependencies that do not belong in `egui`.
|
||||
|
||||
## Images
|
||||
One thing `egui_extras` is commonly used for is to install image loaders for `egui`:
|
||||
|
||||
```toml
|
||||
egui_extras = { version = "*", features = ["all_loaders"] }
|
||||
image = { version = "0.24", features = ["jpeg", "png"] }
|
||||
```
|
||||
|
||||
```rs
|
||||
egui_extras::install_image_loaders(egui_ctx);
|
||||
```
|
||||
|
||||
@@ -7,6 +7,7 @@ pub(crate) struct DatePickerButtonState {
|
||||
pub picker_visible: bool,
|
||||
}
|
||||
|
||||
/// Shows a date, and will open a date picker popup when clicked.
|
||||
pub struct DatePickerButton<'a> {
|
||||
selection: &'a mut NaiveDate,
|
||||
id_source: Option<&'a str>,
|
||||
|
||||
@@ -18,7 +18,7 @@ pub mod syntax_highlighting;
|
||||
#[doc(hidden)]
|
||||
pub mod image;
|
||||
mod layout;
|
||||
pub mod loaders;
|
||||
mod loaders;
|
||||
mod sizing;
|
||||
mod strip;
|
||||
mod table;
|
||||
|
||||
@@ -13,6 +13,10 @@ use crate::*;
|
||||
/// of `min` and `max` are swapped. These are usually a sign of an error.
|
||||
///
|
||||
/// Normally the unit is points (logical pixels) in screen space coordinates.
|
||||
///
|
||||
/// `Rect` does NOT implement `Default`, because there is no obvious default value.
|
||||
/// [`Rect::ZERO`] may seem reasonable, but when used as a bounding box, [`Rect::NOTHING`]
|
||||
/// is a better default - so be explicit instead!
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
|
||||
Reference in New Issue
Block a user