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

Add Continuous mode to ctx.memory.options #4214

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4b94b2c
Update epi_integration.rs
rustbasic Mar 23, 2024
67bc17c
Update memory.rs
rustbasic Mar 23, 2024
34e4364
Update memory.rs
rustbasic Mar 23, 2024
2c48d6d
Update backend_panel.rs
rustbasic Mar 23, 2024
bc9d374
Update memory.rs
rustbasic Mar 23, 2024
d67f20f
Update memory.rs
rustbasic Mar 23, 2024
2b45515
Update memory.rs
rustbasic Mar 23, 2024
1d4d54b
Update memory.rs
rustbasic Mar 23, 2024
f00fd64
Update epi_integration.rs
rustbasic Mar 23, 2024
8c2f741
Update memory.rs
rustbasic Mar 23, 2024
9d56a29
Merge branch 'emilk:master' into patch29
rustbasic Mar 25, 2024
5140e4f
Merge branch 'emilk:master' into patch29
rustbasic Mar 26, 2024
e82ab2d
Merge branch 'emilk:master' into patch29
rustbasic Mar 27, 2024
d47b7cc
Merge branch 'emilk:master' into patch29
rustbasic Mar 27, 2024
3a40cfa
Merge branch 'emilk:master' into patch29
rustbasic Mar 28, 2024
1a1c007
make `continuous_mode` work on all egui integrations
emilk Mar 29, 2024
930b5de
Merge branch 'emilk:master' into patch29
rustbasic Mar 29, 2024
bf6b20d
Merge branch 'emilk:master' into patch29
rustbasic Mar 30, 2024
b4572c4
Merge branch 'emilk:master' into patch29
rustbasic Mar 30, 2024
dbfc9bc
Merge branch 'emilk:master' into patch29
rustbasic Mar 30, 2024
a0e5f4b
Merge branch 'emilk:master' into patch29
rustbasic Mar 31, 2024
52f06b1
Update context.rs
rustbasic Mar 31, 2024
4b1107f
Merge branch 'emilk:master' into patch29
rustbasic Apr 1, 2024
14592ed
Merge branch 'emilk:master' into patch29
rustbasic Apr 1, 2024
df99df1
Merge branch 'emilk:master' into patch29
rustbasic Apr 1, 2024
8707af4
Merge branch 'emilk:master' into patch29
rustbasic Apr 2, 2024
4ccd75c
Merge branch 'emilk:master' into patch29
rustbasic Apr 2, 2024
1d7a429
Merge branch 'emilk:master' into patch29
rustbasic Apr 3, 2024
1825430
Merge branch 'emilk:master' into patch29
rustbasic Apr 3, 2024
8bf3db9
Merge branch 'emilk:master' into patch29
rustbasic Apr 5, 2024
6e070b6
Merge branch 'emilk:master' into patch29
rustbasic Apr 19, 2024
ebe65d8
Update epi_integration.rs
rustbasic Apr 27, 2024
88c773f
Update epi_integration.rs
rustbasic Apr 27, 2024
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
3 changes: 2 additions & 1 deletion crates/eframe/src/native/epi_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,11 @@ impl EpiIntegration {

let full_output = self.egui_ctx.run(raw_input, |egui_ctx| {
if let Some(viewport_ui_cb) = viewport_ui_cb {
// Child viewport
// Child Deferred Viewport
crate::profile_scope!("viewport_callback");
viewport_ui_cb(egui_ctx);
} else {
// ROOT Viewport ( with Immediate Viewport )
crate::profile_scope!("App::update");
app.update(egui_ctx, &mut self.frame);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,7 @@ impl ContextImpl {
.graphics
.drain(self.memory.areas().order(), &self.memory.layer_transforms);

let mut repaint_needed = false;
let mut repaint_needed = self.memory.options.continuous_mode;

{
if self.memory.options.repaint_on_widget_change {
Expand Down
8 changes: 8 additions & 0 deletions crates/egui/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ pub struct Options {
/// Controls the tessellator.
pub tessellation_options: epaint::TessellationOptions,

/// If `true`, This will call `egui::Context::request_repaint()` at the end of each frame
/// If `false` (default), egui is only updated if are input events (like mouse movements) or there are some animations in the GUI.
pub continuous_mode: bool,
emilk marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should just move enum RunMode { into egui from crates/egui_demo_app/src/backend_panel.rs. At least we should copy its documentation.


/// If any widget moves or changes id, repaint everything.
///
/// It is recommended you keep this OFF, because
Expand Down Expand Up @@ -230,6 +234,7 @@ impl Default for Options {
zoom_factor: 1.0,
zoom_with_keyboard: true,
tessellation_options: Default::default(),
continuous_mode: false,
repaint_on_widget_change: false,
screen_reader: false,
preload_font_glyphs: true,
Expand All @@ -246,6 +251,7 @@ impl Options {
zoom_factor: _, // TODO(emilk)
zoom_with_keyboard,
tessellation_options,
continuous_mode,
repaint_on_widget_change,
screen_reader: _, // needs to come from the integration
preload_font_glyphs: _,
Expand All @@ -257,6 +263,8 @@ impl Options {
CollapsingHeader::new("⚙ Options")
.default_open(false)
.show(ui, |ui| {
ui.checkbox(continuous_mode, "Repaint at the end of each frame");

ui.checkbox(
repaint_on_widget_change,
"Repaint if any widget moves or changes id",
Expand Down
3 changes: 2 additions & 1 deletion crates/egui_demo_app/src/backend_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ impl BackendPanel {
match self.run_mode {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.run_mode can be replaced with options.continuous_mode

RunMode::Continuous => {
// Tell the backend to repaint as soon as possible
ctx.request_repaint();
ctx.options_mut(|options| options.continuous_mode = true);
}
RunMode::Reactive => {
// let the computer rest for a bit
ctx.options_mut(|options| options.continuous_mode = false);
}
}
}
Expand Down
Loading