Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Nov 12, 2023
1 parent 46d3039 commit a3c7bdd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
9 changes: 8 additions & 1 deletion crates/eframe/src/native/epi_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ pub fn handle_app_output(
app_output: epi::backend::AppOutput,
window_state: &mut WindowState,
) {
crate::profile_function!();

let epi::backend::AppOutput {
close: _,
window_size,
Expand Down Expand Up @@ -478,6 +480,8 @@ impl EpiIntegration {
egui_winit.on_event(&self.egui_ctx, event)
}

/// If `viewport_ui_cb` is None, we are in the root viewport
/// and will cal [`App::update`].
pub fn update(
&mut self,
app: &mut dyn epi::App,
Expand All @@ -497,12 +501,15 @@ impl EpiIntegration {

// Run user code:
let full_output = self.egui_ctx.run(raw_input, |egui_ctx| {
crate::profile_scope!("App::update");
if let Some(viewport_ui_cb) = viewport_ui_cb {
// Child viewport
crate::profile_scope!("callback");
debug_assert!(id_pair.this != ViewportId::ROOT);
viewport_ui_cb(egui_ctx);
} else {
// Root viewport
crate::profile_scope!("App::update");
debug_assert_eq!(id_pair, ViewportIdPair::ROOT);
app.update(egui_ctx, &mut self.frame);
}
});
Expand Down
2 changes: 2 additions & 0 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,8 @@ impl State {
egui_ctx: &egui::Context,
platform_output: egui::PlatformOutput,
) {
crate::profile_function!();

let egui::PlatformOutput {
cursor_icon,
open_url,
Expand Down
21 changes: 13 additions & 8 deletions crates/egui/src/data/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ impl ViewportInfo {
pub fn take(&mut self) -> Self {
core::mem::take(self)
}

pub fn ui(&self, ui: &mut crate::Ui) {
let Self {
id_pair,
inner_rect,
outer_rect,
close_requested,
} = self;
ui.label(format!("id_pair: {id_pair:?}"));
ui.label(format!("inner_rect: {inner_rect:?}"));
ui.label(format!("outer_rect: {outer_rect:?}"));
ui.label(format!("close_requested: {close_requested:?}"));
}
}

/// A file about to be dropped into egui.
Expand Down Expand Up @@ -1000,14 +1013,6 @@ impl RawInput {
}
}

impl ViewportInfo {
pub fn ui(&self, ui: &mut crate::Ui) {
ui.label(format!("id_pair: {:?}", self.id_pair));
ui.label(format!("inner_rect: {:?}", self.inner_rect));
ui.label(format!("outer_rect: {:?}", self.outer_rect));
}
}

/// this is a `u64` as values of this kind can always be obtained by hashing
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
Expand Down

0 comments on commit a3c7bdd

Please sign in to comment.