mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -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:
@@ -265,9 +265,11 @@ impl Gradient {
|
||||
pub fn one_color(srgba: Color32) -> Self {
|
||||
Self(vec![srgba, srgba])
|
||||
}
|
||||
|
||||
pub fn texture_gradient(left: Color32, right: Color32) -> Self {
|
||||
Self(vec![left, right])
|
||||
}
|
||||
|
||||
pub fn ground_truth_linear_gradient(left: Color32, right: Color32) -> Self {
|
||||
let left = Rgba::from(left);
|
||||
let right = Rgba::from(right);
|
||||
@@ -282,6 +284,7 @@ impl Gradient {
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
||||
/// This is how a bad person blends `sRGBA`
|
||||
pub fn ground_truth_bad_srgba_gradient(left: Color32, right: Color32) -> Self {
|
||||
let n = 255;
|
||||
|
||||
@@ -10,6 +10,7 @@ fn gaussian(x: f64) -> f64 {
|
||||
let var: f64 = 2.0;
|
||||
f64::exp(-(x / var).powi(2)) / (var * f64::sqrt(std::f64::consts::TAU))
|
||||
}
|
||||
|
||||
fn sigmoid(x: f64) -> f64 {
|
||||
-1.0 + 2.0 / (1.0 + f64::exp(-x))
|
||||
}
|
||||
|
||||
@@ -75,12 +75,14 @@ pub fn drop_target<R>(
|
||||
|
||||
InnerResponse::new(ret, response)
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct DragAndDropDemo {
|
||||
/// columns with items
|
||||
columns: Vec<Vec<String>>,
|
||||
}
|
||||
|
||||
impl Default for DragAndDropDemo {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
||||
@@ -47,6 +47,7 @@ impl LayoutSettings {
|
||||
cross_justify: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn top_down_justified_centered() -> Self {
|
||||
Self {
|
||||
main_dir: Direction::TopDown,
|
||||
@@ -55,6 +56,7 @@ impl LayoutSettings {
|
||||
cross_justify: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn horizontal_wrapped() -> Self {
|
||||
Self {
|
||||
main_dir: Direction::LeftToRight,
|
||||
|
||||
@@ -426,6 +426,7 @@ impl Tree {
|
||||
Tree(vec![Tree(vec![Tree::default(); 2]); 3]),
|
||||
])
|
||||
}
|
||||
|
||||
pub fn ui(&mut self, ui: &mut Ui) -> Action {
|
||||
self.ui_impl(ui, 0, "root")
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use egui::*;
|
||||
pub struct PaintBezier {
|
||||
/// Bézier curve degree, it can be 3, 4.
|
||||
degree: usize,
|
||||
|
||||
/// The control points. The [`Self::degree`] first of them are used.
|
||||
control_points: [Pos2; 4],
|
||||
|
||||
|
||||
@@ -265,6 +265,7 @@ impl LegendDemo {
|
||||
100,
|
||||
))
|
||||
}
|
||||
|
||||
fn sin() -> Line {
|
||||
Line::new(PlotPoints::from_explicit_callback(
|
||||
move |x| x.sin(),
|
||||
@@ -272,6 +273,7 @@ impl LegendDemo {
|
||||
100,
|
||||
))
|
||||
}
|
||||
|
||||
fn cos() -> Line {
|
||||
Line::new(PlotPoints::from_explicit_callback(
|
||||
move |x| x.cos(),
|
||||
@@ -390,12 +392,15 @@ impl CustomAxisDemo {
|
||||
fn get_day(x: f64) -> f64 {
|
||||
(x / MINS_PER_DAY).floor()
|
||||
}
|
||||
|
||||
fn get_hour(x: f64) -> f64 {
|
||||
(x.rem_euclid(MINS_PER_DAY) / MINS_PER_H).floor()
|
||||
}
|
||||
|
||||
fn get_minute(x: f64) -> f64 {
|
||||
x.rem_euclid(MINS_PER_H).floor()
|
||||
}
|
||||
|
||||
fn get_percent(y: f64) -> f64 {
|
||||
100.0 * y
|
||||
}
|
||||
@@ -476,6 +481,7 @@ impl LinkedAxisDemo {
|
||||
100,
|
||||
))
|
||||
}
|
||||
|
||||
fn sin() -> Line {
|
||||
Line::new(PlotPoints::from_explicit_callback(
|
||||
move |x| x.sin(),
|
||||
@@ -483,6 +489,7 @@ impl LinkedAxisDemo {
|
||||
100,
|
||||
))
|
||||
}
|
||||
|
||||
fn cos() -> Line {
|
||||
Line::new(PlotPoints::from_explicit_callback(
|
||||
move |x| x.cos(),
|
||||
|
||||
@@ -12,20 +12,28 @@ pub enum Item<'a> {
|
||||
/// `\n`
|
||||
// TODO(emilk): add Style here so empty heading still uses up the right amount of space.
|
||||
Newline,
|
||||
|
||||
///
|
||||
Text(Style, &'a str),
|
||||
|
||||
/// title, url
|
||||
Hyperlink(Style, &'a str, &'a str),
|
||||
|
||||
/// leading space before e.g. a [`Self::BulletPoint`].
|
||||
Indentation(usize),
|
||||
|
||||
/// >
|
||||
QuoteIndent,
|
||||
|
||||
/// - a point well made.
|
||||
BulletPoint,
|
||||
|
||||
/// 1. numbered list. The string is the number(s).
|
||||
NumberedPoint(&'a str),
|
||||
|
||||
/// ---
|
||||
Separator,
|
||||
|
||||
/// language, code
|
||||
CodeBlock(&'a str, &'a str),
|
||||
}
|
||||
@@ -34,20 +42,28 @@ pub enum Item<'a> {
|
||||
pub struct Style {
|
||||
/// # heading (large text)
|
||||
pub heading: bool,
|
||||
|
||||
/// > quoted (slightly dimmer color or other font style)
|
||||
pub quoted: bool,
|
||||
|
||||
/// `code` (monospace, some other color)
|
||||
pub code: bool,
|
||||
|
||||
/// self.strong* (emphasized, e.g. bold)
|
||||
pub strong: bool,
|
||||
|
||||
/// _underline_
|
||||
pub underline: bool,
|
||||
|
||||
/// ~strikethrough~
|
||||
pub strikethrough: bool,
|
||||
|
||||
/// /italics/
|
||||
pub italics: bool,
|
||||
|
||||
/// $small$
|
||||
pub small: bool,
|
||||
|
||||
/// ^raised^
|
||||
pub raised: bool,
|
||||
}
|
||||
@@ -66,8 +82,10 @@ pub struct Style {
|
||||
pub struct Parser<'a> {
|
||||
/// The remainder of the input text
|
||||
s: &'a str,
|
||||
|
||||
/// Are we at the start of a line?
|
||||
start_of_line: bool,
|
||||
|
||||
/// Current self.style. Reset after a newline.
|
||||
style: Style,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user