mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
Lint vertical spacing in the code (#3224)
* Lint vertical spacing in the code * Add some vertical spacing for readability
This commit is contained in:
@@ -272,6 +272,7 @@ pub fn run_simple_native(
|
||||
struct SimpleApp<U> {
|
||||
update_fun: U,
|
||||
}
|
||||
|
||||
impl<U: FnMut(&egui::Context, &mut Frame)> App for SimpleApp<U> {
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut Frame) {
|
||||
(self.update_fun)(ctx, frame);
|
||||
|
||||
@@ -335,8 +335,10 @@ pub struct EpiIntegration {
|
||||
pub egui_ctx: egui::Context,
|
||||
pending_full_output: egui::FullOutput,
|
||||
egui_winit: egui_winit::State,
|
||||
|
||||
/// When set, it is time to close the native window.
|
||||
close: bool,
|
||||
|
||||
can_drag_window: bool,
|
||||
window_state: WindowState,
|
||||
follow_system_theme: bool,
|
||||
|
||||
@@ -22,6 +22,7 @@ use super::epi_integration::{self, EpiIntegration};
|
||||
pub enum UserEvent {
|
||||
RequestRepaint {
|
||||
when: Instant,
|
||||
|
||||
/// What the frame number was when the repaint was _requested_.
|
||||
frame_nr: u64,
|
||||
},
|
||||
|
||||
@@ -334,16 +334,22 @@ struct Prepared {
|
||||
state: State,
|
||||
has_bar: [bool; 2],
|
||||
auto_shrink: [bool; 2],
|
||||
|
||||
/// How much horizontal and vertical space are used up by the
|
||||
/// width of the vertical bar, and the height of the horizontal bar?
|
||||
current_bar_use: Vec2,
|
||||
|
||||
scroll_bar_visibility: ScrollBarVisibility,
|
||||
|
||||
/// Where on the screen the content is (excludes scroll bars).
|
||||
inner_rect: Rect,
|
||||
|
||||
content_ui: Ui,
|
||||
|
||||
/// Relative coordinates: the offset and size of the view of the inner UI.
|
||||
/// `viewport.min == ZERO` means we scrolled to the top.
|
||||
viewport: Rect,
|
||||
|
||||
scrolling_enabled: bool,
|
||||
stick_to_end: [bool; 2],
|
||||
}
|
||||
|
||||
@@ -693,27 +693,37 @@ pub enum Key {
|
||||
|
||||
/// The virtual keycode for the Minus key.
|
||||
Minus,
|
||||
|
||||
/// The virtual keycode for the Plus/Equals key.
|
||||
PlusEquals,
|
||||
|
||||
/// Either from the main row or from the numpad.
|
||||
Num0,
|
||||
|
||||
/// Either from the main row or from the numpad.
|
||||
Num1,
|
||||
|
||||
/// Either from the main row or from the numpad.
|
||||
Num2,
|
||||
|
||||
/// Either from the main row or from the numpad.
|
||||
Num3,
|
||||
|
||||
/// Either from the main row or from the numpad.
|
||||
Num4,
|
||||
|
||||
/// Either from the main row or from the numpad.
|
||||
Num5,
|
||||
|
||||
/// Either from the main row or from the numpad.
|
||||
Num6,
|
||||
|
||||
/// Either from the main row or from the numpad.
|
||||
Num7,
|
||||
|
||||
/// Either from the main row or from the numpad.
|
||||
Num8,
|
||||
|
||||
/// Either from the main row or from the numpad.
|
||||
Num9,
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ pub(crate) struct GridLayout {
|
||||
/// State previous frame (if any).
|
||||
/// This can be used to predict future sizes of cells.
|
||||
prev_state: State,
|
||||
|
||||
/// State accumulated during the current frame.
|
||||
curr_state: State,
|
||||
initial_available: Rect,
|
||||
|
||||
@@ -546,8 +546,10 @@ impl Memory {
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct Areas {
|
||||
areas: IdMap<area::State>,
|
||||
|
||||
/// Back-to-front. Top is last.
|
||||
order: Vec<LayerId>,
|
||||
|
||||
visible_last_frame: ahash::HashSet<LayerId>,
|
||||
visible_current_frame: ahash::HashSet<LayerId>,
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ pub struct Button {
|
||||
text: WidgetText,
|
||||
shortcut_text: WidgetText,
|
||||
wrap: Option<bool>,
|
||||
|
||||
/// None means default for interact
|
||||
fill: Option<Color32>,
|
||||
stroke: Option<Stroke>,
|
||||
|
||||
@@ -11,6 +11,7 @@ use crate::*;
|
||||
pub(crate) struct MonoState {
|
||||
last_dragged_id: Option<Id>,
|
||||
last_dragged_value: Option<f64>,
|
||||
|
||||
/// For temporary edit of a [`DragValue`] value.
|
||||
/// Couples with the current focus id.
|
||||
edit_string: Option<String>,
|
||||
|
||||
@@ -760,15 +760,22 @@ impl PlotItem for Text {
|
||||
/// A set of points.
|
||||
pub struct Points {
|
||||
pub(super) series: PlotPoints,
|
||||
|
||||
pub(super) shape: MarkerShape,
|
||||
|
||||
/// Color of the marker. `Color32::TRANSPARENT` means that it will be picked automatically.
|
||||
pub(super) color: Color32,
|
||||
|
||||
/// Whether to fill the marker. Does not apply to all types.
|
||||
pub(super) filled: bool,
|
||||
|
||||
/// The maximum extent of the marker from its center.
|
||||
pub(super) radius: f32,
|
||||
|
||||
pub(super) name: String,
|
||||
|
||||
pub(super) highlight: bool,
|
||||
|
||||
pub(super) stems: Option<f32>,
|
||||
}
|
||||
|
||||
@@ -1290,8 +1297,10 @@ pub struct BarChart {
|
||||
pub(super) bars: Vec<Bar>,
|
||||
pub(super) default_color: Color32,
|
||||
pub(super) name: String,
|
||||
|
||||
/// A custom element formatter
|
||||
pub(super) element_formatter: Option<Box<dyn Fn(&Bar, &BarChart) -> String>>,
|
||||
|
||||
highlight: bool,
|
||||
}
|
||||
|
||||
@@ -1460,8 +1469,10 @@ pub struct BoxPlot {
|
||||
pub(super) boxes: Vec<BoxElem>,
|
||||
pub(super) default_color: Color32,
|
||||
pub(super) name: String,
|
||||
|
||||
/// A custom element formatter
|
||||
pub(super) element_formatter: Option<Box<dyn Fn(&BoxElem, &BoxPlot) -> String>>,
|
||||
|
||||
highlight: bool,
|
||||
}
|
||||
|
||||
|
||||
@@ -101,9 +101,11 @@ struct PlotMemory {
|
||||
/// Indicates if the user has modified the bounds, for example by moving or zooming,
|
||||
/// or if the bounds should be calculated based by included point or auto bounds.
|
||||
bounds_modified: AxisBools,
|
||||
|
||||
hovered_entry: Option<String>,
|
||||
hidden_items: ahash::HashSet<String>,
|
||||
last_plot_transform: PlotTransform,
|
||||
|
||||
/// Allows to remember the first click position when performing a boxed zoom
|
||||
last_click_pos_for_zoom: Option<Pos2>,
|
||||
}
|
||||
|
||||
@@ -77,8 +77,10 @@ pub struct Slider<'a> {
|
||||
prefix: String,
|
||||
suffix: String,
|
||||
text: WidgetText,
|
||||
|
||||
/// Sets the minimal step of the widget value
|
||||
step: Option<f64>,
|
||||
|
||||
drag_value_speed: Option<f64>,
|
||||
min_decimals: usize,
|
||||
max_decimals: Option<usize>,
|
||||
|
||||
@@ -10,11 +10,15 @@ pub use usvg::FitTo;
|
||||
/// Use the `svg` and `image` features to enable more constructors.
|
||||
pub struct RetainedImage {
|
||||
debug_name: String,
|
||||
|
||||
size: [usize; 2],
|
||||
|
||||
/// Cleared once [`Self::texture`] has been loaded.
|
||||
image: Mutex<egui::ColorImage>,
|
||||
|
||||
/// Lazily loaded when we have an egui context.
|
||||
texture: Mutex<Option<egui::TextureHandle>>,
|
||||
|
||||
options: TextureOptions,
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,11 @@ pub struct StripLayout<'l> {
|
||||
direction: CellDirection,
|
||||
pub(crate) rect: Rect,
|
||||
pub(crate) cursor: Pos2,
|
||||
|
||||
/// Keeps track of the max used position,
|
||||
/// so we know how much space we used.
|
||||
max: Pos2,
|
||||
|
||||
cell_layout: egui::Layout,
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,9 @@ enum InitialColumnSize {
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Column {
|
||||
initial_width: InitialColumnSize,
|
||||
|
||||
width_range: Rangef,
|
||||
|
||||
/// Clip contents if too narrow?
|
||||
clip: bool,
|
||||
|
||||
@@ -511,8 +513,10 @@ pub struct Table<'a> {
|
||||
columns: Vec<Column>,
|
||||
available_width: f32,
|
||||
state: TableState,
|
||||
|
||||
/// Accumulated maximum used widths for each column.
|
||||
max_used_widths: Vec<f32>,
|
||||
|
||||
first_frame_auto_size_columns: bool,
|
||||
resizable: bool,
|
||||
striped: bool,
|
||||
@@ -1011,8 +1015,10 @@ pub struct TableRow<'a, 'b> {
|
||||
layout: &'b mut StripLayout<'a>,
|
||||
columns: &'b [Column],
|
||||
widths: &'b [f32],
|
||||
|
||||
/// grows during building with the maximum widths
|
||||
max_used_widths: &'b mut [f32],
|
||||
|
||||
col_index: usize,
|
||||
striped: bool,
|
||||
height: f32,
|
||||
|
||||
@@ -13,17 +13,15 @@ use emath::*;
|
||||
|
||||
#[allow(clippy::approx_constant)]
|
||||
mod precomputed_vertices {
|
||||
/*
|
||||
fn main() {
|
||||
let n = 64;
|
||||
println!("pub const CIRCLE_{}: [Vec2; {}] = [", n, n+1);
|
||||
for i in 0..=n {
|
||||
let a = std::f64::consts::TAU * i as f64 / n as f64;
|
||||
println!(" vec2({:.06}, {:.06}),", a.cos(), a.sin());
|
||||
}
|
||||
println!("];")
|
||||
}
|
||||
*/
|
||||
// fn main() {
|
||||
// let n = 64;
|
||||
// println!("pub const CIRCLE_{}: [Vec2; {}] = [", n, n+1);
|
||||
// for i in 0..=n {
|
||||
// let a = std::f64::consts::TAU * i as f64 / n as f64;
|
||||
// println!(" vec2({:.06}, {:.06}),", a.cos(), a.sin());
|
||||
// }
|
||||
// println!("];")
|
||||
// }
|
||||
|
||||
use emath::{vec2, Vec2};
|
||||
|
||||
|
||||
@@ -78,11 +78,15 @@ impl Default for GlyphInfo {
|
||||
pub struct FontImpl {
|
||||
name: String,
|
||||
ab_glyph_font: ab_glyph::FontArc,
|
||||
|
||||
/// Maximum character height
|
||||
scale_in_pixels: u32,
|
||||
|
||||
height_in_points: f32,
|
||||
|
||||
// move each character by this much (hack)
|
||||
y_offset: f32,
|
||||
|
||||
ascent: f32,
|
||||
pixels_per_point: f32,
|
||||
glyph_info_cache: RwLock<ahash::HashMap<char, GlyphInfo>>, // TODO(emilk): standard Mutex
|
||||
@@ -320,8 +324,10 @@ type FontIndex = usize;
|
||||
/// Wrapper over multiple [`FontImpl`] (e.g. a primary + fallbacks for emojis)
|
||||
pub struct Font {
|
||||
fonts: Vec<Arc<FontImpl>>,
|
||||
|
||||
/// Lazily calculated.
|
||||
characters: Option<BTreeSet<char>>,
|
||||
|
||||
replacement_glyph: (FontIndex, GlyphInfo),
|
||||
pixels_per_point: f32,
|
||||
row_height: f32,
|
||||
|
||||
@@ -193,8 +193,10 @@ impl std::hash::Hash for LayoutJob {
|
||||
pub struct LayoutSection {
|
||||
/// Can be used for first row indentation.
|
||||
pub leading_space: f32,
|
||||
|
||||
/// Range into the galley text
|
||||
pub byte_range: Range<usize>,
|
||||
|
||||
pub format: TextFormat,
|
||||
}
|
||||
|
||||
@@ -218,12 +220,18 @@ impl std::hash::Hash for LayoutSection {
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct TextFormat {
|
||||
pub font_id: FontId,
|
||||
|
||||
/// Text color
|
||||
pub color: Color32,
|
||||
|
||||
pub background: Color32,
|
||||
|
||||
pub italics: bool,
|
||||
|
||||
pub underline: Stroke,
|
||||
|
||||
pub strikethrough: Stroke,
|
||||
|
||||
/// If you use a small font and [`Align::TOP`] you
|
||||
/// can get the effect of raised text.
|
||||
pub valign: Align,
|
||||
|
||||
@@ -9,8 +9,10 @@ use crate::{ImageData, ImageDelta, TextureId};
|
||||
pub struct TextureManager {
|
||||
/// We allocate texture id:s linearly.
|
||||
next_id: u64,
|
||||
|
||||
/// Information about currently allocated textures.
|
||||
metas: ahash::HashMap<TextureId, TextureMeta>,
|
||||
|
||||
delta: TexturesDelta,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user