From 53ab2f4ef6a3b9acbc93d139fb82617839b55f72 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 27 Dec 2020 14:16:37 +0100 Subject: [PATCH] Improve documentation --- egui/src/containers/collapsing_header.rs | 5 ++-- egui/src/containers/combo_box.rs | 31 ++++++++++++++++++++++ egui/src/containers/frame.rs | 2 +- egui/src/containers/popup.rs | 26 ++++++++++++++++++- egui/src/containers/scroll_area.rs | 4 +-- egui/src/paint/command.rs | 2 ++ egui/src/paint/fonts.rs | 33 ++++++++++++++++++++---- egui/src/paint/tessellator.rs | 14 +++++----- egui/src/widgets/color_picker.rs | 2 ++ egui/src/widgets/mod.rs | 4 +-- 10 files changed, 103 insertions(+), 20 deletions(-) diff --git a/egui/src/containers/collapsing_header.rs b/egui/src/containers/collapsing_header.rs index e8effc5e..e8ccaf57 100644 --- a/egui/src/containers/collapsing_header.rs +++ b/egui/src/containers/collapsing_header.rs @@ -101,7 +101,7 @@ impl State { } /// Paint the arrow icon that indicated if the region is open or not -pub fn paint_icon(ui: &mut Ui, openness: f32, response: &Response) { +pub(crate) fn paint_icon(ui: &mut Ui, openness: f32, response: &Response) { let stroke = ui.style().interact(response).fg_stroke; let rect = response.rect; @@ -118,7 +118,7 @@ pub fn paint_icon(ui: &mut Ui, openness: f32, response: &Response) { ui.painter().add(PaintCmd::closed_line(points, stroke)); } -/// A header which can be collapsed/expanded, revealing a contained `Ui` region. +/// A header which can be collapsed/expanded, revealing a contained [`Ui`] region. pub struct CollapsingHeader { label: Label, default_open: bool, @@ -269,6 +269,7 @@ impl CollapsingHeader { } } +/// The response from showing a [`CollapsingHeader`]. pub struct CollapsingResponse { pub header_response: Response, /// None iff collapsed. diff --git a/egui/src/containers/combo_box.rs b/egui/src/containers/combo_box.rs index 5ea44b26..49a11843 100644 --- a/egui/src/containers/combo_box.rs +++ b/egui/src/containers/combo_box.rs @@ -1,5 +1,20 @@ use crate::{paint::PaintCmd, style::WidgetVisuals, *}; +/// A drop-down selection menu with a descriptive label. +/// +/// See also [`combo_box`]. +/// +/// ``` +/// # #[derive(Debug, PartialEq)] +/// # enum Enum { First, Second, Third } +/// # let mut selected = Enum::First; +/// # let mut ui = &mut egui::Ui::__test(); +/// egui::combo_box_with_label(ui, "Select one!", format!("{:?}", selected), |ui| { +/// ui.selectable_value(&mut selected, Enum::First, "First"); +/// ui.selectable_value(&mut selected, Enum::Second, "Second"); +/// ui.selectable_value(&mut selected, Enum::Third, "Third"); +/// }); +/// ``` pub fn combo_box_with_label( ui: &mut Ui, label: impl Into