Browse Source

Better docs and spelling fixes

pull/1049/head
Emil Ernerfeldt 3 years ago
parent
commit
79cfdaa1f9
  1. 2
      CHANGELOG.md
  2. 6
      egui-winit/src/lib.rs
  3. 16
      egui/src/containers/panel.rs
  4. 12
      egui/src/containers/scroll_area.rs
  5. 2
      egui/src/context.rs
  6. 4
      egui/src/data/input.rs
  7. 2
      egui/src/lib.rs
  8. 11
      egui/src/widgets/progress_bar.rs
  9. 2
      egui/src/widgets/spinner.rs

2
CHANGELOG.md

@ -49,7 +49,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w
### Fixed 🐛
* Fixed `ComboBox` and other popups getting clipped to parent window ([#885](https://github.com/emilk/egui/pull/885)).
* The color picker is now better att keeping the same hue even when saturation goes to zero ([#886](https://github.com/emilk/egui/pull/886)).
* The color picker is now better at keeping the same hue even when saturation goes to zero ([#886](https://github.com/emilk/egui/pull/886)).
### Removed 🔥
* Removed `egui::math` (use `egui::emath` instead).

6
egui-winit/src/lib.rs

@ -454,12 +454,10 @@ impl State {
}
};
if cfg!(target_os = "macos") {
// This is still buggy in winit despite
// https://github.com/rust-windowing/winit/issues/1695 being closed
delta.x *= -1.0;
delta.x *= -1.0; // until https://github.com/rust-windowing/winit/pull/2105 is merged and released
}
if cfg!(target_os = "windows") {
delta.x *= -1.0; // until https://github.com/rust-windowing/winit/pull/2101 is merged
delta.x *= -1.0; // until https://github.com/rust-windowing/winit/pull/2101 is merged and released
}
if self.egui_input.modifiers.ctrl || self.egui_input.modifiers.command {

16
egui/src/containers/panel.rs

@ -117,6 +117,14 @@ impl SidePanel {
/// Can panel be resized by dragging the edge of it?
///
/// Default is `true`.
///
/// 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`].
/// * …
pub fn resizable(mut self, resizable: bool) -> Self {
self.resizable = resizable;
self
@ -393,6 +401,14 @@ impl TopBottomPanel {
/// Can panel be resized by dragging the edge of it?
///
/// Default is `false`.
///
/// 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`].
/// * …
pub fn resizable(mut self, resizable: bool) -> Self {
self.resizable = resizable;
self

12
egui/src/containers/scroll_area.rs

@ -376,10 +376,10 @@ impl ScrollArea {
/// let text_style = egui::TextStyle::Body;
/// let row_height = ui.fonts()[text_style].row_height();
/// // let row_height = ui.spacing().interact_size.y; // if you are adding buttons instead of labels.
/// let num_rows = 10_000;
/// egui::ScrollArea::vertical().show_rows(ui, row_height, num_rows, |ui, row_range| {
/// let total_rows = 10_000;
/// egui::ScrollArea::vertical().show_rows(ui, row_height, total_rows, |ui, row_range| {
/// for row in row_range {
/// let text = format!("Row {}/{}", row + 1, num_rows);
/// let text = format!("Row {}/{}", row + 1, total_rows);
/// ui.label(text);
/// }
/// });
@ -389,19 +389,19 @@ impl ScrollArea {
self,
ui: &mut Ui,
row_height_sans_spacing: f32,
num_rows: usize,
total_rows: usize,
add_contents: impl FnOnce(&mut Ui, std::ops::Range<usize>) -> R,
) -> R {
let spacing = ui.spacing().item_spacing;
let row_height_with_spacing = row_height_sans_spacing + spacing.y;
self.show_viewport(ui, |ui, viewport| {
ui.set_height((row_height_with_spacing * num_rows as f32 - spacing.y).at_least(0.0));
ui.set_height((row_height_with_spacing * total_rows as f32 - spacing.y).at_least(0.0));
let min_row = (viewport.min.y / row_height_with_spacing)
.floor()
.at_least(0.0) as usize;
let max_row = (viewport.max.y / row_height_with_spacing).ceil() as usize + 1;
let max_row = max_row.at_most(num_rows);
let max_row = max_row.at_most(total_rows);
let y_min = ui.max_rect().top() + min_row as f32 * row_height_with_spacing;
let y_max = ui.max_rect().top() + max_row as f32 * row_height_with_spacing;

2
egui/src/context.rs

@ -100,7 +100,7 @@ impl CtxRef {
/// This will modify the internal reference to point to a new generation of [`Context`].
/// Any old clones of this [`CtxRef`] will refer to the old [`Context`], which will not get new input.
///
/// You can alternatively run [`Self::begin_frame`] and [`Self::end_frame`].
/// You can alternatively run [`Self::begin_frame`] and [`Context::end_frame`].
///
/// ``` rust
/// // One egui context that you keep reusing:

4
egui/src/data/input.rs

@ -174,6 +174,10 @@ pub enum Event {
PointerGone,
/// How many points (logical pixels) the user scrolled.
///
/// The direction of the vector indicates how to move the _content_ that is being viewed.
/// So if you get positive values, the content being viewed should move to the right and down,
/// revealing new things to the left and up.
Scroll(Vec2),
/// Zoom scale factor this frame (e.g. from ctrl-scroll or pinch gesture).

2
egui/src/lib.rs

@ -214,7 +214,7 @@
//! when you release the panel/window shrinks again.
//! This is an artifact of immediate mode, and here are some alternatives on how to avoid it:
//!
//! 1. Turn of resizing with [`Window::resizable`], [`SidePanel::resizable`], [`TopBottomPanel::resizable`].
//! 1. Turn off resizing with [`Window::resizable`], [`SidePanel::resizable`], [`TopBottomPanel::resizable`].
//! 2. Wrap your panel contents in a [`ScrollArea`], or use [`Window::vscroll`] and [`Window::hscroll`].
//! 3. Use a justified layout:
//!

11
egui/src/widgets/progress_bar.rs

@ -6,6 +6,9 @@ enum ProgressBarText {
}
/// A simple progress bar.
///
/// See also: [`crate::Spinner`].
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
pub struct ProgressBar {
progress: f32,
desired_width: Option<f32>,
@ -62,10 +65,6 @@ impl Widget for ProgressBar {
let animate = animate && progress < 1.0;
if animate {
ui.ctx().request_repaint();
}
let desired_width =
desired_width.unwrap_or_else(|| ui.available_size_before_wrap().x.at_least(96.0));
let height = ui.spacing().interact_size.y;
@ -73,6 +72,10 @@ impl Widget for ProgressBar {
ui.allocate_exact_size(vec2(desired_width, height), Sense::hover());
if ui.is_rect_visible(response.rect) {
if animate {
ui.ctx().request_repaint();
}
let visuals = ui.style().visuals.clone();
let corner_radius = outer_rect.height() / 2.0;
ui.painter().rect(

2
egui/src/widgets/spinner.rs

@ -3,6 +3,8 @@ use epaint::{emath::lerp, vec2, Pos2, Shape, Stroke};
use crate::{Response, Sense, Ui, Widget};
/// A spinner widget used to indicate loading.
///
/// See also: [`crate::ProgressBar`].
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
#[derive(Default)]
pub struct Spinner {

Loading…
Cancel
Save