diff --git a/README.md b/README.md index 65c4678a6..301b9a32f 100644 --- a/README.md +++ b/README.md @@ -291,7 +291,7 @@ There is experimental support for a screen reader. In [the web demo](https://emi Read more at . -### What is the difference between egui and eframe? +### What is the difference between [egui](https://docs.rs/egui) and [eframe](https://docs.rs/eframe)? `egui` is a 2D user interface library for laying out and interacting with buttons, sliders, etc. `egui` has no idea if it is running on the web or natively, and does not know how to collect input or show things on screen. diff --git a/egui/src/containers/popup.rs b/egui/src/containers/popup.rs index ba424395d..4c11fe7d9 100644 --- a/egui/src/containers/popup.rs +++ b/egui/src/containers/popup.rs @@ -53,6 +53,20 @@ pub fn show_tooltip(ctx: &CtxRef, id: Id, add_contents: impl FnOnce(&mut Ui)) { show_tooltip_at_pointer(ctx, id, add_contents) } +/// Show a tooltip at the current pointer position (if any). +/// +/// Most of the time it is easier to use [`Response::on_hover_ui`]. +/// +/// See also [`show_tooltip_text`]. +/// +/// ``` +/// # let mut ui = egui::Ui::__test(); +/// if ui.ui_contains_pointer() { +/// egui::show_tooltip_at_pointer(ui.ctx(), egui::Id::new("my_tooltip"), |ui| { +/// ui.label("Helpful text"); +/// }); +/// } +/// ``` pub fn show_tooltip_at_pointer(ctx: &CtxRef, id: Id, add_contents: impl FnOnce(&mut Ui)) { let suggested_pos = ctx .input() diff --git a/egui/src/lib.rs b/egui/src/lib.rs index 17b6f021a..d5d90fe20 100644 --- a/egui/src/lib.rs +++ b/egui/src/lib.rs @@ -394,7 +394,10 @@ pub fn warn_if_debug_build(ui: &mut crate::Ui) { /// Create a [`Hyperlink`](crate::Hyperlink) to the current [`file!()`] (and line) on Github /// -/// Example: `ui.add(github_link_file_line!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)"));` +/// ``` +/// # let ui = &mut egui::Ui::__test(); +/// ui.add(egui::github_link_file_line!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)")); +/// ``` #[macro_export] macro_rules! github_link_file_line { ($github_url:expr, $label:expr) => {{ @@ -405,7 +408,10 @@ macro_rules! github_link_file_line { /// Create a [`Hyperlink`](crate::Hyperlink) to the current [`file!()`] on github. /// -/// Example: `ui.add(github_link_file!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)"));` +/// ``` +/// # let ui = &mut egui::Ui::__test(); +/// ui.add(egui::github_link_file!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)")); +/// ``` #[macro_export] macro_rules! github_link_file { ($github_url:expr, $label:expr) => {{ diff --git a/egui/src/painter.rs b/egui/src/painter.rs index 76fd4b6e6..f62e652c5 100644 --- a/egui/src/painter.rs +++ b/egui/src/painter.rs @@ -92,14 +92,15 @@ impl Painter { /// ## Accessors etc impl Painter { + /// Get a reference to the parent [`CtxRef`]. #[inline(always)] - pub(crate) fn ctx(&self) -> &CtxRef { + pub fn ctx(&self) -> &CtxRef { &self.ctx } - /// Available fonts + /// Available fonts. #[inline(always)] - pub(crate) fn fonts(&self) -> &Fonts { + pub fn fonts(&self) -> &Fonts { self.ctx.fonts() } @@ -123,19 +124,19 @@ impl Painter { self.clip_rect = clip_rect; } - /// Useful for pixel-perfect rendering + /// Useful for pixel-perfect rendering. #[inline(always)] pub fn round_to_pixel(&self, point: f32) -> f32 { self.ctx().round_to_pixel(point) } - /// Useful for pixel-perfect rendering + /// Useful for pixel-perfect rendering. #[inline(always)] pub fn round_vec_to_pixels(&self, vec: Vec2) -> Vec2 { self.ctx().round_vec_to_pixels(vec) } - /// Useful for pixel-perfect rendering + /// Useful for pixel-perfect rendering. #[inline(always)] pub fn round_pos_to_pixels(&self, pos: Pos2) -> Pos2 { self.ctx().round_pos_to_pixels(pos) diff --git a/egui/src/ui.rs b/egui/src/ui.rs index 8e9dbcfb4..ff7e88658 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -698,9 +698,9 @@ impl Ui { widget_rect } - /// Allocate a specific part of the `Ui‘. + /// Allocate a specific part of the `Ui`. /// - /// Ignore the layout of the `Ui‘: just put my widget here! + /// Ignore the layout of the `Ui`: just put my widget here! /// The layout cursor will advance to past this `rect`. pub fn allocate_rect(&mut self, rect: Rect, sense: Sense) -> Response { let id = self.advance_cursor_after_rect(rect); diff --git a/egui_demo_lib/src/apps/demo/widget_gallery.rs b/egui_demo_lib/src/apps/demo/widget_gallery.rs index 8d4f1beaa..e19b6bc4f 100644 --- a/egui_demo_lib/src/apps/demo/widget_gallery.rs +++ b/egui_demo_lib/src/apps/demo/widget_gallery.rs @@ -6,6 +6,7 @@ enum Enum { Third, } +/// Shows off one example of each major type of widget. #[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))] pub struct WidgetGallery { enabled: bool, @@ -141,7 +142,7 @@ impl WidgetGallery { }); ui.end_row(); - ui.add(doc_link_label("Combo box", "combo_box")); + ui.add(doc_link_label("Combo box", "ComboBox")); egui::ComboBox::from_label("Take your pick") .selected_text(format!("{:?}", radio)) diff --git a/epi/src/lib.rs b/epi/src/lib.rs index 82231215a..a63fbace3 100644 --- a/epi/src/lib.rs +++ b/epi/src/lib.rs @@ -96,8 +96,8 @@ pub trait App { /// Called once before the first frame. /// - /// Allows you to do setup code, e.g to call `[Context::set_fonts]`, - /// `[Context::set_visuals]` etc. + /// Allows you to do setup code, e.g to call `[egui::Context::set_fonts]`, + /// `[egui::Context::set_visuals]` etc. /// /// Also allows you to restore state, if there is a storage. fn setup( @@ -127,7 +127,7 @@ pub trait App { /// where `APPNAME` is what is returned by [`Self::name()`]. fn save(&mut self, _storage: &mut dyn Storage) {} - /// Called once on shutdown (before or after `save()`) + /// Called once on shutdown (before or after [`Self::save`]) fn on_exit(&mut self) {} // --------- @@ -136,12 +136,12 @@ pub trait App { /// The name of your App. fn name(&self) -> &str; - /// Time between automatic calls to `save()` + /// Time between automatic calls to [`Self::save`] fn auto_save_interval(&self) -> std::time::Duration { std::time::Duration::from_secs(30) } - /// The size limit of the web app canvas + /// The size limit of the web app canvas. fn max_size_points(&self) -> egui::Vec2 { // Some browsers get slow with huge WebGL canvases, so we limit the size: egui::Vec2::new(1024.0, 2048.0) @@ -254,6 +254,8 @@ impl<'a> Frame<'a> { /// Very simple Http fetch API. /// Calls the given callback when done. + /// + /// You must enable the "http" feature for this. #[cfg(feature = "http")] pub fn http_fetch( &self, @@ -370,6 +372,8 @@ pub const APP_KEY: &str = "app"; #[cfg(feature = "http")] /// `epi` supports simple HTTP requests with [`Frame::http_fetch`]. +/// +/// You must enable the "http" feature for this. pub mod http { /// A simple http requests. pub struct Request {