From 530e9f667c0969b09edb68f7701f20c52a273d3a Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 10 Feb 2023 18:03:16 +0100 Subject: [PATCH] format: add some blank lines where it was needed --- crates/eframe/src/native/run.rs | 9 +++++++++ crates/eframe/src/web/backend.rs | 1 + crates/egui-wgpu/src/lib.rs | 4 ++++ crates/egui-winit/src/lib.rs | 1 + crates/egui/src/animation_manager.rs | 3 +++ crates/egui/src/containers/frame.rs | 5 +++++ crates/egui/src/context.rs | 1 + crates/egui/src/input_state.rs | 2 ++ crates/egui/src/input_state/touch_state.rs | 4 ++++ crates/egui/src/lib.rs | 12 ++++++++++++ crates/egui/src/style.rs | 2 ++ crates/emath/src/pos2.rs | 1 + crates/epaint/src/tessellator.rs | 4 ++++ examples/keyboard_events/src/main.rs | 1 + 14 files changed, 50 insertions(+) diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index 87b66fd6..fa687c5d 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -38,6 +38,7 @@ pub use epi::NativeOptions; #[derive(Debug)] enum EventResult { Wait, + /// Causes a synchronous repaint inside the event handler. This should only /// be used in special situations if the window must be repainted while /// handling a specific event. This occurs on Windows when handling resizes. @@ -45,20 +46,28 @@ enum EventResult { /// `RepaintNow` creates a new frame synchronously, and should therefore /// only be used for extremely urgent repaints. RepaintNow, + /// Queues a repaint for once the event loop handles its next redraw. Exists /// so that multiple input events can be handled in one frame. Does not /// cause any delay like `RepaintNow`. RepaintNext, + RepaintAt(Instant), + Exit, } trait WinitApp { fn is_focused(&self) -> bool; + fn integration(&self) -> Option<&EpiIntegration>; + fn window(&self) -> Option<&winit::window::Window>; + fn save_and_destroy(&mut self); + fn paint(&mut self) -> EventResult; + fn on_event( &mut self, event_loop: &EventLoopWindowTarget, diff --git a/crates/eframe/src/web/backend.rs b/crates/eframe/src/web/backend.rs index 7ec76924..76d05af5 100644 --- a/crates/eframe/src/web/backend.rs +++ b/crates/eframe/src/web/backend.rs @@ -466,6 +466,7 @@ impl EventToUnsubscribe { } } } + pub struct AppRunnerContainer { pub runner: AppRunnerRef, diff --git a/crates/egui-wgpu/src/lib.rs b/crates/egui-wgpu/src/lib.rs index 339df180..e5ba7f53 100644 --- a/crates/egui-wgpu/src/lib.rs +++ b/crates/egui-wgpu/src/lib.rs @@ -105,11 +105,13 @@ pub enum WgpuError { DeviceError(wgpu::RequestDeviceError), SurfaceError(wgpu::CreateSurfaceError), } + impl std::fmt::Display for WgpuError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Debug::fmt(self, f) } } + impl std::error::Error for WgpuError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { @@ -118,11 +120,13 @@ impl std::error::Error for WgpuError { } } } + impl From for WgpuError { fn from(e: wgpu::RequestDeviceError) -> Self { Self::DeviceError(e) } } + impl From for WgpuError { fn from(e: wgpu::CreateSurfaceError) -> Self { Self::SurfaceError(e) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 4a7c9ee9..5ae22a43 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -60,6 +60,7 @@ pub struct State { pointer_pos_in_points: Option, any_pointer_button_down: bool, current_cursor_icon: Option, + /// What egui uses. current_pixels_per_point: f32, diff --git a/crates/egui/src/animation_manager.rs b/crates/egui/src/animation_manager.rs index 3cc273bf..be181507 100644 --- a/crates/egui/src/animation_manager.rs +++ b/crates/egui/src/animation_manager.rs @@ -9,6 +9,7 @@ pub(crate) struct AnimationManager { #[derive(Clone, Debug)] struct BoolAnim { value: bool, + /// when did `value` last toggle? toggle_time: f64, } @@ -16,7 +17,9 @@ struct BoolAnim { #[derive(Clone, Debug)] struct ValueAnim { from_value: f32, + to_value: f32, + /// when did `value` last toggle? toggle_time: f64, } diff --git a/crates/egui/src/containers/frame.rs b/crates/egui/src/containers/frame.rs index dd00d4dd..fa1caee7 100644 --- a/crates/egui/src/containers/frame.rs +++ b/crates/egui/src/containers/frame.rs @@ -19,11 +19,16 @@ use epaint::*; pub struct Frame { /// Margin within the painted frame. pub inner_margin: Margin, + /// Margin outside the painted frame. pub outer_margin: Margin, + pub rounding: Rounding, + pub shadow: Shadow, + pub fill: Color32, + pub stroke: Stroke, } diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 8e731f36..b7b65fc3 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -65,6 +65,7 @@ struct ContextImpl { /// Written to during the frame. layer_rects_this_frame: ahash::HashMap>, + /// Read layer_rects_prev_frame: ahash::HashMap>, diff --git a/crates/egui/src/input_state.rs b/crates/egui/src/input_state.rs index 52f147b0..12b13253 100644 --- a/crates/egui/src/input_state.rs +++ b/crates/egui/src/input_state.rs @@ -447,8 +447,10 @@ impl InputState { #[derive(Clone, Debug, PartialEq)] pub(crate) struct Click { pub pos: Pos2, + /// 1 or 2 (double-click) or 3 (triple-click) pub count: u32, + /// Allows you to check for e.g. shift-click pub modifiers: Modifiers, } diff --git a/crates/egui/src/input_state/touch_state.rs b/crates/egui/src/input_state/touch_state.rs index e4a7a1f0..becd0d52 100644 --- a/crates/egui/src/input_state/touch_state.rs +++ b/crates/egui/src/input_state/touch_state.rs @@ -96,10 +96,14 @@ struct GestureState { struct DynGestureState { /// used for proportional zooming avg_distance: f32, + /// used for non-proportional zooming avg_abs_distance2: Vec2, + avg_pos: Pos2, + avg_force: f32, + heading: f32, } diff --git a/crates/egui/src/lib.rs b/crates/egui/src/lib.rs index 929526bb..b8069efd 100644 --- a/crates/egui/src/lib.rs +++ b/crates/egui/src/lib.rs @@ -513,18 +513,30 @@ pub mod special_emojis { #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub enum WidgetType { Label, // TODO(emilk): emit Label events + /// e.g. a hyperlink Link, + TextEdit, + Button, + Checkbox, + RadioButton, + SelectableLabel, + ComboBox, + Slider, + DragValue, + ColorButton, + ImageButton, + CollapsingHeader, /// If you cannot fit any of the above slots. diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 6b6c9080..01502405 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -305,6 +305,7 @@ pub struct Spacing { /// Margin between contents and scroll bar. pub scroll_bar_inner_margin: f32, + /// Margin between scroll bar and the outer container (e.g. right of a vertical scroll bar). pub scroll_bar_outer_margin: f32, } @@ -491,6 +492,7 @@ pub struct Visuals { pub resize_corner_size: f32, pub text_cursor_width: f32, + /// show where the text cursor would be if you clicked pub text_cursor_preview: bool, diff --git a/crates/emath/src/pos2.rs b/crates/emath/src/pos2.rs index 409b0493..bafbcf42 100644 --- a/crates/emath/src/pos2.rs +++ b/crates/emath/src/pos2.rs @@ -15,6 +15,7 @@ use crate::*; pub struct Pos2 { /// How far to the right. pub x: f32, + /// How far down. pub y: f32, // implicit w = 1 diff --git a/crates/epaint/src/tessellator.rs b/crates/epaint/src/tessellator.rs index fe80e478..a28daa60 100644 --- a/crates/epaint/src/tessellator.rs +++ b/crates/epaint/src/tessellator.rs @@ -973,12 +973,16 @@ pub struct Tessellator { pixels_per_point: f32, options: TessellationOptions, font_tex_size: [usize; 2], + /// See [`TextureAtlas::prepared_discs`]. prepared_discs: Vec, + /// size of feathering in points. normally the size of a physical pixel. 0.0 if disabled feathering: f32, + /// Only used for culling clip_rect: Rect, + scratchpad_points: Vec, scratchpad_path: Path, } diff --git a/examples/keyboard_events/src/main.rs b/examples/keyboard_events/src/main.rs index 1585d9a3..86f3a8e7 100644 --- a/examples/keyboard_events/src/main.rs +++ b/examples/keyboard_events/src/main.rs @@ -2,6 +2,7 @@ use eframe::egui; use egui::*; + fn main() -> Result<(), eframe::Error> { // Log to stdout (if you run with `RUST_LOG=debug`). tracing_subscriber::fmt::init();