Rename `egui::containers::menu::Bar` to `egui::MenuBar` (#7327)
The old name is still there, just deprecated.
This commit is contained in:
parent
8d2f39fc08
commit
9478a6223b
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! See [`MenuBar`] for an example
|
||||||
|
|
||||||
use crate::style::StyleModifier;
|
use crate::style::StyleModifier;
|
||||||
use crate::{
|
use crate::{
|
||||||
Button, Color32, Context, Frame, Id, InnerResponse, IntoAtoms, Layout, Popup,
|
Button, Color32, Context, Frame, Id, InnerResponse, IntoAtoms, Layout, Popup,
|
||||||
|
|
@ -163,13 +165,29 @@ impl MenuState {
|
||||||
/// The menu bar goes well in a [`crate::TopBottomPanel::top`],
|
/// The menu bar goes well in a [`crate::TopBottomPanel::top`],
|
||||||
/// but can also be placed in a [`crate::Window`].
|
/// but can also be placed in a [`crate::Window`].
|
||||||
/// In the latter case you may want to wrap it in [`Frame`].
|
/// In the latter case you may want to wrap it in [`Frame`].
|
||||||
|
///
|
||||||
|
/// ### Example:
|
||||||
|
/// ```
|
||||||
|
/// # egui::__run_test_ui(|ui| {
|
||||||
|
/// egui::MenuBar::new().ui(ui, |ui| {
|
||||||
|
/// ui.menu_button("File", |ui| {
|
||||||
|
/// if ui.button("Quit").clicked() {
|
||||||
|
/// ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
|
||||||
|
/// }
|
||||||
|
/// });
|
||||||
|
/// });
|
||||||
|
/// # });
|
||||||
|
/// ```
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Bar {
|
pub struct MenuBar {
|
||||||
config: MenuConfig,
|
config: MenuConfig,
|
||||||
style: StyleModifier,
|
style: StyleModifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Bar {
|
#[deprecated = "Renamed to `egui::MenuBar`"]
|
||||||
|
pub type Bar = MenuBar;
|
||||||
|
|
||||||
|
impl Default for MenuBar {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
config: MenuConfig::default(),
|
config: MenuConfig::default(),
|
||||||
|
|
@ -178,7 +196,7 @@ impl Default for Bar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bar {
|
impl MenuBar {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
@ -234,8 +252,8 @@ impl Bar {
|
||||||
|
|
||||||
/// A thin wrapper around a [`Button`] that shows a [`Popup::menu`] when clicked.
|
/// A thin wrapper around a [`Button`] that shows a [`Popup::menu`] when clicked.
|
||||||
///
|
///
|
||||||
/// The only thing this does is search for the current menu config (if set via [`Bar`]).
|
/// The only thing this does is search for the current menu config (if set via [`MenuBar`]).
|
||||||
/// If your menu button is not in a [`Bar`] it's fine to use [`Ui::button`] and [`Popup::menu`]
|
/// If your menu button is not in a [`MenuBar`] it's fine to use [`Ui::button`] and [`Popup::menu`]
|
||||||
/// directly.
|
/// directly.
|
||||||
pub struct MenuButton<'a> {
|
pub struct MenuButton<'a> {
|
||||||
pub button: Button<'a>,
|
pub button: Button<'a>,
|
||||||
|
|
|
||||||
|
|
@ -481,7 +481,7 @@ pub mod text {
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
atomics::*,
|
atomics::*,
|
||||||
containers::*,
|
containers::{menu::MenuBar, *},
|
||||||
context::{Context, RepaintCause, RequestRepaintInfo},
|
context::{Context, RepaintCause, RequestRepaintInfo},
|
||||||
data::{
|
data::{
|
||||||
Key, UserData,
|
Key, UserData,
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ fn set_menu_style(style: &mut Style) {
|
||||||
/// The menu bar goes well in a [`crate::TopBottomPanel::top`],
|
/// The menu bar goes well in a [`crate::TopBottomPanel::top`],
|
||||||
/// but can also be placed in a [`crate::Window`].
|
/// but can also be placed in a [`crate::Window`].
|
||||||
/// In the latter case you may want to wrap it in [`Frame`].
|
/// In the latter case you may want to wrap it in [`Frame`].
|
||||||
#[deprecated = "Use `crate::containers::menu::Bar` instead"]
|
#[deprecated = "Use `egui::MenuBar::new().ui(` instead"]
|
||||||
pub fn bar<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
|
pub fn bar<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
set_menu_style(ui.style_mut());
|
set_menu_style(ui.style_mut());
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ impl DemoWindows {
|
||||||
|
|
||||||
fn mobile_top_bar(&mut self, ctx: &Context) {
|
fn mobile_top_bar(&mut self, ctx: &Context) {
|
||||||
egui::TopBottomPanel::top("menu_bar").show(ctx, |ui| {
|
egui::TopBottomPanel::top("menu_bar").show(ctx, |ui| {
|
||||||
menu::Bar::new()
|
menu::MenuBar::new()
|
||||||
.config(menu::MenuConfig::new().style(StyleModifier::default()))
|
.config(menu::MenuConfig::new().style(StyleModifier::default()))
|
||||||
.ui(ui, |ui| {
|
.ui(ui, |ui| {
|
||||||
let font_size = 16.5;
|
let font_size = 16.5;
|
||||||
|
|
@ -290,7 +290,7 @@ impl DemoWindows {
|
||||||
});
|
});
|
||||||
|
|
||||||
egui::TopBottomPanel::top("menu_bar").show(ctx, |ui| {
|
egui::TopBottomPanel::top("menu_bar").show(ctx, |ui| {
|
||||||
menu::Bar::new().ui(ui, |ui| {
|
menu::MenuBar::new().ui(ui, |ui| {
|
||||||
file_menu_button(ui);
|
file_menu_button(ui);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use egui::containers::menu::{Bar, MenuConfig, SubMenuButton};
|
use egui::containers::menu::{MenuBar, MenuConfig, SubMenuButton};
|
||||||
use egui::{PopupCloseBehavior, Ui, include_image};
|
use egui::{PopupCloseBehavior, Ui, include_image};
|
||||||
use egui_kittest::{Harness, SnapshotResults};
|
use egui_kittest::{Harness, SnapshotResults};
|
||||||
use kittest::Queryable as _;
|
use kittest::Queryable as _;
|
||||||
|
|
@ -18,7 +18,7 @@ impl TestMenu {
|
||||||
|
|
||||||
fn ui(&mut self, ui: &mut Ui) {
|
fn ui(&mut self, ui: &mut Ui) {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
Bar::new().config(self.config.clone()).ui(ui, |ui| {
|
MenuBar::new().config(self.config.clone()).ui(ui, |ui| {
|
||||||
egui::Sides::new().show(
|
egui::Sides::new().show(
|
||||||
ui,
|
ui,
|
||||||
|ui| {
|
|ui| {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue