Various spelling fixes, docs improvements and code cleanup
This commit is contained in:
parent
1f965d16a2
commit
f6770f0183
13 changed files with 36 additions and 34 deletions
2
check.sh
2
check.sh
|
@ -13,7 +13,7 @@ CARGO_INCREMENTAL=0 cargo clippy --workspace --all-targets --all-features -- -D
|
||||||
cargo test --workspace --all-targets --all-features
|
cargo test --workspace --all-targets --all-features
|
||||||
cargo fmt --all -- --check
|
cargo fmt --all -- --check
|
||||||
|
|
||||||
# TODO: doesn't error, but at least prints a warning.
|
# TODO: make cargo doc produce a proper error (it only prints a warning at the moment).
|
||||||
cargo doc -p emath -p epaint -p egui -p eframe -p epi -p egui_web -p egui_glium --lib --no-deps
|
cargo doc -p emath -p epaint -p egui -p eframe -p epi -p egui_web -p egui_glium --lib --no-deps
|
||||||
cargo doc -p egui_web --target wasm32-unknown-unknown --lib --no-deps
|
cargo doc -p egui_web --target wasm32-unknown-unknown --lib --no-deps
|
||||||
|
|
||||||
|
|
|
@ -65,10 +65,12 @@
|
||||||
// Here we tell bindgen the path to the wasm file so it can start
|
// Here we tell bindgen the path to the wasm file so it can start
|
||||||
// initialization and return to us a promise when it's done.
|
// initialization and return to us a promise when it's done.
|
||||||
wasm_bindgen("./egui_demo_app_bg.wasm")
|
wasm_bindgen("./egui_demo_app_bg.wasm")
|
||||||
.then(on_wasm_loaded)["catch"](console.error);
|
.then(on_wasm_loaded)
|
||||||
|
.catch(console.error);
|
||||||
|
|
||||||
function on_wasm_loaded() {
|
function on_wasm_loaded() {
|
||||||
// This call installs a bunch of callbacks and then returns.
|
// This call installs a bunch of callbacks and then returns.
|
||||||
|
console.log("loaded wasm, starting egui app");
|
||||||
wasm_bindgen.start("the_canvas_id");
|
wasm_bindgen.start("the_canvas_id");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -25,8 +25,8 @@ pub struct RawInput {
|
||||||
/// `None` will be treated as "same as last frame", with the default being a very big area.
|
/// `None` will be treated as "same as last frame", with the default being a very big area.
|
||||||
pub screen_rect: Option<Rect>,
|
pub screen_rect: Option<Rect>,
|
||||||
|
|
||||||
/// Also known as device pixel ratio, > 1 for HDPI screens.
|
/// Also known as device pixel ratio, > 1 for high resolution screens.
|
||||||
/// If text looks blurry on high resolution screens, you probably forgot to set this.
|
/// If text looks blurry you probably forgot to set this.
|
||||||
/// Set this the first frame, whenever it changes, or just on every frame.
|
/// Set this the first frame, whenever it changes, or just on every frame.
|
||||||
pub pixels_per_point: Option<f32>,
|
pub pixels_per_point: Option<f32>,
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub fn item_ui(ui: &mut Ui, item: easy_mark::Item<'_>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
easy_mark::Item::Separator => {
|
easy_mark::Item::Separator => {
|
||||||
ui.add(Separator::new().horizontal());
|
ui.add(Separator::default().horizontal());
|
||||||
}
|
}
|
||||||
easy_mark::Item::Indentation(indent) => {
|
easy_mark::Item::Indentation(indent) => {
|
||||||
let indent = indent as f32 * one_indent;
|
let indent = indent as f32 * one_indent;
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub struct InputState {
|
||||||
/// Position and size of the egui area.
|
/// Position and size of the egui area.
|
||||||
pub screen_rect: Rect,
|
pub screen_rect: Rect,
|
||||||
|
|
||||||
/// Also known as device pixel ratio, > 1 for HDPI screens.
|
/// Also known as device pixel ratio, > 1 for high resolution screens.
|
||||||
pub pixels_per_point: f32,
|
pub pixels_per_point: f32,
|
||||||
|
|
||||||
/// Time in seconds. Relative to whatever. Used for animation.
|
/// Time in seconds. Relative to whatever. Used for animation.
|
||||||
|
@ -79,7 +79,7 @@ impl InputState {
|
||||||
let unstable_dt = (time - self.time) as f32;
|
let unstable_dt = (time - self.time) as f32;
|
||||||
let screen_rect = new.screen_rect.unwrap_or_else(|| {
|
let screen_rect = new.screen_rect.unwrap_or_else(|| {
|
||||||
if new.screen_size != Default::default() {
|
if new.screen_size != Default::default() {
|
||||||
Rect::from_min_size(Default::default(), new.screen_size) // backwards compatability
|
Rect::from_min_size(Default::default(), new.screen_size) // backwards compatibility
|
||||||
} else {
|
} else {
|
||||||
self.screen_rect
|
self.screen_rect
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ impl InputState {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Also known as device pixel ratio, > 1 for HDPI screens.
|
/// Also known as device pixel ratio, > 1 for high resolution screens.
|
||||||
pub fn pixels_per_point(&self) -> f32 {
|
pub fn pixels_per_point(&self) -> f32 {
|
||||||
self.pixels_per_point
|
self.pixels_per_point
|
||||||
}
|
}
|
||||||
|
@ -257,8 +257,6 @@ pub struct PointerState {
|
||||||
/// Used to check for double-clicks.
|
/// Used to check for double-clicks.
|
||||||
last_click_time: f64,
|
last_click_time: f64,
|
||||||
|
|
||||||
// /// All clicks that occurred this frame
|
|
||||||
// clicks: Vec<Click>,
|
|
||||||
/// All button events that occurred this frame
|
/// All button events that occurred this frame
|
||||||
pub(crate) pointer_events: Vec<PointerEvent>,
|
pub(crate) pointer_events: Vec<PointerEvent>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ pub struct Response {
|
||||||
/// The pointer clicked this thing this frame.
|
/// The pointer clicked this thing this frame.
|
||||||
pub(crate) clicked: [bool; NUM_POINTER_BUTTONS],
|
pub(crate) clicked: [bool; NUM_POINTER_BUTTONS],
|
||||||
|
|
||||||
|
// TODO: `released` for sliders
|
||||||
/// The thing was double-clicked.
|
/// The thing was double-clicked.
|
||||||
pub(crate) double_clicked: [bool; NUM_POINTER_BUTTONS],
|
pub(crate) double_clicked: [bool; NUM_POINTER_BUTTONS],
|
||||||
|
|
||||||
|
|
|
@ -1000,9 +1000,9 @@ impl Ui {
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shortcut for `add(Separator::new())` (see [`Separator`]).
|
/// Shortcut for `add(Separator::default())` (see [`Separator`]).
|
||||||
pub fn separator(&mut self) -> Response {
|
pub fn separator(&mut self) -> Response {
|
||||||
self.add(Separator::new())
|
self.add(Separator::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Modify an angle. The given angle should be in radians, but is shown to the user in degrees.
|
/// Modify an angle. The given angle should be in radians, but is shown to the user in degrees.
|
||||||
|
|
|
@ -268,11 +268,11 @@ impl Label {
|
||||||
let dy = if self.raised {
|
let dy = if self.raised {
|
||||||
-2.0
|
-2.0
|
||||||
} else {
|
} else {
|
||||||
let normal_text_heigth = ui.fonts()[TextStyle::Body].row_height();
|
let normal_text_height = ui.fonts()[TextStyle::Body].row_height();
|
||||||
let font_height = ui.fonts().row_height(text_style);
|
let font_height = ui.fonts().row_height(text_style);
|
||||||
(normal_text_heigth - font_height) / 2.0 - 1.0 // center
|
(normal_text_height - font_height) / 2.0 - 1.0 // center
|
||||||
|
|
||||||
// normal_text_heigth - font_height // align bottom
|
// normal_text_height - font_height // align bottom
|
||||||
};
|
};
|
||||||
|
|
||||||
if dy != 0.0 {
|
if dy != 0.0 {
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
//! * `ui.add(Label::new("Text").text_color(color::red));`
|
//! * `ui.add(Label::new("Text").text_color(color::red));`
|
||||||
//! * `if ui.add(Button::new("Click me")).clicked() { ... }`
|
//! * `if ui.add(Button::new("Click me")).clicked() { ... }`
|
||||||
|
|
||||||
#![allow(clippy::new_without_default)]
|
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
mod button;
|
mod button;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::*;
|
||||||
/// # let ui = &mut egui::Ui::__test();
|
/// # let ui = &mut egui::Ui::__test();
|
||||||
/// // These are equivalent:
|
/// // These are equivalent:
|
||||||
/// ui.separator();
|
/// ui.separator();
|
||||||
/// ui.add(egui::Separator::new());
|
/// ui.add(egui::Separator::default());
|
||||||
/// ```
|
/// ```
|
||||||
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
|
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
|
||||||
pub struct Separator {
|
pub struct Separator {
|
||||||
|
@ -16,13 +16,20 @@ pub struct Separator {
|
||||||
is_horizontal_line: Option<bool>,
|
is_horizontal_line: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Separator {
|
impl Default for Separator {
|
||||||
pub fn new() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
spacing: 6.0,
|
spacing: 6.0,
|
||||||
is_horizontal_line: None,
|
is_horizontal_line: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Separator {
|
||||||
|
#[deprecated = "Use Separator::default() instead"]
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self::default()
|
||||||
|
}
|
||||||
|
|
||||||
/// How much space we take up. The line is painted in the middle of this.
|
/// How much space we take up. The line is painted in the middle of this.
|
||||||
pub fn spacing(mut self, spacing: f32) -> Self {
|
pub fn spacing(mut self, spacing: f32) -> Self {
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
use egui::{containers::*, *};
|
use egui::{containers::*, *};
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "persistence", serde(default))]
|
||||||
pub struct DancingStrings {}
|
pub struct DancingStrings {}
|
||||||
|
|
||||||
impl Default for DancingStrings {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl super::Demo for DancingStrings {
|
impl super::Demo for DancingStrings {
|
||||||
fn name(&self) -> &'static str {
|
fn name(&self) -> &'static str {
|
||||||
"♫ Dancing Strings"
|
"♫ Dancing Strings"
|
||||||
|
|
|
@ -83,8 +83,6 @@ fn set_open(open: &mut BTreeSet<String>, key: &'static str, is_open: bool) {
|
||||||
#[cfg_attr(feature = "persistence", serde(default))]
|
#[cfg_attr(feature = "persistence", serde(default))]
|
||||||
pub struct DemoWindows {
|
pub struct DemoWindows {
|
||||||
open_windows: OpenWindows,
|
open_windows: OpenWindows,
|
||||||
|
|
||||||
/// open, title, view
|
|
||||||
demos: Demos,
|
demos: Demos,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +113,10 @@ impl DemoWindows {
|
||||||
|
|
||||||
ui.heading("Windows:");
|
ui.heading("Windows:");
|
||||||
self.demos.checkboxes(ui);
|
self.demos.checkboxes(ui);
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
|
|
||||||
|
ui.label("egui:");
|
||||||
self.open_windows.checkboxes(ui);
|
self.open_windows.checkboxes(ui);
|
||||||
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
@ -209,8 +211,6 @@ impl OpenWindows {
|
||||||
memory,
|
memory,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
ui.separator();
|
|
||||||
ui.label("egui:");
|
|
||||||
ui.checkbox(settings, "🔧 Settings");
|
ui.checkbox(settings, "🔧 Settings");
|
||||||
ui.checkbox(inspection, "🔍 Inspection");
|
ui.checkbox(inspection, "🔍 Inspection");
|
||||||
ui.checkbox(memory, "📝 Memory");
|
ui.checkbox(memory, "📝 Memory");
|
||||||
|
|
|
@ -16,13 +16,14 @@ impl super::Demo for CursorTest {
|
||||||
|
|
||||||
impl super::View for CursorTest {
|
impl super::View for CursorTest {
|
||||||
fn ui(&mut self, ui: &mut egui::Ui) {
|
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||||
ui.heading("Hover to switch cursor icon:");
|
|
||||||
ui.vertical_centered_justified(|ui| {
|
ui.vertical_centered_justified(|ui| {
|
||||||
|
ui.heading("Hover to switch cursor icon:");
|
||||||
for &cursor_icon in &egui::CursorIcon::ALL {
|
for &cursor_icon in &egui::CursorIcon::ALL {
|
||||||
let _ = ui
|
let _ = ui
|
||||||
.button(format!("{:?}", cursor_icon))
|
.button(format!("{:?}", cursor_icon))
|
||||||
.on_hover_cursor(cursor_icon);
|
.on_hover_cursor(cursor_icon);
|
||||||
}
|
}
|
||||||
|
ui.add(crate::__egui_github_link_file!());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,14 +296,14 @@ impl super::View for InputTest {
|
||||||
egui::PointerButton::Middle,
|
egui::PointerButton::Middle,
|
||||||
] {
|
] {
|
||||||
if response.clicked_by(button) {
|
if response.clicked_by(button) {
|
||||||
new_info += &format!("Clicked by {:?}\n", button);
|
new_info += &format!("Clicked by {:?} button\n", button);
|
||||||
}
|
}
|
||||||
if response.double_clicked_by(button) {
|
if response.double_clicked_by(button) {
|
||||||
new_info += &format!("Double-clicked by {:?}\n", button);
|
new_info += &format!("Double-clicked by {:?} button\n", button);
|
||||||
}
|
}
|
||||||
if response.dragged_by(button) {
|
if response.dragged_by(button) {
|
||||||
new_info += &format!(
|
new_info += &format!(
|
||||||
"Dragged by {:?}, delta: {:?}\n",
|
"Dragged by {:?} button, delta: {:?}\n",
|
||||||
button,
|
button,
|
||||||
response.drag_delta()
|
response.drag_delta()
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue