1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 06:40:06 -04:00

Add egui_inspection protocol and plugin (#8234)

Introduces live inspection for running egui apps over a small TCP
request/response protocol, plus the `egui::Plugin` that serves it.

This is the minimal surface to get the egui mcp in, we may want to
extend this in the future to add support for the inspection gui.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lucas Meurer
2026-06-18 11:26:18 +02:00
committed by GitHub
parent 172fb54f7f
commit 86fcffb229
16 changed files with 869 additions and 14 deletions

View File

@@ -897,7 +897,7 @@ impl Context {
profiling::function_scope!();
let plugins = self.read(|ctx| ctx.plugins.ordered_plugins());
plugins.on_input(&mut new_input);
plugins.on_input(self, &mut new_input);
self.write(|ctx| ctx.begin_pass(new_input));
}
@@ -2391,7 +2391,7 @@ impl Context {
let mut output = self.write(|ctx| ctx.end_pass());
let plugins = self.read(|ctx| ctx.plugins.ordered_plugins());
plugins.on_output(&mut output);
plugins.on_output(self, &mut output);
output
}

View File

@@ -35,13 +35,13 @@ pub trait Plugin: Send + Sync + std::any::Any + 'static {
///
/// Useful to inspect or modify the input.
/// Since this is called outside a pass, don't show ui here. Using `Context::debug_painter` is fine though.
fn input_hook(&mut self, input: &mut RawInput) {}
fn input_hook(&mut self, ctx: &Context, input: &mut RawInput) {}
/// Called just before the output is passed to the backend.
///
/// Useful to inspect or modify the output.
/// Since this is called outside a pass, don't show ui here. Using `Context::debug_painter` is fine though.
fn output_hook(&mut self, output: &mut FullOutput) {}
fn output_hook(&mut self, ctx: &Context, output: &mut FullOutput) {}
/// Called when a widget is created and is under the pointer.
///
@@ -168,17 +168,17 @@ impl PluginsOrdered {
});
}
pub fn on_input(&self, input: &mut RawInput) {
pub fn on_input(&self, ctx: &Context, input: &mut RawInput) {
profiling::scope!("plugins", "on_input");
self.for_each_dyn(|plugin| {
plugin.input_hook(input);
plugin.input_hook(ctx, input);
});
}
pub fn on_output(&self, output: &mut FullOutput) {
pub fn on_output(&self, ctx: &Context, output: &mut FullOutput) {
profiling::scope!("plugins", "on_output");
self.for_each_dyn(|plugin| {
plugin.output_hook(output);
plugin.output_hook(ctx, output);
});
}