mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 14:49:06 -04:00
Replace ui.ctx().foo with ui.foo in a few places (#7774)
Internal code cleanup after * https://github.com/emilk/egui/pull/7770
This commit is contained in:
@@ -51,7 +51,7 @@ impl eframe::App for MyApp {
|
||||
if ui.button("Yes").clicked() {
|
||||
self.show_confirmation_dialog = false;
|
||||
self.allowed_to_close = true;
|
||||
ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
|
||||
ui.send_viewport_cmd(egui::ViewportCommand::Close);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -106,12 +106,11 @@ fn title_bar_ui(ui: &mut egui::Ui, title_bar_rect: eframe::epaint::Rect, title:
|
||||
// Interact with the title bar (drag to move window):
|
||||
if title_bar_response.double_clicked() {
|
||||
let is_maximized = ui.input(|i| i.viewport().maximized.unwrap_or(false));
|
||||
ui.ctx()
|
||||
.send_viewport_cmd(ViewportCommand::Maximized(!is_maximized));
|
||||
ui.send_viewport_cmd(ViewportCommand::Maximized(!is_maximized));
|
||||
}
|
||||
|
||||
if title_bar_response.drag_started_by(PointerButton::Primary) {
|
||||
ui.ctx().send_viewport_cmd(ViewportCommand::StartDrag);
|
||||
ui.send_viewport_cmd(ViewportCommand::StartDrag);
|
||||
}
|
||||
|
||||
ui.scope_builder(
|
||||
@@ -137,7 +136,7 @@ fn close_maximize_minimize(ui: &mut egui::Ui) {
|
||||
.add(Button::new(RichText::new("❌").size(button_height)))
|
||||
.on_hover_text("Close the window");
|
||||
if close_response.clicked() {
|
||||
ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
|
||||
ui.send_viewport_cmd(egui::ViewportCommand::Close);
|
||||
}
|
||||
|
||||
let is_maximized = ui.input(|i| i.viewport().maximized.unwrap_or(false));
|
||||
@@ -146,15 +145,14 @@ fn close_maximize_minimize(ui: &mut egui::Ui) {
|
||||
.add(Button::new(RichText::new("🗗").size(button_height)))
|
||||
.on_hover_text("Restore window");
|
||||
if maximized_response.clicked() {
|
||||
ui.ctx()
|
||||
.send_viewport_cmd(ViewportCommand::Maximized(false));
|
||||
ui.send_viewport_cmd(ViewportCommand::Maximized(false));
|
||||
}
|
||||
} else {
|
||||
let maximized_response = ui
|
||||
.add(Button::new(RichText::new("🗗").size(button_height)))
|
||||
.on_hover_text("Maximize window");
|
||||
if maximized_response.clicked() {
|
||||
ui.ctx().send_viewport_cmd(ViewportCommand::Maximized(true));
|
||||
ui.send_viewport_cmd(ViewportCommand::Maximized(true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +160,6 @@ fn close_maximize_minimize(ui: &mut egui::Ui) {
|
||||
.add(Button::new(RichText::new("🗕").size(button_height)))
|
||||
.on_hover_text("Minimize the window");
|
||||
if minimized_response.clicked() {
|
||||
ui.ctx().send_viewport_cmd(ViewportCommand::Minimized(true));
|
||||
ui.send_viewport_cmd(ViewportCommand::Minimized(true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ impl eframe::App for MyApp {
|
||||
}
|
||||
|
||||
if self.blinky {
|
||||
let now = ui.ctx().input(|i| i.time);
|
||||
let now = ui.input(|i| i.time);
|
||||
let blink = now % 1.0 < 0.5;
|
||||
egui::Frame::new()
|
||||
.inner_margin(3)
|
||||
|
||||
@@ -109,7 +109,7 @@ impl eframe::App for MyApp {
|
||||
}
|
||||
|
||||
if self.blinky {
|
||||
let now = ui.ctx().input(|i| i.time);
|
||||
let now = ui.input(|i| i.time);
|
||||
let blink = now % 1.0 < 0.5;
|
||||
egui::Frame::new()
|
||||
.inner_margin(3)
|
||||
|
||||
@@ -38,7 +38,7 @@ impl eframe::App for Content {
|
||||
}
|
||||
if ctx.input(|i| i.key_down(Key::A)) {
|
||||
self.text.push_str("\nHeld");
|
||||
ui.ctx().request_repaint(); // make sure we note the holding.
|
||||
ui.request_repaint(); // make sure we note the holding.
|
||||
}
|
||||
if ctx.input(|i| i.key_released(Key::A)) {
|
||||
self.text.push_str("\nReleased");
|
||||
|
||||
@@ -65,7 +65,7 @@ impl eframe::App for MyApp {
|
||||
ui.horizontal(|ui| {
|
||||
ui.monospace(cmd);
|
||||
if ui.small_button("📋").clicked() {
|
||||
ui.ctx().copy_text(cmd.into());
|
||||
ui.copy_text(cmd.into());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@ impl eframe::App for MyApp {
|
||||
ui.checkbox(&mut self.keep_repainting, "Keep repainting");
|
||||
if self.keep_repainting {
|
||||
ui.spinner();
|
||||
ui.ctx().request_repaint();
|
||||
ui.request_repaint();
|
||||
} else {
|
||||
ui.label("Repainting on events (e.g. mouse movement)");
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ impl eframe::App for MyApp {
|
||||
|
||||
if ui.button("Close").clicked() {
|
||||
log::info!("Pressed Close button");
|
||||
ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
|
||||
ui.send_viewport_cmd(egui::ViewportCommand::Close);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user