Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ui::spinner shortcut method #1494

Merged
merged 3 commits into from Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions eframe/CHANGELOG.md
Expand Up @@ -23,6 +23,7 @@ NOTE: [`egui_web`](../egui_web/CHANGELOG.md), [`egui-winit`](../egui-winit/CHANG
* Fixed potential scale bug when DPI scaling changes (e.g. when dragging a window between different displays) ([#1441](https://github.com/emilk/egui/pull/1441)).
* MSRV (Minimum Supported Rust Version) is now `1.60.0` ([#1467](https://github.com/emilk/egui/pull/1467)).
* Added new feature `puffin` to add [`puffin profiler`](https://github.com/EmbarkStudios/puffin) scopes ([#1483](https://github.com/emilk/egui/pull/1483)).
* Added `Ui::spinner()` shortcut method ([#1494](https://github.com/emilk/egui/pull/1494)).


## 0.17.0 - 2022-02-22
Expand Down
12 changes: 11 additions & 1 deletion egui/src/ui.rs
Expand Up @@ -1383,12 +1383,22 @@ impl Ui {
response
}

/// Shortcut for `add(Separator::default())` (see [`Separator`]).
/// Shortcut for `add(Separator::default())`
///
/// See also [`Separator`].
#[inline]
pub fn separator(&mut self) -> Response {
Separator::default().ui(self)
}

/// Shortcut for `add(Spinner::new())`
///
/// See also [`Spinner`].
#[inline]
pub fn spinner(&mut self) -> Response {
Spinner::new().ui(self)
}

/// Modify an angle. The given angle should be in radians, but is shown to the user in degrees.
/// The angle is NOT wrapped, so the user may select, for instance 720° = 2𝞃 = 4π
pub fn drag_angle(&mut self, radians: &mut f32) -> Response {
Expand Down
2 changes: 1 addition & 1 deletion egui_demo_lib/src/apps/http_app.rs
Expand Up @@ -101,7 +101,7 @@ impl epi::App for HttpApp {
}
}
} else {
ui.add(egui::Spinner::new());
ui.spinner();
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion examples/download_image/src/main.rs
Expand Up @@ -38,7 +38,7 @@ impl eframe::App for MyApp {

egui::CentralPanel::default().show(ctx, |ui| match promise.ready() {
None => {
ui.add(egui::Spinner::new()); // still loading
ui.spinner(); // still loading
}
Some(Err(err)) => {
ui.colored_label(egui::Color32::RED, err); // something went wrong
Expand Down