Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple viewports/windows #3172

Merged
merged 367 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
367 commits
Select commit Hold shift + click to select a range
7c4a85e
Now in ViewportBuilder, InputState, RawInput: viewport_inner_pos, vie…
konkitoman Sep 4, 2023
12eeda0
Merge branch 'master' of https://github.com/emilk/egui into multiples…
konkitoman Sep 4, 2023
f30bf51
Merge branch 'master' of https://github.com/emilk/egui into multiples…
konkitoman Sep 5, 2023
39a57f1
I restored Cargo.lock from emilk/egui master
konkitoman Sep 5, 2023
155d48a
Added __screenshot feature for eframe in viewports example
konkitoman Sep 5, 2023
e44c2e6
Merge branch 'master' of https://github.com/emilk/egui into multiples…
konkitoman Sep 5, 2023
6e244d1
Improved documentation and added documentation
konkitoman Sep 5, 2023
fea6ed7
Merge branch 'master' of https://github.com/emilk/egui into multiples…
konkitoman Sep 6, 2023
83f8260
* Fix warnings
konkitoman Sep 6, 2023
b1189c1
Now when creating a async viewport, if we not spefify the icon will h…
konkitoman Sep 6, 2023
fb80880
* Fix posibile deadlock when sending a viewport command from a sync v…
konkitoman Sep 6, 2023
a5d4ce8
Now eframe glow supports viewport sync icon
konkitoman Sep 6, 2023
956c1c3
Fix memory leak
konkitoman Sep 10, 2023
fc90a7e
Fix cyclical reference
konkitoman Sep 11, 2023
1cbf333
* Fix crash when spamming a viewport with other viewports
konkitoman Sep 11, 2023
c96197d
Merge branch 'master' of https://github.com/emilk/egui into multiples…
konkitoman Sep 19, 2023
915d1b6
Add ViewportIdPair, Viewport, ViewportOutput
konkitoman Sep 19, 2023
ddff550
Remove get_*
konkitoman Sep 19, 2023
e2d406d
* InputState::{inner_pos, inner_size} compacted to InputState::inner_…
konkitoman Sep 19, 2023
22c128b
Fix warning in viewports example
konkitoman Sep 19, 2023
8ecd29d
eframe: Now WGPU implementation when creating a sync viewport will in…
konkitoman Sep 20, 2023
f4c5378
Merge branch 'master' of https://github.com/emilk/egui into multiples…
konkitoman Sep 25, 2023
28f7b86
egui: Move comment
konkitoman Sep 25, 2023
e453d66
egui and eframe now uses more ViewportIdPair
konkitoman Sep 25, 2023
489d8a7
egui: fix web app runner
konkitoman Sep 25, 2023
543a0a2
egui, egui_glow, eframe: fix all errors returned by ./scripts/check.sh
konkitoman Sep 25, 2023
b719e1c
eframe fix android build
konkitoman Sep 26, 2023
6a5838c
Now all sizes are in Vec2 insted of Pos2
konkitoman Sep 26, 2023
43ad25a
Renamed gl_window to glutin_ctx in init_run_state and initializate ma…
konkitoman Sep 26, 2023
e578312
Fix max_texture_side for the main viewport was alwats set to 0
konkitoman Sep 26, 2023
5c8c56c
rename the events that are result of events event_result
konkitoman Sep 26, 2023
f3686e2
now using a HashMap insted of a Vec to store repaint_after
konkitoman Sep 26, 2023
1930d69
Fix the change that change from a Vec to HashMap braked web and pure_…
konkitoman Sep 26, 2023
38e00e2
refactor eframe viewport sync rendering for glow and wgpu
konkitoman Sep 26, 2023
f001f06
Restore from master egui_demo_app.js and egui_demo_app_bg.wasm
konkitoman Sep 26, 2023
449f38a
This is a temporary fix to not unsafe impl Sync + Send for backends
konkitoman Sep 26, 2023
8fad6b7
Now we use egui::ColorImage insted of (u32, u32, Vec<u8>)
konkitoman Sep 26, 2023
73f14c9
Update crates/eframe/src/native/run.rs
konkitoman Sep 28, 2023
7caa042
Merge branch 'master' of https://github.com/emilk/egui into multiples…
konkitoman Sep 30, 2023
4243036
Update ViewportBuilder, documentation and implementation
konkitoman Sep 30, 2023
287f704
Fix typos and expose Context::is_desktop
konkitoman Sep 30, 2023
e21ed4f
refactored the viewports example
konkitoman Oct 9, 2023
954366e
eframe: refactor code to be more compact and faster
konkitoman Oct 11, 2023
7f1a1e3
Now in ViewportBuilder has close_button and drag_and_drop enabled by …
konkitoman Oct 18, 2023
701d31a
Viewports example:
konkitoman Oct 18, 2023
b1e7faf
egui:
konkitoman Oct 18, 2023
4f1696c
big refractor
konkitoman Oct 19, 2023
ec37d38
Fix pure glow
konkitoman Oct 19, 2023
f5e1d08
Fixing:
konkitoman Oct 19, 2023
9e89188
Fix trying to render not existent viewport resulting in 100% cpu usage
konkitoman Oct 19, 2023
cc78ecb
Fix X11 invalid outer_position, inner_position, outer_size, inner_siz…
konkitoman Oct 20, 2023
fb02629
Added pixels per point in viewports example
konkitoman Oct 20, 2023
84ef02d
eframe WGPU:
konkitoman Oct 20, 2023
239a807
Fix default viewport size and added a range on pixels_per_point
konkitoman Oct 20, 2023
b422456
Now all viewports repaint when pixels_per_point are changed
konkitoman Oct 20, 2023
d6c2f3e
Fix pixels per point for multiples viewports
konkitoman Oct 22, 2023
9b32dd7
Refactor and update docs
konkitoman Oct 25, 2023
a57a3d0
Add to semicolons to silence clippy
emilk Nov 1, 2023
cc31695
Remove unused `use` statment
emilk Nov 1, 2023
06af749
Merge branch 'master' into multiples_viewports
emilk Nov 1, 2023
9f926d4
Lint: vertical spacing
emilk Nov 1, 2023
678a3b0
Replace RwLock with RefCell in thread_local
emilk Nov 1, 2023
abc70cc
Misc code cleanup
emilk Nov 1, 2023
f6c5e71
Simplify function signature
emilk Nov 1, 2023
521678b
Simplify another function signature
emilk Nov 1, 2023
ec39563
Use less RwLocks and Arcs in public interfaces
emilk Nov 1, 2023
0c9673b
Fix broken doclinks
emilk Nov 1, 2023
3d1ee1b
Replace some `Arc` with `Rc` to make it clear what is thread-local
emilk Nov 1, 2023
9fce858
Less RwLock in parameters
emilk Nov 1, 2023
7c1af06
Less RwLock
emilk Nov 1, 2023
2eb1240
Less RefCell in parameters
emilk Nov 1, 2023
7340acf
Less RefCell in parameters
emilk Nov 1, 2023
e5dab1e
Less RefCell in parameters
emilk Nov 1, 2023
72a7ee4
fix typo
emilk Nov 1, 2023
2b8e5b5
Fix crash when rendering a sync viewport in a sync viewport
konkitoman Nov 1, 2023
76d3873
Better names
konkitoman Nov 1, 2023
9749e1e
Move Rc<RefCell<……>> outside of struct Viewports
emilk Nov 2, 2023
46febb4
Fix crash during shutdown
emilk Nov 2, 2023
75e6d3c
Fix crash on eframe wgpu when rendering a sync viewport in a sync vie…
konkitoman Nov 2, 2023
0df4b49
Better error reporting
emilk Nov 3, 2023
99417b4
Clean up viewports example slightly
emilk Nov 3, 2023
51b083a
Misc code cleanup
emilk Nov 3, 2023
29e1c4d
Spelling
emilk Nov 3, 2023
9fd65ad
Rename `render` to `viewport_ui_cb` to avoid confusion
emilk Nov 3, 2023
1f0fc7a
format let-else statements
emilk Nov 3, 2023
256ad73
More cleanup
emilk Nov 3, 2023
682db9c
create_viewport_sync: embed viewport if backend doesn't support them
emilk Nov 3, 2023
f14fa16
rename `pair` to `id_pair`
emilk Nov 3, 2023
47e7b9d
Minor naming cleanup
emilk Nov 3, 2023
3cb8f49
`ViewportId` now wraps `Id`
emilk Nov 3, 2023
4cad978
Spelling
emilk Nov 6, 2023
39f13b4
Hide close-button for child viewports by default
emilk Nov 6, 2023
c29727f
Fix docs
konkitoman Nov 6, 2023
0ae7eeb
Clean up example code
emilk Nov 6, 2023
6a371e5
Define a fast `ViewportMap` type
emilk Nov 6, 2023
a52d383
MAIN -> ROOT
emilk Nov 6, 2023
73432ba
Make the viewports example/test an explicit tree of viewports
emilk Nov 6, 2023
291ab1e
Rename viewports example to test_viewports, and hide drag-and-drop
emilk Nov 6, 2023
8aa14d2
Allow changing titles
emilk Nov 6, 2023
58dc7ba
Cleanup
konkitoman Nov 7, 2023
1ddfe07
Fix warning
konkitoman Nov 7, 2023
a85adf5
Rename `force_embedding` -> `embed_viewports`
emilk Nov 7, 2023
6643713
Remove `Context::is_desktop`
emilk Nov 7, 2023
7bc5698
Always use the latest async callback when rendering a viewport
emilk Nov 7, 2023
d6a5c8b
Introduce `ViewportIdSet`
emilk Nov 7, 2023
76fd562
eframe:
konkitoman Nov 7, 2023
54c6d51
Move egui_winit::changes_between_builders to egui::ViewportBuilder::p…
konkitoman Nov 7, 2023
645521b
Clarify logic around how viewports are retained, and add `ViewportIdSet`
emilk Nov 7, 2023
522cfb5
Fix docs
konkitoman Nov 7, 2023
85c8708
egui-wgpu cleanup
emilk Nov 7, 2023
d4fab25
Improve docs for `ViewportCommand`
emilk Nov 7, 2023
f300c95
Rename the viewport types to "immediate" and "deferred"
emilk Nov 7, 2023
290ecca
Add a simple example of the viewports API
emilk Nov 7, 2023
ae346e1
update Cargo.lock
emilk Nov 7, 2023
4ca165b
Make Memory::areas private
emilk Nov 7, 2023
911b147
Only have one `Memory::areas`
emilk Nov 7, 2023
72d77bc
Only one Memory window interaction
emilk Nov 7, 2023
1a261ed
Only one Interaction member of Memory
emilk Nov 7, 2023
18f3fdb
Remove unsafe impl of Send and Sync for Painter
emilk Nov 7, 2023
d313487
Clean up egui-wgpu code
emilk Nov 7, 2023
25fd7ba
Fix wrong pixels-per-point for wgpu
emilk Nov 7, 2023
35a799c
Refactor glow setup a bit
emilk Nov 7, 2023
96f1426
Clean up how max_texture_side is set
emilk Nov 7, 2023
a3b0200
Some better naming and cleanup of viewport.rs
emilk Nov 7, 2023
701301e
Use a `ViewportIdSet`
emilk Nov 7, 2023
2d54b4b
Small cleanup and renamings
emilk Nov 7, 2023
bee5d32
Add some puffin profiling scopes
emilk Nov 7, 2023
b59cb75
use let-else to reduce indentation levels
emilk Nov 7, 2023
0d7c878
Better ViewportBuilder builder patern
konkitoman Nov 8, 2023
12f3782
Introduce ViewportInfo
konkitoman Nov 8, 2023
f174467
Remove viewport_id from tessellate and added tessellate_for
konkitoman Nov 8, 2023
37e42d1
Fix docs
konkitoman Nov 8, 2023
04fbafd
Fix web
konkitoman Nov 8, 2023
e9b57e6
Fix warning
konkitoman Nov 8, 2023
9676115
Simplify and move CloseRequested
konkitoman Nov 8, 2023
a852333
only apply x11 stuff on linux
emilk Nov 9, 2023
0f7d1d5
Clarify tessellate
emilk Nov 9, 2023
79bfca3
Remove unnecessary `Clone`
emilk Nov 9, 2023
0c300e1
Replace newtype with type alias
emilk Nov 9, 2023
3c8110e
Remove superfluous profiling scopes
emilk Nov 9, 2023
3041de3
`is_focused` -> `focused_viewport`
emilk Nov 9, 2023
9e8fb18
borrow_mut -> replace
emilk Nov 9, 2023
8a41642
Remove unused Rc<RefCell<T>>
konkitoman Nov 10, 2023
4ff713a
Removed more unused Rc<RefCell<T>>
konkitoman Nov 10, 2023
4539ebe
Remove another Rc<RefCell<T>>
konkitoman Nov 10, 2023
6b74ee7
Simplify a little
konkitoman Nov 10, 2023
0901fa5
Fix: When we have a Viewport in a Viewport and when the first is dest…
konkitoman Nov 10, 2023
2a554dd
Remove unnecessary Box
emilk Nov 11, 2023
3d6ca6c
Simplify arguments
emilk Nov 11, 2023
9c420b9
Remove some clones
emilk Nov 11, 2023
d439965
Replace four locks with a single lock
emilk Nov 11, 2023
40f0fc0
Remove another `Rc`
emilk Nov 11, 2023
3a87db2
Remove RefCell
emilk Nov 11, 2023
7e96001
Remove Rc<RefCell<…>>
emilk Nov 11, 2023
5ecc0e3
Small cleanup
emilk Nov 11, 2023
962eb02
More cleanup
emilk Nov 11, 2023
6866e58
More Id:s, less cloning
emilk Nov 11, 2023
4dfc28f
Add some comments
emilk Nov 11, 2023
730a4b7
typo
emilk Nov 11, 2023
922c372
Fix andoid compilation
emilk Nov 11, 2023
51938ef
Remove unnecessary std::result:: Prefix
emilk Nov 11, 2023
6e17040
Merge branch 'master' into multiples_viewports
emilk Nov 12, 2023
e1f261b
Simplify arguments to process_viewport_commands
emilk Nov 12, 2023
111228b
Warn on web if there are more than one viewport
emilk Nov 12, 2023
2f53f7d
Handle viewport commands in EguiGlow
emilk Nov 12, 2023
46d3039
Clean up ViewportCommands
emilk Nov 12, 2023
a3c7bdd
Minor cleanup
emilk Nov 12, 2023
5892d05
Use _px suffix for things in pixel units
emilk Nov 12, 2023
de6c250
Remove WINIT_EVENT_LOOP hack
emilk Nov 12, 2023
9eda6f6
Clean up run.rs
emilk Nov 12, 2023
e83d227
Create helper `make_viewport_current`
emilk Nov 12, 2023
93cb96e
Move process_viewport_builders
emilk Nov 12, 2023
6ddc22e
Reduce indentation by making some function non-members
emilk Nov 12, 2023
1c5c198
Fewer arguments to `EpiIntegration::`update
emilk Nov 12, 2023
3e57131
No need to wrap winit::Window in RefCell - it is already Sync
emilk Nov 12, 2023
115e10b
Avoid some Window Rc clones
emilk Nov 12, 2023
df78a2d
`use winit::window::{Window, WindowId};`
emilk Nov 12, 2023
10dce1c
Naming: `state` -> `egui_winit`
emilk Nov 12, 2023
00ee51b
Less Viewport cloning
emilk Nov 12, 2023
960ef20
Remove the need for `window` during app update
emilk Nov 12, 2023
7c251a5
Fix crash when closing end opening a viewport really fast
konkitoman Nov 13, 2023
c32d035
Improve next_repaint_time
konkitoman Nov 13, 2023
c033483
Remove clone and fix ClontrolFlow::Pull overrided by WaitUntil
konkitoman Nov 13, 2023
4bee4f8
Refactor how `EpiIntegration::update` is called
emilk Nov 13, 2023
8d35f51
Clippy fixes
emilk Nov 13, 2023
39ccffb
No need to clone viewports
emilk Nov 13, 2023
b179ddc
Remove another Rc-RefMut
emilk Nov 13, 2023
4d7fc70
Add a comment
emilk Nov 13, 2023
dcd1675
Fix wasm compilation
emilk Nov 13, 2023
0dec08b
Remove another Rc<RefCell<_>>
emilk Nov 13, 2023
9418499
Avoid unwrap
emilk Nov 13, 2023
8195a82
Split out `run_ui_and_paint` to be a member of `GlowWinitRunning`
emilk Nov 13, 2023
fdb7499
Build fix
emilk Nov 13, 2023
337da61
Easily open all viewports in test_viewports app
emilk Nov 13, 2023
719f2f1
Reduce indentation and simplify code
emilk Nov 13, 2023
3a07c0c
Less cloning
emilk Nov 13, 2023
5136e3a
No need to store an `Arc<glow::Context>`
emilk Nov 13, 2023
eafe36d
Small code cleanup
emilk Nov 13, 2023
0ad9970
Fix doclink
emilk Nov 13, 2023
6e7a735
Clarify comment
emilk Nov 13, 2023
7682a7a
Code cleanup: spliut out `save_screeshot_and_exit` helper function
emilk Nov 13, 2023
0cd6204
Reduce indentation levels
emilk Nov 13, 2023
4ba27bd
Lock once up-front
emilk Nov 13, 2023
8bf670c
Less unwrap
emilk Nov 13, 2023
0915fb2
Move stuff into `impl WgpuWinitRunning`
emilk Nov 13, 2023
0c82844
Remove secondary map of `builders`
emilk Nov 14, 2023
66662e4
Rename `id_pair` to `ids` everywhere
emilk Nov 14, 2023
002110e
Create `struct ImmediateViewport` to simplify argument lists
emilk Nov 14, 2023
4be66c0
Add helper function for initializing/updating viewports
emilk Nov 14, 2023
67c192b
Simplify render_immediate_viewport
emilk Nov 14, 2023
2c9426b
Simplify render_immediate_viewport
emilk Nov 14, 2023
274cdea
Make same simplification for the glow integration
emilk Nov 14, 2023
aad7ed2
"Final" touch-ups on wgpu integration
emilk Nov 14, 2023
4aefb26
Break out on_window_event for glow
emilk Nov 14, 2023
17614cd
Final touch-ups of glow code
emilk Nov 14, 2023
d6c1505
Small touch-ups of the event loop
emilk Nov 14, 2023
999a54f
Fix id clash in test_viewports app
emilk Nov 14, 2023
f9e6860
Better error reporting
emilk Nov 14, 2023
afe1649
Format let-else
emilk Nov 14, 2023
874556c
Fix `eprint` -> `eprintln`
emilk Nov 14, 2023
1090d2d
Fix comment
emilk Nov 14, 2023
0dd10bf
Cleanup: replace `std::iter::once(x)` with `[x]`
emilk Nov 14, 2023
dc4e06a
Fix wasm32 build
emilk Nov 14, 2023
bfaef3a
Fix typo
emilk Nov 14, 2023
09a728b
Clean up request-repaint logic: always request at least two repaints
emilk Nov 14, 2023
54f6e6b
Remove `id` from `ViewportBuilder` so it can implement `Default`
emilk Nov 14, 2023
dacce7b
Use the egui-standard builder pattern for `ViewportBuilder`
emilk Nov 14, 2023
ab67a31
Refactor Context.rs: clump all per-viewport state together
emilk Nov 15, 2023
c18eb19
Simplify Context::end_frame
emilk Nov 15, 2023
1b1be3c
Pass out `pixels_per_point` in output for use in tesselation
emilk Nov 15, 2023
4790a64
Fix wasm build
emilk Nov 15, 2023
684b166
Fix doclinks
emilk Nov 15, 2023
6c9ce2b
Simplify Context: put per-viewport repaint info into the same state
emilk Nov 15, 2023
ccf96ce
Fix android build
emilk Nov 15, 2023
6f98994
Show how to close a child viewport in the example
emilk Nov 15, 2023
d21458d
Simplify ViewportBuilder: Defaults is chosen by eframe
emilk Nov 15, 2023
e36ef75
Remove `Option<Option<X>>` and simplify ViewportBuilder
emilk Nov 15, 2023
fb07dc1
Move the viewport commands into the per-viewport output
emilk Nov 15, 2023
62fcc62
Handle all the output in the immediate renderers
emilk Nov 15, 2023
4930e7b
Doc improvements
emilk Nov 15, 2023
09b639e
Fix web build
emilk Nov 15, 2023
e222247
Output the repaint delay for integrations that don't install a callback
emilk Nov 15, 2023
d231a05
Fix clicking windows
emilk Nov 15, 2023
46bea93
Fix web build
emilk Nov 15, 2023
13e258b
Fix pure_glow example
emilk Nov 15, 2023
fb21fee
Small cleanup of context.rs
emilk Nov 16, 2023
2cb2434
`ViewportOutput`: only include parent id, as own if is the key of map
emilk Nov 16, 2023
b0d64aa
Fix typos
emilk Nov 16, 2023
26f0c2a
Classify viewports using `enum ViewportClass`
emilk Nov 16, 2023
82863f8
Add a lot more documentation
emilk Nov 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions crates/eframe/src/epi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#[cfg(not(target_arch = "wasm32"))]
mod icon_data;

