mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Rename egui::containers::menu::Bar to egui::MenuBar (#7327)
The old name is still there, just deprecated.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
//! See [`MenuBar`] for an example
|
||||
|
||||
use crate::style::StyleModifier;
|
||||
use crate::{
|
||||
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`],
|
||||
/// but can also be placed in a [`crate::Window`].
|
||||
/// 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)]
|
||||
pub struct Bar {
|
||||
pub struct MenuBar {
|
||||
config: MenuConfig,
|
||||
style: StyleModifier,
|
||||
}
|
||||
|
||||
impl Default for Bar {
|
||||
#[deprecated = "Renamed to `egui::MenuBar`"]
|
||||
pub type Bar = MenuBar;
|
||||
|
||||
impl Default for MenuBar {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
config: MenuConfig::default(),
|
||||
@@ -178,7 +196,7 @@ impl Default for Bar {
|
||||
}
|
||||
}
|
||||
|
||||
impl Bar {
|
||||
impl MenuBar {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
@@ -234,8 +252,8 @@ impl Bar {
|
||||
|
||||
/// 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`]).
|
||||
/// If your menu button is not in a [`Bar`] it's fine to use [`Ui::button`] and [`Popup::menu`]
|
||||
/// The only thing this does is search for the current menu config (if set via [`MenuBar`]).
|
||||
/// If your menu button is not in a [`MenuBar`] it's fine to use [`Ui::button`] and [`Popup::menu`]
|
||||
/// directly.
|
||||
pub struct MenuButton<'a> {
|
||||
pub button: Button<'a>,
|
||||
|
||||
@@ -481,7 +481,7 @@ pub mod text {
|
||||
|
||||
pub use self::{
|
||||
atomics::*,
|
||||
containers::*,
|
||||
containers::{menu::MenuBar, *},
|
||||
context::{Context, RepaintCause, RequestRepaintInfo},
|
||||
data::{
|
||||
Key, UserData,
|
||||
|
||||
@@ -87,7 +87,7 @@ fn set_menu_style(style: &mut Style) {
|
||||
/// The menu bar goes well in a [`crate::TopBottomPanel::top`],
|
||||
/// but can also be placed in a [`crate::Window`].
|
||||
/// 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> {
|
||||
ui.horizontal(|ui| {
|
||||
set_menu_style(ui.style_mut());
|
||||
|
||||
Reference in New Issue
Block a user