mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 05:10:03 -04:00
Improve various documentation
This commit is contained in:
@@ -54,6 +54,8 @@ pub enum Shape {
|
||||
|
||||
/// ## Constructors
|
||||
impl Shape {
|
||||
/// A line between two points.
|
||||
/// More efficient than calling [`Self::line`].
|
||||
pub fn line_segment(points: [Pos2; 2], stroke: impl Into<Stroke>) -> Self {
|
||||
Self::LineSegment {
|
||||
points,
|
||||
@@ -61,6 +63,9 @@ impl Shape {
|
||||
}
|
||||
}
|
||||
|
||||
/// A line through many points.
|
||||
///
|
||||
/// Use [`Self::line_segment`] instead if your line only connect two points.
|
||||
pub fn line(points: Vec<Pos2>, stroke: impl Into<Stroke>) -> Self {
|
||||
Self::Path {
|
||||
points,
|
||||
@@ -70,6 +75,7 @@ impl Shape {
|
||||
}
|
||||
}
|
||||
|
||||
/// A line that closes back to the start point again.
|
||||
pub fn closed_line(points: Vec<Pos2>, stroke: impl Into<Stroke>) -> Self {
|
||||
Self::Path {
|
||||
points,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use super::*;
|
||||
|
||||
/// Describes the width and color of a line.
|
||||
///
|
||||
/// The default stroke is the same as [`Stroke::none`].
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct Stroke {
|
||||
@@ -9,6 +11,7 @@ pub struct Stroke {
|
||||
}
|
||||
|
||||
impl Stroke {
|
||||
/// Same as [`Stroke::default`].
|
||||
pub fn none() -> Self {
|
||||
Self::new(0.0, Color32::TRANSPARENT)
|
||||
}
|
||||
|
||||
@@ -341,20 +341,23 @@ impl Font {
|
||||
self.finalize_galley(galley)
|
||||
}
|
||||
|
||||
/// Always returns at least one row.
|
||||
/// Will line break at `\n`.
|
||||
///
|
||||
/// Always returns at least one row.
|
||||
pub fn layout_no_wrap(&self, text: String) -> Galley {
|
||||
self.layout_multiline(text, f32::INFINITY)
|
||||
}
|
||||
|
||||
/// Will wrap text at the given width and line break at `\n`.
|
||||
///
|
||||
/// Always returns at least one row.
|
||||
/// Will wrap text at the given width.
|
||||
pub fn layout_multiline(&self, text: String, max_width_in_points: f32) -> Galley {
|
||||
self.layout_multiline_with_indentation_and_max_width(text, 0.0, max_width_in_points)
|
||||
}
|
||||
|
||||
/// * `first_row_indentation`: extra space before the very first character (in points).
|
||||
/// * `max_width_in_points`: wrapping width.
|
||||
///
|
||||
/// Always returns at least one row.
|
||||
pub fn layout_multiline_with_indentation_and_max_width(
|
||||
&self,
|
||||
|
||||
@@ -315,8 +315,9 @@ impl Fonts {
|
||||
self.fonts[&text_style].row_height()
|
||||
}
|
||||
|
||||
/// Always returns at least one row.
|
||||
/// Will line break at `\n`.
|
||||
///
|
||||
/// Always returns at least one row.
|
||||
pub fn layout_no_wrap(&self, text_style: TextStyle, text: String) -> Arc<Galley> {
|
||||
self.layout_multiline(text_style, text, f32::INFINITY)
|
||||
}
|
||||
@@ -338,8 +339,9 @@ impl Fonts {
|
||||
)
|
||||
}
|
||||
|
||||
/// Will wrap text at the given width and line break at `\n`.
|
||||
///
|
||||
/// Always returns at least one row.
|
||||
/// Will wrap text at the given width.
|
||||
pub fn layout_multiline(
|
||||
&self,
|
||||
text_style: TextStyle,
|
||||
@@ -356,6 +358,7 @@ impl Fonts {
|
||||
|
||||
/// * `first_row_indentation`: extra space before the very first character (in points).
|
||||
/// * `max_width_in_points`: wrapping width.
|
||||
///
|
||||
/// Always returns at least one row.
|
||||
pub fn layout_multiline_with_indentation_and_max_width(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user