mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 22:30:03 -04:00
Remove everything that was marked #[deprecated] (#8105)
Simplify. Streamline. Spring cleaning.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
use egui::Frame;
|
||||
|
||||
type AppKindContextState<'a, State> = Box<dyn FnMut(&egui::Context, &mut State) + 'a>;
|
||||
type AppKindUiState<'a, State> = Box<dyn FnMut(&mut egui::Ui, &mut State) + 'a>;
|
||||
type AppKindContext<'a> = Box<dyn FnMut(&egui::Context) + 'a>;
|
||||
type AppKindUi<'a> = Box<dyn FnMut(&mut egui::Ui) + 'a>;
|
||||
|
||||
/// In order to access the [`eframe::App`] trait from the generic `State`, we store a function pointer
|
||||
@@ -13,9 +11,7 @@ type AppKindUi<'a> = Box<dyn FnMut(&mut egui::Ui) + 'a>;
|
||||
type AppKindEframe<'a, State> = (fn(&mut State) -> &mut dyn eframe::App, eframe::Frame);
|
||||
|
||||
pub(crate) enum AppKind<'a, State> {
|
||||
Context(AppKindContext<'a>),
|
||||
Ui(AppKindUi<'a>),
|
||||
ContextState(AppKindContextState<'a, State>),
|
||||
UiState(AppKindUiState<'a, State>),
|
||||
#[cfg(feature = "eframe")]
|
||||
Eframe(AppKindEframe<'a, State>),
|
||||
@@ -29,25 +25,12 @@ impl<State> AppKind<'_, State> {
|
||||
sizing_pass: bool,
|
||||
) -> Option<egui::Response> {
|
||||
match self {
|
||||
AppKind::Context(f) => {
|
||||
debug_assert!(!sizing_pass, "Context closures cannot do a sizing pass");
|
||||
f(ui);
|
||||
None
|
||||
}
|
||||
AppKind::ContextState(f) => {
|
||||
debug_assert!(!sizing_pass, "Context closures cannot do a sizing pass");
|
||||
f(ui, state);
|
||||
None
|
||||
}
|
||||
#[cfg(feature = "eframe")]
|
||||
AppKind::Eframe((get_app, frame)) => {
|
||||
let app = get_app(state);
|
||||
|
||||
app.logic(ui, frame);
|
||||
|
||||
#[expect(deprecated)]
|
||||
app.update(ui, frame);
|
||||
|
||||
app.ui(ui, frame);
|
||||
|
||||
None
|
||||
@@ -74,8 +57,9 @@ impl<State> AppKind<'_, State> {
|
||||
.show(ui, |ui| match self {
|
||||
AppKind::Ui(f) => f(ui),
|
||||
AppKind::UiState(f) => f(ui, state),
|
||||
_ => unreachable!(
|
||||
"run_ui should only be called with AppKind::Ui or AppKind UiState"
|
||||
#[cfg(feature = "eframe")]
|
||||
AppKind::Eframe(_) => unreachable!(
|
||||
"run_ui should only be called with AppKind::Ui or AppKind::UiState"
|
||||
),
|
||||
});
|
||||
})
|
||||
|
||||
@@ -159,46 +159,10 @@ impl<State> HarnessBuilder<State> {
|
||||
self.renderer(crate::wgpu::WgpuTestRenderer::from_setup(setup))
|
||||
}
|
||||
|
||||
/// Create a new Harness with the given app closure and a state.
|
||||
///
|
||||
/// The app closure will immediately be called once to create the initial ui.
|
||||
///
|
||||
/// If you don't need to create Windows / Panels, you can use [`HarnessBuilder::build_ui`] instead.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// # use egui::CentralPanel;
|
||||
/// # use egui_kittest::{Harness, kittest::Queryable};
|
||||
/// let checked = false;
|
||||
/// let mut harness = Harness::builder()
|
||||
/// .with_size(egui::Vec2::new(300.0, 200.0))
|
||||
/// .build_state(|ctx, checked| {
|
||||
/// CentralPanel::default().show(ctx, |ui| {
|
||||
/// ui.checkbox(checked, "Check me!");
|
||||
/// });
|
||||
/// }, checked);
|
||||
///
|
||||
/// harness.get_by_label("Check me!").click();
|
||||
/// harness.run();
|
||||
///
|
||||
/// assert_eq!(*harness.state(), true);
|
||||
/// ```
|
||||
#[track_caller]
|
||||
#[deprecated = "use `build_ui_state` instead"]
|
||||
pub fn build_state<'a>(
|
||||
self,
|
||||
app: impl FnMut(&egui::Context, &mut State) + 'a,
|
||||
state: State,
|
||||
) -> Harness<'a, State> {
|
||||
Harness::from_builder(self, AppKind::ContextState(Box::new(app)), state, None)
|
||||
}
|
||||
|
||||
/// Create a new Harness with the given ui closure and a state.
|
||||
///
|
||||
/// The ui closure will immediately be called once to create the initial ui.
|
||||
///
|
||||
/// If you need to create Windows / Panels, you can use [`HarnessBuilder::build`] instead.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// # use egui_kittest::{Harness, kittest::Queryable};
|
||||
@@ -249,37 +213,10 @@ impl<State> HarnessBuilder<State> {
|
||||
}
|
||||
|
||||
impl HarnessBuilder {
|
||||
/// Create a new Harness with the given app closure.
|
||||
///
|
||||
/// The app closure will immediately be called once to create the initial ui.
|
||||
///
|
||||
/// If you don't need to create Windows / Panels, you can use [`HarnessBuilder::build_ui`] instead.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// # use egui::CentralPanel;
|
||||
/// # use egui_kittest::{Harness, kittest::Queryable};
|
||||
/// let mut harness = Harness::builder()
|
||||
/// .with_size(egui::Vec2::new(300.0, 200.0))
|
||||
/// .build(|ctx| {
|
||||
/// CentralPanel::default().show(ctx, |ui| {
|
||||
/// ui.label("Hello, world!");
|
||||
/// });
|
||||
/// });
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[track_caller]
|
||||
#[deprecated = "use `build_ui` instead"]
|
||||
pub fn build<'a>(self, app: impl FnMut(&egui::Context) + 'a) -> Harness<'a> {
|
||||
Harness::from_builder(self, AppKind::Context(Box::new(app)), (), None)
|
||||
}
|
||||
|
||||
/// Create a new Harness with the given ui closure.
|
||||
///
|
||||
/// The ui closure will immediately be called once to create the initial ui.
|
||||
///
|
||||
/// If you need to create Windows / Panels, you can use [`HarnessBuilder::build`] instead.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// # use egui_kittest::{Harness, kittest::Queryable};
|
||||
|
||||
@@ -60,7 +60,7 @@ impl Display for ExceededMaxStepsError {
|
||||
|
||||
/// The test Harness. This contains everything needed to run the test.
|
||||
///
|
||||
/// Create a new Harness using [`Harness::new`] or [`Harness::builder`].
|
||||
/// Create a new Harness using [`Harness::new_ui`] or [`Harness::builder`].
|
||||
///
|
||||
/// The [Harness] has a optional generic state that can be used to pass data to the app / ui closure.
|
||||
/// In _most cases_ it should be fine to just store the state in the closure itself.
|
||||
@@ -185,43 +185,10 @@ impl<'a, State> Harness<'a, State> {
|
||||
HarnessBuilder::default()
|
||||
}
|
||||
|
||||
/// Create a new Harness with the given app closure and a state.
|
||||
///
|
||||
/// The app closure will immediately be called once to create the initial ui.
|
||||
///
|
||||
/// If you don't need to create Windows / Panels, you can use [`Harness::new_ui`] instead.
|
||||
///
|
||||
/// If you e.g. want to customize the size of the window, you can use [`Harness::builder`].
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// # use egui::CentralPanel;
|
||||
/// # use egui_kittest::{Harness, kittest::Queryable};
|
||||
/// let mut checked = false;
|
||||
/// let mut harness = Harness::new_state(|ctx, checked| {
|
||||
/// CentralPanel::default().show(ctx, |ui| {
|
||||
/// ui.checkbox(checked, "Check me!");
|
||||
/// });
|
||||
/// }, checked);
|
||||
///
|
||||
/// harness.get_by_label("Check me!").click();
|
||||
/// harness.run();
|
||||
///
|
||||
/// assert_eq!(*harness.state(), true);
|
||||
/// ```
|
||||
#[track_caller]
|
||||
#[deprecated = "use `new_ui_state` instead"]
|
||||
pub fn new_state(app: impl FnMut(&egui::Context, &mut State) + 'a, state: State) -> Self {
|
||||
#[expect(deprecated)]
|
||||
Self::builder().build_state(app, state)
|
||||
}
|
||||
|
||||
/// Create a new Harness with the given ui closure and a state.
|
||||
///
|
||||
/// The ui closure will immediately be called once to create the initial ui.
|
||||
///
|
||||
/// If you need to create Windows / Panels, you can use [`Harness::new`] instead.
|
||||
///
|
||||
/// If you e.g. want to customize the size of the ui, you can use [`Harness::builder`].
|
||||
///
|
||||
/// # Example
|
||||
@@ -714,48 +681,15 @@ impl<'a, State> Harness<'a, State> {
|
||||
queue: &self.queued_events,
|
||||
}
|
||||
}
|
||||
|
||||
#[deprecated = "Use `Harness::root` instead."]
|
||||
pub fn node(&self) -> Node<'_> {
|
||||
self.root()
|
||||
}
|
||||
}
|
||||
|
||||
/// Utilities for stateless harnesses.
|
||||
impl<'a> Harness<'a> {
|
||||
/// Create a new Harness with the given app closure.
|
||||
/// Use the [`Harness::run`], [`Harness::step`], etc... methods to run the app.
|
||||
///
|
||||
/// The app closure will immediately be called once to create the initial ui.
|
||||
///
|
||||
/// If you don't need to create Windows / Panels, you can use [`Harness::new_ui`] instead.
|
||||
///
|
||||
/// If you e.g. want to customize the size of the window, you can use [`Harness::builder`].
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// # use egui::CentralPanel;
|
||||
/// # use egui_kittest::Harness;
|
||||
/// let mut harness = Harness::new(|ctx| {
|
||||
/// CentralPanel::default().show(ctx, |ui| {
|
||||
/// ui.label("Hello, world!");
|
||||
/// });
|
||||
/// });
|
||||
/// ```
|
||||
#[track_caller]
|
||||
#[deprecated = "use `new_ui` instead"]
|
||||
pub fn new(app: impl FnMut(&egui::Context) + 'a) -> Self {
|
||||
#[expect(deprecated)]
|
||||
Self::builder().build(app)
|
||||
}
|
||||
|
||||
/// Create a new Harness with the given ui closure.
|
||||
/// Use the [`Harness::run`], [`Harness::step`], etc... methods to run the app.
|
||||
///
|
||||
/// The ui closure will immediately be called once to create the initial ui.
|
||||
///
|
||||
/// If you need to create Windows / Panels, you can use [`Harness::new`] instead.
|
||||
///
|
||||
/// If you e.g. want to customize the size of the ui, you can use [`Harness::builder`].
|
||||
///
|
||||
/// # Example
|
||||
|
||||
@@ -54,11 +54,6 @@ impl Node<'_> {
|
||||
self.click_button(PointerButton::Primary);
|
||||
}
|
||||
|
||||
#[deprecated = "Use `click()` instead."]
|
||||
pub fn simulate_click(&self) {
|
||||
self.click();
|
||||
}
|
||||
|
||||
pub fn click_secondary(&self) {
|
||||
self.click_button(PointerButton::Secondary);
|
||||
}
|
||||
@@ -130,28 +125,6 @@ impl Node<'_> {
|
||||
}));
|
||||
}
|
||||
|
||||
#[deprecated = "Use `Harness::key_down` instead."]
|
||||
pub fn key_down(&self, key: egui::Key) {
|
||||
self.event(egui::Event::Key {
|
||||
key,
|
||||
pressed: true,
|
||||
modifiers: Modifiers::default(),
|
||||
repeat: false,
|
||||
physical_key: None,
|
||||
});
|
||||
}
|
||||
|
||||
#[deprecated = "Use `Harness::key_up` instead."]
|
||||
pub fn key_up(&self, key: egui::Key) {
|
||||
self.event(egui::Event::Key {
|
||||
key,
|
||||
pressed: false,
|
||||
modifiers: Modifiers::default(),
|
||||
repeat: false,
|
||||
physical_key: None,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn type_text(&self, text: &str) {
|
||||
self.event(egui::Event::Text(text.to_owned()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user