1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -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:
Emil Ernerfeldt
2023-08-10 15:26:54 +02:00
committed by GitHub
parent 83c18498e9
commit d568d9f5d0
22 changed files with 215 additions and 14 deletions

View File

@@ -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};

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,
}