mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Add back old deprecated panels
This commit is contained in:
@@ -161,15 +161,14 @@ impl MenuState {
|
||||
if state.last_visible_pass + 1 < pass_nr {
|
||||
state.open_item = None;
|
||||
}
|
||||
if let Some(item) = state.open_item {
|
||||
if data
|
||||
if let Some(item) = state.open_item
|
||||
&& data
|
||||
.get_temp(item.with(Self::ID))
|
||||
.is_none_or(|item: Self| item.last_visible_pass + 1 < pass_nr)
|
||||
{
|
||||
// If the open item wasn't shown for at least a frame, reset the open item
|
||||
state.open_item = None;
|
||||
}
|
||||
}
|
||||
let r = f(&mut state);
|
||||
data.insert_temp(state_id, state);
|
||||
r
|
||||
|
||||
@@ -27,7 +27,7 @@ pub use {
|
||||
frame::Frame,
|
||||
modal::{Modal, ModalResponse},
|
||||
old_popup::*,
|
||||
panel::{CentralPanel, HorizontalSide, Panel, PanelSide, VerticalSide},
|
||||
panel::*,
|
||||
popup::*,
|
||||
resize::Resize,
|
||||
scene::{DragPanButtons, Scene},
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
use emath::{GuiRounding as _, Pos2};
|
||||
|
||||
use crate::{
|
||||
lerp, vec2, Align, Context, CursorIcon, Frame, Id, InnerResponse, LayerId, Layout, NumExt,
|
||||
Rangef, Rect, Sense, Stroke, Ui, UiBuilder, UiKind, UiStackInfo, Vec2,
|
||||
Align, Context, CursorIcon, Frame, Id, InnerResponse, LayerId, Layout, NumExt as _, Rangef,
|
||||
Rect, Sense, Stroke, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, lerp, vec2,
|
||||
};
|
||||
|
||||
fn animate_expansion(ctx: &Context, id: Id, is_expanded: bool) -> f32 {
|
||||
@@ -73,23 +73,23 @@ pub enum PanelSide {
|
||||
|
||||
impl PanelSide {
|
||||
fn opposite(self) -> Self {
|
||||
let opposite_vertical = |side: VerticalSide| -> PanelSide {
|
||||
let opposite_vertical = |side: VerticalSide| -> Self {
|
||||
match side {
|
||||
VerticalSide::Left => PanelSide::Vertical(VerticalSide::Right),
|
||||
VerticalSide::Right => PanelSide::Vertical(VerticalSide::Left),
|
||||
VerticalSide::Left => Self::Vertical(VerticalSide::Right),
|
||||
VerticalSide::Right => Self::Vertical(VerticalSide::Left),
|
||||
}
|
||||
};
|
||||
|
||||
let opposite_horizontal = |side: HorizontalSide| -> PanelSide {
|
||||
let opposite_horizontal = |side: HorizontalSide| -> Self {
|
||||
match side {
|
||||
HorizontalSide::Top => PanelSide::Horizontal(HorizontalSide::Bottom),
|
||||
HorizontalSide::Bottom => PanelSide::Horizontal(HorizontalSide::Top),
|
||||
HorizontalSide::Top => Self::Horizontal(HorizontalSide::Bottom),
|
||||
HorizontalSide::Bottom => Self::Horizontal(HorizontalSide::Top),
|
||||
}
|
||||
};
|
||||
|
||||
match self {
|
||||
PanelSide::Vertical(side) => opposite_vertical(side),
|
||||
PanelSide::Horizontal(side) => opposite_horizontal(side),
|
||||
Self::Vertical(side) => opposite_vertical(side),
|
||||
Self::Horizontal(side) => opposite_horizontal(side),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ impl PanelSide {
|
||||
};
|
||||
|
||||
match self {
|
||||
PanelSide::Vertical(side) => set_rect_size_vertical(side),
|
||||
PanelSide::Horizontal(side) => set_rect_size_horizontal(side),
|
||||
Self::Vertical(side) => set_rect_size_vertical(side),
|
||||
Self::Horizontal(side) => set_rect_size_horizontal(side),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ impl PanelSide {
|
||||
};
|
||||
|
||||
match self {
|
||||
PanelSide::Vertical(side) => side_axe_vertical(side, rect),
|
||||
PanelSide::Horizontal(side) => side_axe_horizontal(side, rect),
|
||||
Self::Vertical(side) => side_axe_vertical(side, rect),
|
||||
Self::Horizontal(side) => side_axe_horizontal(side, rect),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,8 +147,8 @@ impl PanelSide {
|
||||
};
|
||||
|
||||
match self {
|
||||
PanelSide::Vertical(side) => sign_vertical(side),
|
||||
PanelSide::Horizontal(side) => sign_horizontal(side),
|
||||
Self::Vertical(side) => sign_vertical(side),
|
||||
Self::Horizontal(side) => sign_horizontal(side),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -619,7 +619,7 @@ impl Panel {
|
||||
HorizontalSide::Top => cursor.min.y = rect.max.y,
|
||||
HorizontalSide::Bottom => cursor.max.y = rect.min.y,
|
||||
},
|
||||
};
|
||||
}
|
||||
ui.set_cursor(cursor);
|
||||
}
|
||||
|
||||
@@ -846,7 +846,7 @@ impl Panel {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_animated_size(ctx: &Context, panel: &Panel) -> f32 {
|
||||
fn get_animated_size(ctx: &Context, panel: &Self) -> f32 {
|
||||
let get_rect_state_size = |state: PanelState| match panel.side {
|
||||
PanelSide::Vertical(_) => state.rect.width(),
|
||||
PanelSide::Horizontal(_) => state.rect.height(),
|
||||
@@ -976,3 +976,38 @@ fn clamp_to_range(x: f32, range: Rangef) -> f32 {
|
||||
let range = range.as_positive();
|
||||
x.clamp(range.min, range.max)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
mod legacy {
|
||||
#![expect(deprecated)]
|
||||
|
||||
use super::{Id, Panel};
|
||||
|
||||
#[deprecated = "Use Panel::left or Panel::right instead"]
|
||||
pub struct SidePanel {}
|
||||
|
||||
impl SidePanel {
|
||||
pub fn left(id: impl Into<Id>) -> Panel {
|
||||
Panel::left(id)
|
||||
}
|
||||
pub fn right(id: impl Into<Id>) -> Panel {
|
||||
Panel::right(id)
|
||||
}
|
||||
}
|
||||
|
||||
#[deprecated = "Use Panel::top or Panel::bottom instead"]
|
||||
pub struct TopBottomPanel {}
|
||||
|
||||
impl TopBottomPanel {
|
||||
pub fn top(id: impl Into<Id>) -> Panel {
|
||||
Panel::top(id)
|
||||
}
|
||||
pub fn bottom(id: impl Into<Id>) -> Panel {
|
||||
Panel::bottom(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(deprecated)]
|
||||
pub use legacy::{SidePanel, TopBottomPanel};
|
||||
|
||||
@@ -1271,9 +1271,7 @@ impl Areas {
|
||||
|
||||
pub fn top_layer_id(&self, order: Order) -> Option<LayerId> {
|
||||
self.order
|
||||
.iter()
|
||||
.filter(|layer| layer.order == order && !self.is_sublayer(layer))
|
||||
.next_back()
|
||||
.iter().rfind(|layer| layer.order == order && !self.is_sublayer(layer))
|
||||
.copied()
|
||||
}
|
||||
|
||||
|
||||
@@ -634,7 +634,7 @@ impl SubMenu {
|
||||
/// Usually you don't need to use it directly.
|
||||
pub struct MenuState {
|
||||
/// The opened sub-menu and its [`Id`]
|
||||
sub_menu: Option<(Id, Arc<RwLock<MenuState>>)>,
|
||||
sub_menu: Option<(Id, Arc<RwLock<Self>>)>,
|
||||
|
||||
/// Bounding box of this menu (without the sub-menu),
|
||||
/// including the frame and everything.
|
||||
|
||||
@@ -209,7 +209,7 @@ pub struct UiStack {
|
||||
pub layout_direction: Direction,
|
||||
pub min_rect: Rect,
|
||||
pub max_rect: Rect,
|
||||
pub parent: Option<Arc<UiStack>>,
|
||||
pub parent: Option<Arc<Self>>,
|
||||
}
|
||||
|
||||
// these methods act on this specific node
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
use std::mem;
|
||||
|
||||
use accesskit::{Action, ActionRequest, NodeId};
|
||||
use accesskit_consumer::{FilterResult, Node, Tree, TreeChangeHandler};
|
||||
|
||||
use eframe::epaint::text::TextWrapMode;
|
||||
use egui::collapsing_header::CollapsingState;
|
||||
use egui::{
|
||||
Button, Color32, Context, Event, Frame, FullOutput, Id, Key, KeyboardShortcut, Label,
|
||||
Modifiers, RawInput, RichText, ScrollArea, SidePanel, TopBottomPanel, Ui,
|
||||
Modifiers, Panel, RawInput, RichText, ScrollArea, Ui, collapsing_header::CollapsingState,
|
||||
};
|
||||
use std::mem;
|
||||
|
||||
/// This [`egui::Plugin`] adds an inspector Panel.
|
||||
///
|
||||
@@ -86,10 +87,10 @@ impl egui::Plugin for AccessibilityInspectorPlugin {
|
||||
|
||||
ctx.enable_accesskit();
|
||||
|
||||
SidePanel::right(Self::id()).show(ctx, |ui| {
|
||||
Panel::right(Self::id()).show(ctx, |ui| {
|
||||
ui.heading("🔎 AccessKit Inspector");
|
||||
if let Some(selected_node) = self.selected_node {
|
||||
TopBottomPanel::bottom(Self::id().with("details_panel"))
|
||||
Panel::bottom(Self::id().with("details_panel"))
|
||||
.frame(Frame::new())
|
||||
.show_separator_line(false)
|
||||
.show_inside(ui, |ui| {
|
||||
|
||||
@@ -2,8 +2,6 @@ use egui::ImageFit;
|
||||
use egui::Slider;
|
||||
use egui::Vec2;
|
||||
use egui::emath::Rot2;
|
||||
use egui::panel::Side;
|
||||
use egui::panel::TopBottomSide;
|
||||
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct ImageViewer {
|
||||
@@ -52,7 +50,7 @@ impl Default for ImageViewer {
|
||||
|
||||
impl eframe::App for ImageViewer {
|
||||
fn update(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
|
||||
egui::TopBottomPanel::new(TopBottomSide::Top, "url bar").show(ctx, |ui| {
|
||||
egui::Panel::top("url bar").show(ctx, |ui| {
|
||||
ui.horizontal_centered(|ui| {
|
||||
let label = ui.label("URI:");
|
||||
ui.text_edit_singleline(&mut self.uri_edit_text)
|
||||
@@ -73,7 +71,7 @@ impl eframe::App for ImageViewer {
|
||||
});
|
||||
});
|
||||
|
||||
egui::SidePanel::new(Side::Left, "controls").show(ctx, |ui| {
|
||||
egui::Panel::left("controls").show(ctx, |ui| {
|
||||
// uv
|
||||
ui.label("UV");
|
||||
ui.add(Slider::new(&mut self.image_options.uv.min.x, 0.0..=1.0).text("min x"));
|
||||
|
||||
@@ -236,7 +236,7 @@ impl DemoWindows {
|
||||
}
|
||||
|
||||
fn mobile_top_bar(&mut self, ctx: &Context) {
|
||||
egui::TopBottomPanel::top("menu_bar").show(ctx, |ui| {
|
||||
egui::Panel::top("menu_bar").show(ctx, |ui| {
|
||||
menu::MenuBar::new()
|
||||
.config(menu::MenuConfig::new().style(StyleModifier::default()))
|
||||
.ui(ui, |ui| {
|
||||
@@ -262,10 +262,10 @@ impl DemoWindows {
|
||||
}
|
||||
|
||||
fn desktop_ui(&mut self, ctx: &Context) {
|
||||
egui::SidePanel::right("egui_demo_panel")
|
||||
egui::Panel::right("egui_demo_panel")
|
||||
.resizable(false)
|
||||
.default_width(160.0)
|
||||
.min_width(160.0)
|
||||
.default_size(160.0)
|
||||
.min_size(160.0)
|
||||
.show(ctx, |ui| {
|
||||
ui.add_space(4.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
@@ -289,7 +289,7 @@ impl DemoWindows {
|
||||
self.demo_list_ui(ui);
|
||||
});
|
||||
|
||||
egui::TopBottomPanel::top("menu_bar").show(ctx, |ui| {
|
||||
egui::Panel::top("menu_bar").show(ctx, |ui| {
|
||||
menu::MenuBar::new().ui(ui, |ui| {
|
||||
file_menu_button(ui);
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ pub enum Shape {
|
||||
|
||||
/// Recursively nest more shapes - sometimes a convenience to be able to do.
|
||||
/// For performance reasons it is better to avoid it.
|
||||
Vec(Vec<Shape>),
|
||||
Vec(Vec<Self>),
|
||||
|
||||
/// Circle with optional outline and fill.
|
||||
Circle(CircleShape),
|
||||
|
||||
@@ -41,7 +41,7 @@ impl eframe::App for MyApp {
|
||||
// TODO(lucasmerlin): This is a pretty big hack, should be fixed once safe_area implemented
|
||||
// for android:
|
||||
// https://github.com/rust-windowing/winit/issues/3910
|
||||
egui::TopBottomPanel::top("status_bar_space").show(ctx, |ui| {
|
||||
egui::Panel::top("status_bar_space").show(ctx, |ui| {
|
||||
ui.set_height(32.0);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user