1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

More newlines for improved readability (#1880)

* Add blank lines above all `fn`, `impl`, `struct`, etc
* Even newlines between docstringed struct and enum fields
* Improve some documentation
This commit is contained in:
Emil Ernerfeldt
2022-08-02 17:26:33 +02:00
committed by GitHub
parent 5d8ef5326b
commit 10788ccc92
56 changed files with 306 additions and 12 deletions

View File

@@ -33,6 +33,7 @@ impl PartialEq for CCursor {
impl std::ops::Add<usize> for CCursor {
type Output = CCursor;
fn add(self, rhs: usize) -> Self::Output {
CCursor {
index: self.index.saturating_add(rhs),
@@ -43,6 +44,7 @@ impl std::ops::Add<usize> for CCursor {
impl std::ops::Sub<usize> for CCursor {
type Output = CCursor;
fn sub(self, rhs: usize) -> Self::Output {
CCursor {
index: self.index.saturating_sub(rhs),

View File

@@ -42,7 +42,9 @@ impl PointScale {
struct Paragraph {
/// Start of the next glyph to be added.
pub cursor_x: f32,
pub glyphs: Vec<Glyph>,
/// In case of an empty paragraph ("\n"), use this as height.
pub empty_paragraph_height: f32,
}
@@ -715,16 +717,21 @@ struct RowBreakCandidates {
/// Breaking at ` ` or other whitespace
/// is always the primary candidate.
space: Option<usize>,
/// Logograms (single character representing a whole word) are good candidates for line break.
logogram: Option<usize>,
/// Kana (Japanese hiragana and katakana) may be line broken unless before a gyōtō kinsoku character.
kana: Option<usize>,
/// Breaking at a dash is a super-
/// good idea.
dash: Option<usize>,
/// This is nicer for things like URLs, e.g. www.
/// example.com.
punctuation: Option<usize>,
/// Breaking after just random character is some
/// times necessary.
any: Option<usize>,

View File

@@ -395,14 +395,19 @@ impl Default for RowVisuals {
#[derive(Copy, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Glyph {
/// The character this glyph represents.
pub chr: char,
/// Relative to the galley position.
/// Logical position: pos.y is the same for all chars of the same [`TextFormat`].
pub pos: Pos2,
/// Advance width and font row height.
pub size: Vec2,
/// Position of the glyph in the font texture, in texels.
pub uv_rect: UvRect,
/// Index into [`LayoutJob::sections`]. Decides color etc.
pub section_index: u32,
}