Browse Source

spelling

pull/20/head
Emil Ernerfeldt 4 years ago
parent
commit
1a9618c524
  1. 6
      egui/src/app.rs
  2. 2
      egui/src/containers/scroll_area.rs
  3. 13
      egui/src/input.rs
  4. 2
      egui/src/layers.rs
  5. 5
      egui/src/layout.rs
  6. 4
      egui/src/menu.rs
  7. 2
      egui/src/types.rs
  8. 2
      egui/src/widgets.rs

6
egui/src/app.rs

@ -1,5 +1,7 @@
//! Traits and helper for writing Egui apps. //! Traits and helper for writing Egui apps.
//! //!
//! This module is very experimental, and you don't need to use it.
//!
//! Egui can be used as a library, but you can also use it as a framework to write apps in. //! Egui can be used as a library, but you can also use it as a framework to write apps in.
//! This module defined the `App` trait that can be implemented and used with the `egui_web` and `egui_glium` crates. //! This module defined the `App` trait that can be implemented and used with the `egui_web` and `egui_glium` crates.
@ -19,7 +21,7 @@ pub trait App {
/// How the backend runs the app /// How the backend runs the app
#[derive(Clone, Copy, Debug, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum RunMode { pub enum RunMode {
/// Repint the UI all the time (at the display refresh rate of e.g. 60 Hz). /// Repaint the UI all the time (at the display refresh rate of e.g. 60 Hz).
/// This is good for games where things are constantly moving. /// This is good for games where things are constantly moving.
/// This can also be achieved with `RunMode::Reactive` combined with calling `egui::Context::request_repaint()` each frame. /// This can also be achieved with `RunMode::Reactive` combined with calling `egui::Context::request_repaint()` each frame.
Continuous, Continuous,
@ -50,7 +52,7 @@ pub trait Backend {
fn fps(&self) -> f32; fn fps(&self) -> f32;
/// Signal the backend that we'd like to exit the app now. /// Signal the backend that we'd like to exit the app now.
/// This does nothing for web apps.s /// This does nothing for web apps.
fn quit(&mut self) {} fn quit(&mut self) {}
} }

2
egui/src/containers/scroll_area.rs

