Skip to content

Commit

Permalink
Partial update for 0.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Hirtol committed Feb 16, 2023
1 parent 365a0aa commit 194e9ad
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ default = []
serde = ["dep:serde", "egui/persistence"]

[dependencies]
egui = "0.20"
egui = "0.21"

[dev-dependencies]
eframe = "0.20"
eframe = "0.21"

[dependencies.serde]
version = "1"
Expand Down
20 changes: 1 addition & 19 deletions examples/simple/frame_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,9 @@ impl FrameHistory {
let color = ui.visuals().text_color();
let line_stroke = Stroke::new(1.0, color);

if let Some(pointer_pos) = response.hover_pos() {
let y = pointer_pos.y;
shapes.push(Shape::line_segment(
[pos2(rect.left(), y), pos2(rect.right(), y)],
line_stroke,
));
let cpu_usage = to_screen.inverse().transform_pos(pointer_pos).y;
let text = format!("{:.1} ms", 1e3 * cpu_usage);
shapes.push(Shape::text(
&*ui.fonts(),
pos2(rect.left(), y),
egui::Align2::LEFT_BOTTOM,
text,
TextStyle::Monospace.resolve(ui.style()),
color,
));
}

let circle_color = color;
let radius = 2.0;
let right_side_time = ui.input().time; // Time at right side of screen
let right_side_time = ui.input(|i| i.time); // Time at right side of screen

for (time, cpu_usage) in history.iter() {
let age = (right_side_time - time) as f32;
Expand Down
4 changes: 2 additions & 2 deletions examples/simple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod frame_history;

pub fn main() {
let app = App::default();
eframe::run_native(
let _ = eframe::run_native(
"Mem-Edit Example",
NativeOptions::default(),
Box::new(|_cc| Box::new(app)),
Expand Down Expand Up @@ -83,7 +83,7 @@ impl Memory {
}

fn create_frame_history(ctx: &Context, frame: &Frame, frame_history: &mut FrameHistory) {
frame_history.on_new_frame(ctx.input().time, frame.info().cpu_usage);
frame_history.on_new_frame(ctx.input(|i| i.time), frame.info().cpu_usage);
egui::SidePanel::left("SidePanel").show(ctx, |ui| {
frame_history.ui(ui);
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ impl MemoryEditor {
return;
};

let key_pressed = KEYS.iter().find(|&&k| ctx.input().key_pressed(k));
let key_pressed = KEYS.iter().find(|&&k| ctx.input(|i| i.key_pressed(k)));
if let Some(key) = key_pressed {
let next_address = match key {
ArrowDown => current_address + self.options.column_count,
Expand Down
4 changes: 2 additions & 2 deletions src/option_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ impl MemoryEditor {

// For some reason egui is triggering response.clicked() when we press enter at the moment
// (didn't used to do this). The additional check for not having enter pressed will need to stay until that is fixed.
if response.clicked() && !ui.input().key_pressed(egui::Key::Enter) {
if response.clicked() && !ui.input(|i| i.key_pressed(egui::Key::Enter)) {
self.frame_data.goto_address_string.clear();
}

// If we pressed enter, move to the address
if response.lost_focus() && ui.input().key_pressed(egui::Key::Enter) {
if response.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)) {
let goto_address_string = &mut self.frame_data.goto_address_string;

if goto_address_string.starts_with("0x") || goto_address_string.starts_with("0X") {
Expand Down

0 comments on commit 194e9ad

Please sign in to comment.