1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-28 07:23:13 -04:00

Replace TODO: with TODO(emilk): and update code guidelines

This commit is contained in:
Emil Ernerfeldt
2022-05-21 16:53:25 +02:00
parent 3d5e203d86
commit f3e305a646
60 changed files with 140 additions and 112 deletions

View File

@@ -38,7 +38,7 @@ pub struct Mesh {
/// The texture to use when drawing these triangles.
pub texture_id: TextureId,
// TODO: bounding rectangle
// TODO(emilk): bounding rectangle
}
impl Mesh {

View File

@@ -47,7 +47,7 @@ impl Shadow {
}
pub fn tessellate(&self, rect: emath::Rect, rounding: impl Into<Rounding>) -> Mesh {
// tessellator.clip_rect = clip_rect; // TODO: culling
// tessellator.clip_rect = clip_rect; // TODO(emilk): culling
let Self { extrusion, color } = *self;

View File

@@ -339,7 +339,7 @@ impl Path {
pub fn add_circle(&mut self, center: Pos2, radius: f32) {
use precomputed_vertices::*;
// These cutoffs are based on a high-dpi display. TODO: use pixels_per_point here?
// These cutoffs are based on a high-dpi display. TODO(emilk): use pixels_per_point here?
// same cutoffs as in add_circle_quadrant
if radius <= 2.0 {
@@ -547,7 +547,7 @@ pub mod path {
pub fn add_circle_quadrant(path: &mut Vec<Pos2>, center: Pos2, radius: f32, quadrant: f32) {
use super::precomputed_vertices::*;
// These cutoffs are based on a high-dpi display. TODO: use pixels_per_point here?
// These cutoffs are based on a high-dpi display. TODO(emilk): use pixels_per_point here?
// same cutoffs as in add_circle
if radius <= 0.0 {
@@ -1171,7 +1171,7 @@ impl Tessellator {
let cutoff_radius = radius_px * 2.0_f32.powf(0.25);
// Find the right disc radius for a crisp edge:
// TODO: perhaps we can do something faster than this linear search.
// TODO(emilk): perhaps we can do something faster than this linear search.
for disc in &self.prepared_discs {
if cutoff_radius <= disc.r {
let side = radius_px * disc.w / (self.pixels_per_point * disc.r);

View File

@@ -66,7 +66,7 @@ pub struct FontImpl {
// move each character by this much (hack)
y_offset: f32,
pixels_per_point: f32,
glyph_info_cache: RwLock<AHashMap<char, GlyphInfo>>, // TODO: standard Mutex
glyph_info_cache: RwLock<AHashMap<char, GlyphInfo>>, // TODO(emilk): standard Mutex
atlas: Arc<Mutex<TextureAtlas>>,
}
@@ -84,7 +84,7 @@ impl FontImpl {
let height_in_points = scale_in_pixels as f32 / pixels_per_point;
// TODO: use these font metrics?
// TODO(emilk): use these font metrics?
// use ab_glyph::ScaleFont as _;
// let scaled = ab_glyph_font.as_scaled(scale_in_pixels as f32);
// dbg!(scaled.ascent());
@@ -212,7 +212,7 @@ impl FontImpl {
type FontIndex = usize;
// TODO: rename?
// TODO(emilk): rename?
/// Wrapper over multiple [`FontImpl`] (e.g. a primary + fallbacks for emojis)
pub struct Font {
fonts: Vec<Arc<FontImpl>>,
@@ -349,7 +349,7 @@ fn invisible_char(c: char) -> bool {
// See https://github.com/emilk/egui/issues/336
// From https://www.fileformat.info/info/unicode/category/Cf/list.htm
('\u{200B}'..='\u{206F}').contains(&c) // TODO: heed bidi characters
('\u{200B}'..='\u{206F}').contains(&c) // TODO(emilk): heed bidi characters
}
fn allocate_glyph(

View File

@@ -22,7 +22,7 @@ pub struct FontId {
/// What font family to use.
pub family: FontFamily,
// TODO: weight (bold), italics, …
// TODO(emilk): weight (bold), italics, …
}
impl Default for FontId {
@@ -240,7 +240,6 @@ pub struct FontDefinitions {
/// When looking for a character glyph `epaint` will start with
/// the first font and then move to the second, and so on.
/// So the first font is the primary, and then comes a list of fallbacks in order of priority.
// TODO: per font size-modifier.
pub families: BTreeMap<FontFamily, Vec<String>>,
}
@@ -618,7 +617,7 @@ struct GalleyCache {
impl GalleyCache {
fn layout(&mut self, fonts: &mut FontsImpl, job: LayoutJob) -> Arc<Galley> {
let hash = crate::util::hash(&job); // TODO: even faster hasher?
let hash = crate::util::hash(&job); // TODO(emilk): even faster hasher?
match self.cache.entry(hash) {
std::collections::hash_map::Entry::Occupied(entry) => {

View File

@@ -98,7 +98,7 @@ fn layout_section(
let mut paragraph = out_paragraphs.last_mut().unwrap();
if paragraph.glyphs.is_empty() {
paragraph.empty_paragraph_height = font_height; // TODO: replace this hack with actually including `\n` in the glyphs?
paragraph.empty_paragraph_height = font_height; // TODO(emilk): replace this hack with actually including `\n` in the glyphs?
}
paragraph.cursor_x += leading_space;
@@ -109,7 +109,7 @@ fn layout_section(
if job.break_on_newline && chr == '\n' {
out_paragraphs.push(Paragraph::default());
paragraph = out_paragraphs.last_mut().unwrap();
paragraph.empty_paragraph_height = font_height; // TODO: replace this hack with actually including `\n` in the glyphs?
paragraph.empty_paragraph_height = font_height; // TODO(emilk): replace this hack with actually including `\n` in the glyphs?
} else {
let (font_impl, glyph_info) = font.glyph_info_and_font_impl(chr);
if let Some(font_impl) = font_impl {
@@ -207,7 +207,7 @@ fn line_break(
&& !row_break_candidates.has_good_candidate(job.wrap.break_anywhere)
{
// Allow the first row to be completely empty, because we know there will be more space on the next row:
// TODO: this records the height of this first row as zero, though that is probably fine since first_row_indentation usually comes with a first_row_min_height.
// TODO(emilk): this records the height of this first row as zero, though that is probably fine since first_row_indentation usually comes with a first_row_min_height.
out_rows.push(Row {
glyphs: vec![],
visuals: Default::default(),
@@ -685,7 +685,7 @@ fn add_hline(point_scale: PointScale, [start, stop]: [Pos2; 2], stroke: Stroke,
let antialiased = true;
if antialiased {
let mut path = crate::tessellator::Path::default(); // TODO: reuse this to avoid re-allocations.
let mut path = crate::tessellator::Path::default(); // TODO(emilk): reuse this to avoid re-allocations.
path.add_line_segment([start, stop]);
let feathering = 1.0 / point_scale.pixels_per_point();
path.stroke_open(feathering, stroke, mesh);

View File

@@ -227,7 +227,7 @@ pub struct TextFormat {
/// If you use a small font and [`Align::TOP`] you
/// can get the effect of raised text.
pub valign: Align,
// TODO: lowered
// TODO(emilk): lowered
}
impl Default for TextFormat {
@@ -735,7 +735,7 @@ impl Galley {
}
}
// TODO: return identical cursor, or clamp?
// TODO(emilk): return identical cursor, or clamp?
pub fn from_pcursor(&self, pcursor: PCursor) -> Cursor {
let prefer_next_row = pcursor.prefer_next_row;
let mut ccursor_it = CCursor {

View File

@@ -87,7 +87,7 @@ impl TextureAtlas {
image[pos] = 1.0;
// Allocate a series of anti-aliased discs used to render small filled circles:
// TODO: these circles can be packed A LOT better.
// TODO(emilk): these circles can be packed A LOT better.
// In fact, the whole texture atlas could be packed a lot better.
// for r in [1, 2, 4, 8, 16, 32, 64] {
// let w = 2 * r + 3;