@ -191,7 +191,7 @@ impl Prepared {
let max_scroll_bar_width = max_scroll_bar_width_with_margin(ui); let max_scroll_bar_width = max_scroll_bar_width_with_margin(ui);
if show_scroll_this_frame && current_scroll_bar_width <= 0.0 { if show_scroll_this_frame && current_scroll_bar_width <= 0.0 {
// Avoid frame delay; start shwoing scroll bar right away: // Avoid frame delay; start showing scroll bar right away:
current_scroll_bar_width = remap_clamp( current_scroll_bar_width = remap_clamp(
ui.input().predicted_dt, ui.input().predicted_dt,
0.0..=ui.style().animation_time, 0.0..=ui.style().animation_time,

13
egui/src/input.rs

@ -1,3 +1,5 @@
//! The input needed by Egui.
use crate::math::*; use crate::math::*;
/// If mouse moves more than this, it is no longer a click (but maybe a drag) /// If mouse moves more than this, it is no longer a click (but maybe a drag)
@ -5,9 +7,9 @@ const MAX_CLICK_DIST: f32 = 6.0;
/// The new mouse press must come within this many seconds from previous mouse release /// The new mouse press must come within this many seconds from previous mouse release
const MAX_CLICK_DELAY: f64 = 0.3; const MAX_CLICK_DELAY: f64 = 0.3;
/// What the integration gives to the gui. /// What the backend provides to Egui at the start of each frame.
/// All coordinates in egui is in point/logical coordinates ///
/// with origin (0, 0) in the top left corner. /// All coordinates are in points (logical pixels) with origin (0, 0) in the top left corner.
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct RawInput { pub struct RawInput {
/// Is the button currently down? /// Is the button currently down?
@ -24,6 +26,7 @@ pub struct RawInput {
pub screen_size: Vec2, pub screen_size: Vec2,
/// Also known as device pixel ratio, > 1 for HDPI screens. /// Also known as device pixel ratio, > 1 for HDPI screens.
/// If text looks blurry on high resolution screens, you probably forgot to set this.
pub pixels_per_point: Option<f32>, pub pixels_per_point: Option<f32>,
/// Time in seconds. Relative to whatever. Used for animations. /// Time in seconds. Relative to whatever. Used for animations.
@ -332,7 +335,7 @@ impl RawInput {
pub fn ui(&self, ui: &mut crate::Ui) { pub fn ui(&self, ui: &mut crate::Ui) {
use crate::label; use crate::label;
// TODO: simpler way to show values, e.g. `ui.value("Mouse Pos:", self.mouse_pos); // TODO: simpler way to show values, e.g. `ui.value("Mouse Pos:", self.mouse_pos);
// TODO: easily change default font! // TODO: `ui.style_mut().text_style = TextStyle::Monospace`;
ui.add(label!("mouse_down: {}", self.mouse_down)); ui.add(label!("mouse_down: {}", self.mouse_down));
ui.add(label!("mouse_pos: {:.1?}", self.mouse_pos)); ui.add(label!("mouse_pos: {:.1?}", self.mouse_pos));
ui.add(label!("scroll_delta: {:?} points", self.scroll_delta)); ui.add(label!("scroll_delta: {:?} points", self.scroll_delta));
@ -366,7 +369,7 @@ impl InputState {
ui.add(label!("scroll_delta: {:?} points", self.scroll_delta)); ui.add(label!("scroll_delta: {:?} points", self.scroll_delta));
ui.add(label!("screen_size: {:?} points", self.screen_size)); ui.add(label!("screen_size: {:?} points", self.screen_size));
ui.add(label!( ui.add(label!(
"{} points for each physical pixel (hdpi factor)", "{} points for each physical pixel (HDPI factor)",
self.pixels_per_point self.pixels_per_point
)); ));
ui.add(label!("time: {:.3} s", self.time)); ui.add(label!("time: {:.3} s", self.time));

2
egui/src/layers.rs

@ -67,7 +67,7 @@ impl PaintList {
} }
} }
// TODO: improve this // TODO: improve GraphicLayers
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct GraphicLayers(AHashMap<Layer, PaintList>); pub struct GraphicLayers(AHashMap<Layer, PaintList>);

5
egui/src/layout.rs

@ -61,12 +61,13 @@ pub(crate) fn anchor_rect(rect: Rect, anchor: (Align, Align)) -> Rect {
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
// #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] // #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Layout { pub struct Layout {
/// Lay out things horizontally or vertically? /// Lay out things horizontally or vertically? Main axis.
dir: Direction, dir: Direction,
/// How to align things on the cross axis.
/// For vertical layouts: put things to left, center or right? /// For vertical layouts: put things to left, center or right?
/// For horizontal layouts: put things to top, center or bottom? /// For horizontal layouts: put things to top, center or bottom?
/// None means justified, which means full width (vertical layout) or height (horizontal layouts). /// `None` means justified, which means full width (vertical layout) or height (horizontal layouts).
align: Option<Align>, align: Option<Align>,
/// Lay out things in reversed order, i.e. from the right or bottom-up. /// Lay out things in reversed order, i.e. from the right or bottom-up.

4
egui/src/menu.rs

@ -1,4 +1,4 @@
//! Menu bar functionality. //! Menu bar functionality (very basic so far).
//! //!
//! Usage: //! Usage:
//! ``` rust //! ``` rust
@ -79,7 +79,7 @@ pub fn bar<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> (R, Rect)
let clicked_outside = !ui.hovered(ui.rect()) && ui.input().mouse.released; let clicked_outside = !ui.hovered(ui.rect()) && ui.input().mouse.released;
if clicked_outside || ui.input().key_pressed(Key::Escape) { if clicked_outside || ui.input().key_pressed(Key::Escape) {
// TODO: this prevent sub-menus in menus. We should fix that. // TODO: this prevents sub-menus in menus. We should fix that.
let bar_id = ui.id(); let bar_id = ui.id();
BarState::close_menus(ui.ctx(), bar_id); BarState::close_menus(ui.ctx(), bar_id);
} }

2
egui/src/types.rs

@ -63,7 +63,7 @@ pub struct InteractInfo {
/// The mouse is hovering above this thing /// The mouse is hovering above this thing
pub hovered: bool, pub hovered: bool,
/// The mouse pressed this thing ealier, and now released on this thing too. /// The mouse pressed this thing earlier, and now released on this thing too.
pub clicked: bool, pub clicked: bool,
pub double_clicked: bool, pub double_clicked: bool,

2
egui/src/widgets.rs

@ -514,7 +514,7 @@ impl Widget for Separator {
// TODO: only allocate `spacing`, but not our full width/height // TODO: only allocate `spacing`, but not our full width/height
// as that would make the false impression that we *need* all that space, // as that would make the false impression that we *need* all that space,
// wich would prevent regions from autoshrinking // which would prevent regions from auto-shrinking
let (points, rect) = match ui.layout().dir() { let (points, rect) = match ui.layout().dir() {
Direction::Horizontal => { Direction::Horizontal => {

Loading…
Cancel
Save