mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -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:
@@ -40,7 +40,7 @@ impl crate::View for DancingStrings {
|
||||
.on_hover_text("Demonstrates how a path can have varying color across its length.");
|
||||
|
||||
Frame::canvas(ui.style()).show(ui, |ui| {
|
||||
ui.ctx().request_repaint();
|
||||
ui.request_repaint();
|
||||
let time = ui.input(|i| i.time);
|
||||
|
||||
let desired_size = ui.available_width() * vec2(1.0, 0.35);
|
||||
|
||||
@@ -304,7 +304,7 @@ impl DemoWindows {
|
||||
self.groups.checkboxes(ui, &mut self.open);
|
||||
ui.separator();
|
||||
if ui.button("Organize windows").clicked() {
|
||||
ui.ctx().memory_mut(|mem| mem.reset_areas());
|
||||
ui.memory_mut(|mem| mem.reset_areas());
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -323,11 +323,11 @@ fn file_menu_button(ui: &mut Ui) {
|
||||
// or else they would only be checked if the "File" menu was actually open!
|
||||
|
||||
if ui.input_mut(|i| i.consume_shortcut(&organize_shortcut)) {
|
||||
ui.ctx().memory_mut(|mem| mem.reset_areas());
|
||||
ui.memory_mut(|mem| mem.reset_areas());
|
||||
}
|
||||
|
||||
if ui.input_mut(|i| i.consume_shortcut(&reset_shortcut)) {
|
||||
ui.ctx().memory_mut(|mem| *mem = Default::default());
|
||||
ui.memory_mut(|mem| *mem = Default::default());
|
||||
}
|
||||
|
||||
ui.menu_button("File", |ui| {
|
||||
@@ -352,7 +352,7 @@ fn file_menu_button(ui: &mut Ui) {
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
ui.ctx().memory_mut(|mem| mem.reset_areas());
|
||||
ui.memory_mut(|mem| mem.reset_areas());
|
||||
}
|
||||
|
||||
if ui
|
||||
@@ -363,7 +363,7 @@ fn file_menu_button(ui: &mut Ui) {
|
||||
.on_hover_text("Forget scroll, positions, sizes etc")
|
||||
.clicked()
|
||||
{
|
||||
ui.ctx().memory_mut(|mem| *mem = Default::default());
|
||||
ui.memory_mut(|mem| *mem = Default::default());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ impl crate::View for FontBook {
|
||||
};
|
||||
|
||||
if ui.add(button).on_hover_ui(tooltip_ui).clicked() {
|
||||
ui.ctx().copy_text(chr.to_string());
|
||||
ui.copy_text(chr.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,12 +541,12 @@ fn ui_stack_demo(ui: &mut Ui) {
|
||||
let response = ui.label(format!("{:?}", node.id));
|
||||
|
||||
if response.hovered() {
|
||||
ui.ctx().debug_painter().debug_rect(
|
||||
ui.debug_painter().debug_rect(
|
||||
node.max_rect,
|
||||
Color32::GREEN,
|
||||
"max_rect",
|
||||
);
|
||||
ui.ctx().debug_painter().circle_filled(
|
||||
ui.debug_painter().circle_filled(
|
||||
node.min_rect.min,
|
||||
2.0,
|
||||
Color32::RED,
|
||||
|
||||
@@ -149,7 +149,7 @@ impl crate::View for Modals {
|
||||
*user_modal_open = false;
|
||||
} else {
|
||||
*save_progress = Some(progress + 0.003);
|
||||
ui.ctx().request_repaint();
|
||||
ui.request_repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ impl MultiTouch {
|
||||
|
||||
let delay = 0.5;
|
||||
if time_since_last_touch < delay {
|
||||
ui.ctx().request_repaint();
|
||||
ui.request_repaint();
|
||||
} else {
|
||||
// seconds after which half the amount of zoom/rotation will be reverted:
|
||||
let half_life =
|
||||
@@ -157,7 +157,7 @@ impl MultiTouch {
|
||||
self.zoom = 1. + ((self.zoom - 1.) * half_life_factor);
|
||||
self.rotation *= half_life_factor;
|
||||
self.translation *= half_life_factor;
|
||||
ui.ctx().request_repaint();
|
||||
ui.request_repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,8 +73,7 @@ impl PaintBezier {
|
||||
ui.collapsing("Global tessellation options", |ui| {
|
||||
let mut tessellation_options = ui.ctx().tessellation_options(|to| *to);
|
||||
tessellation_options.ui(ui);
|
||||
ui.ctx()
|
||||
.tessellation_options_mut(|to| *to = tessellation_options);
|
||||
ui.tessellation_options_mut(|to| *to = tessellation_options);
|
||||
});
|
||||
|
||||
ui.radio_value(&mut self.degree, 3, "Quadratic Bézier");
|
||||
|
||||
@@ -43,12 +43,11 @@ impl crate::View for Screenshot {
|
||||
let capture = ui.button("📷 Take Screenshot").clicked();
|
||||
ui.checkbox(&mut self.continuous, "Capture continuously");
|
||||
if capture || self.continuous {
|
||||
ui.ctx()
|
||||
.send_viewport_cmd(ViewportCommand::Screenshot(UserData::default()));
|
||||
ui.send_viewport_cmd(ViewportCommand::Screenshot(UserData::default()));
|
||||
}
|
||||
});
|
||||
|
||||
let image = ui.ctx().input(|i| {
|
||||
let image = ui.input(|i| {
|
||||
i.events
|
||||
.iter()
|
||||
.filter_map(|e| {
|
||||
|
||||
@@ -388,6 +388,6 @@ impl crate::View for ScrollStickTo {
|
||||
);
|
||||
|
||||
self.n_items += 1;
|
||||
ui.ctx().request_repaint();
|
||||
ui.request_repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ impl crate::View for ClipboardTest {
|
||||
.horizontal(|ui| {
|
||||
let text_edit_response = ui.text_edit_singleline(&mut self.text);
|
||||
if ui.button("📋").clicked() {
|
||||
ui.ctx().copy_text(self.text.clone());
|
||||
ui.copy_text(self.text.clone());
|
||||
}
|
||||
text_edit_response
|
||||
})
|
||||
@@ -48,7 +48,7 @@ impl crate::View for ClipboardTest {
|
||||
] {
|
||||
if ui.button(name).clicked() {
|
||||
// Next frame we should get a copy/cut/paste-event…
|
||||
ui.ctx().send_viewport_cmd(cmd);
|
||||
ui.send_viewport_cmd(cmd);
|
||||
|
||||
// …that should en up here:
|
||||
text_edit_response.request_focus();
|
||||
@@ -69,7 +69,7 @@ impl crate::View for ClipboardTest {
|
||||
ui.ctx().try_load_image(&uri, Default::default())
|
||||
&& ui.button("📋").clicked()
|
||||
{
|
||||
ui.ctx().copy_image((*image).clone());
|
||||
ui.copy_image((*image).clone());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ impl crate::Demo for IdTest {
|
||||
impl crate::View for IdTest {
|
||||
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||
// Make sure the warnings are on (by default they are only on in debug builds).
|
||||
ui.ctx().options_mut(|opt| opt.warn_on_id_clash = true);
|
||||
ui.options_mut(|opt| opt.warn_on_id_clash = true);
|
||||
|
||||
ui.heading("Name collision example");
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ impl crate::View for TextEditDemo {
|
||||
.cursor
|
||||
.set_char_range(Some(egui::text::CCursorRange::one(ccursor)));
|
||||
state.store(ui.ctx(), text_edit_id);
|
||||
ui.ctx().memory_mut(|mem| mem.request_focus(text_edit_id)); // give focus back to the [`TextEdit`].
|
||||
ui.memory_mut(|mem| mem.request_focus(text_edit_id)); // give focus back to the [`TextEdit`].
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ impl crate::View for TextEditDemo {
|
||||
.cursor
|
||||
.set_char_range(Some(egui::text::CCursorRange::one(ccursor)));
|
||||
state.store(ui.ctx(), text_edit_id);
|
||||
ui.ctx().memory_mut(|mem| mem.request_focus(text_edit_id)); // give focus back to the [`TextEdit`].
|
||||
ui.memory_mut(|mem| mem.request_focus(text_edit_id)); // give focus back to the [`TextEdit`].
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ impl crate::View for TextLayoutDemo {
|
||||
|
||||
use egui::text::LayoutJob;
|
||||
|
||||
let pixels_per_point = ui.ctx().pixels_per_point();
|
||||
let pixels_per_point = ui.pixels_per_point();
|
||||
let points_per_pixel = 1.0 / pixels_per_point;
|
||||
|
||||
ui.vertical_centered(|ui| {
|
||||
|
||||
@@ -69,6 +69,6 @@ impl crate::View for UndoRedoDemo {
|
||||
});
|
||||
|
||||
self.undoer
|
||||
.feed_state(ui.ctx().input(|input| input.time), &self.state);
|
||||
.feed_state(ui.input(|input| input.time), &self.state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ fn pixel_test_strokes(ui: &mut Ui) {
|
||||
egui::Color32::BLACK
|
||||
};
|
||||
|
||||
let pixels_per_point = ui.ctx().pixels_per_point();
|
||||
let pixels_per_point = ui.pixels_per_point();
|
||||
|
||||
for thickness_pixels in 1..=3 {
|
||||
let thickness_pixels = thickness_pixels as f32;
|
||||
@@ -506,7 +506,7 @@ fn pixel_test_squares(ui: &mut Ui) {
|
||||
egui::Color32::BLACK
|
||||
};
|
||||
|
||||
let pixels_per_point = ui.ctx().pixels_per_point();
|
||||
let pixels_per_point = ui.pixels_per_point();
|
||||
|
||||
let num_squares = (pixels_per_point * 10.0).round().max(10.0) as u32;
|
||||
let size_pixels = vec2(
|
||||
@@ -532,7 +532,7 @@ fn pixel_test_squares(ui: &mut Ui) {
|
||||
}
|
||||
|
||||
fn pixel_test_lines(ui: &mut Ui) {
|
||||
let pixels_per_point = ui.ctx().pixels_per_point();
|
||||
let pixels_per_point = ui.pixels_per_point();
|
||||
let n = (96.0 * pixels_per_point) as usize;
|
||||
|
||||
ui.label("The lines should be exactly one physical pixel wide, one physical pixel apart.");
|
||||
|
||||
Reference in New Issue
Block a user