Various spelling fixes, docs improvements and code cleanup
This commit is contained in:
@@ -25,8 +25,8 @@ pub struct RawInput {
|
||||
/// `None` will be treated as "same as last frame", with the default being a very big area.
|
||||
pub screen_rect: Option<Rect>,
|
||||
|
||||
/// Also known as device pixel ratio, > 1 for HDPI screens.
|
||||
/// If text looks blurry on high resolution screens, you probably forgot to set this.
|
||||
/// Also known as device pixel ratio, > 1 for high resolution screens.
|
||||
/// If text looks blurry you probably forgot to set this.
|
||||
/// Set this the first frame, whenever it changes, or just on every frame.
|
||||
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 => {
|
||||
ui.add(Separator::new().horizontal());
|
||||
ui.add(Separator::default().horizontal());
|
||||
}
|
||||
easy_mark::Item::Indentation(indent) => {
|
||||
let indent = indent as f32 * one_indent;
|
||||
|
||||
@@ -24,7 +24,7 @@ pub struct InputState {
|
||||
/// Position and size of the egui area.
|
||||
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,
|
||||
|
||||
/// Time in seconds. Relative to whatever. Used for animation.
|
||||
@@ -79,7 +79,7 @@ impl InputState {
|
||||
let unstable_dt = (time - self.time) as f32;
|
||||
let screen_rect = new.screen_rect.unwrap_or_else(|| {
|
||||
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 {
|
||||
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 {
|
||||
self.pixels_per_point
|
||||
}
|
||||
@@ -257,8 +257,6 @@ pub struct PointerState {
|
||||
/// Used to check for double-clicks.
|
||||
last_click_time: f64,
|
||||
|
||||
// /// All clicks that occurred this frame
|
||||
// clicks: Vec<Click>,
|
||||
/// All button events that occurred this frame
|
||||
pub(crate) pointer_events: Vec<PointerEvent>,
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ pub struct Response {
|
||||
/// The pointer clicked this thing this frame.
|
||||
pub(crate) clicked: [bool; NUM_POINTER_BUTTONS],
|
||||
|
||||
// TODO: `released` for sliders
|
||||
/// The thing was double-clicked.
|
||||
pub(crate) double_clicked: [bool; NUM_POINTER_BUTTONS],
|
||||
|
||||
|
||||
+2
-2
@@ -1000,9 +1000,9 @@ impl Ui {
|
||||
response
|
||||
}
|
||||
|
||||
/// Shortcut for `add(Separator::new())` (see [`Separator`]).
|
||||
/// Shortcut for `add(Separator::default())` (see [`Separator`]).
|
||||
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.
|
||||
|
||||
@@ -268,11 +268,11 @@ impl Label {
|
||||
let dy = if self.raised {
|
||||
-2.0
|
||||
} 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);
|
||||
(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 {
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
//! * `ui.add(Label::new("Text").text_color(color::red));`
|
||||
//! * `if ui.add(Button::new("Click me")).clicked() { ... }`
|
||||
|
||||
#![allow(clippy::new_without_default)]
|
||||
|
||||
use crate::*;
|
||||
|
||||
mod button;
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::*;
|
||||
/// # let ui = &mut egui::Ui::__test();
|
||||
/// // These are equivalent:
|
||||
/// 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);`"]
|
||||
pub struct Separator {
|
||||
@@ -16,13 +16,20 @@ pub struct Separator {
|
||||
is_horizontal_line: Option<bool>,
|
||||
}
|
||||
|
||||
impl Separator {
|
||||
pub fn new() -> Self {
|
||||
impl Default for Separator {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
spacing: 6.0,
|
||||
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.
|
||||
pub fn spacing(mut self, spacing: f32) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user