use egui::ViewportRender;
#[cfg(not(target_arch = "wasm32"))]
pub use icon_data::IconData;

Expand Down Expand Up @@ -112,7 +113,7 @@ pub trait App {
/// The [`egui::Context`] can be cloned and saved if you like.
///
/// To force a repaint, call [`egui::Context::request_repaint`] at any time (e.g. from another thread).
fn update(&mut self, ctx: &egui::Context, frame: &mut Frame);
fn update(&mut self, ctx: &egui::Context, frame: &mut Frame, render: Option<&ViewportRender>);

/// Get a handle to the app.
///
Expand Down Expand Up @@ -208,7 +209,7 @@ pub trait App {
// NOTE: a bright gray makes the shadows of the windows look weird.
// We use a bit of transparency so that if the user switches on the
// `transparent()` option they get immediate results.
egui::Color32::from_rgba_unmultiplied(12, 12, 12, 180).to_normalized_gamma_f32()
egui::Color32::from_rgba_unmultiplied(12, 12, 12, 0).to_normalized_gamma_f32()

// _visuals.window_fill() would also be a natural choice
}
Expand Down Expand Up @@ -507,7 +508,7 @@ impl Default for NativeOptions {
min_window_size: None,
max_window_size: None,
resizable: true,
transparent: false,
transparent: true,
mouse_passthrough: false,

active: true,
Expand Down Expand Up @@ -774,6 +775,9 @@ impl Frame {
self.info.clone()
}

/// If this is the main window will return true!
/// When is a single window mode will always return true!

/// A place where you can store custom data in a way that persists when you restart the app.
pub fn storage(&self) -> Option<&dyn Storage> {
self.storage.as_deref()
Expand Down Expand Up @@ -809,7 +813,7 @@ impl Frame {
/// struct MyApp;
///
/// impl eframe::App for MyApp {
/// fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
/// fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame, _render: Option<&egui::ViewportRender>) {
/// // In real code the app would render something here
/// frame.request_screenshot();
/// // Things that are added to the frame after the call to
Expand Down
19 changes: 15 additions & 4 deletions crates/eframe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
//! }
//!
//! impl eframe::App for MyEguiApp {
//! fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
//! fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame, _render: Option<&egui::ViewportRender>) {
//! egui::CentralPanel::default().show(ctx, |ui| {
//! ui.heading("Hello World!");
//! });
Expand Down Expand Up @@ -187,7 +187,7 @@ mod native;
/// }
///
/// impl eframe::App for MyEguiApp {
/// fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
/// fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame, _render: Option<&egui::ViewportRender>) {
/// egui::CentralPanel::default().show(ctx, |ui| {
/// ui.heading("Hello World!");
/// });
Expand Down Expand Up @@ -269,13 +269,24 @@ pub fn run_simple_native(
native_options: NativeOptions,
update_fun: impl FnMut(&egui::Context, &mut Frame) + 'static,
) -> Result<()> {
use egui::{ViewportId, ViewportRender};

struct SimpleApp<U> {
update_fun: U,
}

impl<U: FnMut(&egui::Context, &mut Frame)> App for SimpleApp<U> {
fn update(&mut self, ctx: &egui::Context, frame: &mut Frame) {
(self.update_fun)(ctx, frame);
fn update(
&mut self,
ctx: &egui::Context,
frame: &mut Frame,
render: Option<&ViewportRender>,
) {
if ctx.get_viewport_id() == ViewportId::MAIN {
(self.update_fun)(ctx, frame);
} else if let Some(render_function) = render {
render_function(ctx);
}
}
}

Expand Down
Loading