Small tweaks to documentation and demo

This commit is contained in:
Emil Ernerfeldt 2021-12-29 10:48:38 +01:00
parent d0a47bf8e8
commit 84399cde83
4 changed files with 13 additions and 7 deletions

View file

@ -437,13 +437,12 @@ impl Response {
/// Move the scroll to this UI with the specified alignment. /// Move the scroll to this UI with the specified alignment.
/// ///
/// ``` /// ```
/// # use egui::Align;
/// # egui::__run_test_ui(|ui| { /// # egui::__run_test_ui(|ui| {
/// egui::ScrollArea::vertical().show(ui, |ui| { /// egui::ScrollArea::vertical().show(ui, |ui| {
/// for i in 0..1000 { /// for i in 0..1000 {
/// let response = ui.button(format!("Button {}", i)); /// let response = ui.button("Scroll to me");
/// if response.clicked() { /// if response.clicked() {
/// response.scroll_to_me(Align::Center); /// response.scroll_to_me(egui::Align::Center);
/// } /// }
/// } /// }
/// }); /// });
@ -490,6 +489,8 @@ impl Response {
/// }); /// });
/// # }); /// # });
/// ``` /// ```
///
/// See also: [`Ui::menu_button`] and [`Ui::close_menu`].
pub fn context_menu(self, add_contents: impl FnOnce(&mut Ui)) -> Self { pub fn context_menu(self, add_contents: impl FnOnce(&mut Ui)) -> Self {
self.ctx self.ctx
.context_menu_system() .context_menu_system()

View file

@ -1763,7 +1763,9 @@ impl Ui {
result result
} }
/// Close menu (with submenus), if any. /// Close the menu we are in (including submenus), if any.
///
/// See also: [`Self::menu_button`] and [`Response::context_menu`].
pub fn close_menu(&mut self) { pub fn close_menu(&mut self) {
if let Some(menu_state) = &mut self.menu_state { if let Some(menu_state) = &mut self.menu_state {
menu_state.write().close(); menu_state.write().close();
@ -1780,7 +1782,9 @@ impl Ui {
} }
#[inline] #[inline]
/// Create a menu button. Creates a button for a sub-menu when the `Ui` is inside a menu. /// Create a menu button that when clicked will show the given menu.
///
/// If called from within a menu this will instead create a button for a sub-menu.
/// ///
/// ``` /// ```
/// # egui::__run_test_ui(|ui| { /// # egui::__run_test_ui(|ui| {
@ -1793,6 +1797,8 @@ impl Ui {
/// }); /// });
/// # }); /// # });
/// ``` /// ```
///
/// See also: [`Self::close_menu`] and [`Response::context_menu`].
pub fn menu_button<R>( pub fn menu_button<R>(
&mut self, &mut self,
title: impl Into<WidgetText>, title: impl Into<WidgetText>,

View file

@ -153,7 +153,7 @@ impl DemoWindows {
egui::SidePanel::right("egui_demo_panel") egui::SidePanel::right("egui_demo_panel")
.min_width(150.0) .min_width(150.0)
.default_width(190.0) .default_width(180.0)
.show(ctx, |ui| { .show(ctx, |ui| {
egui::trace!(ui); egui::trace!(ui);
ui.vertical_centered(|ui| { ui.vertical_centered(|ui| {

View file

@ -153,7 +153,6 @@ impl BackendPanel {
ui.label( ui.label(
"Everything you see is rendered as textured triangles. There is no DOM and no HTML elements. \ "Everything you see is rendered as textured triangles. There is no DOM and no HTML elements. \
This is the web page, reinvented with game tech."); This is the web page, reinvented with game tech.");
ui.label("This is also work in progress, and not ready for production… yet :)");
ui.hyperlink("https://github.com/emilk/egui"); ui.hyperlink("https://github.com/emilk/egui");
ui.separator(); ui.separator();