Skip to content

Commit

Permalink
add setting window position to basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
coderedart committed Feb 24, 2024
1 parent 0d06911 commit 815d9e8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,37 @@ impl EguiOverlay for HelloWorld {
if changed {
glfw_backend.set_window_size(size);
}
// how to change size.
// WARNING: don't use drag value, because window size changing while dragging ui messes things up.
let mut pos = glfw_backend.window_position;
let mut changed = false;
ui.horizontal(|ui| {
ui.label("x: ");
ui.add_enabled(false, DragValue::new(&mut pos[0]));
if ui.button("inc").clicked() {
pos[0] += 10;
changed = true;
}
if ui.button("dec").clicked() {
pos[0] -= 10;
changed = true;
}
});
ui.horizontal(|ui| {
ui.label("y: ");
ui.add_enabled(false, DragValue::new(&mut pos[1]));
if ui.button("inc").clicked() {
pos[1] += 10;
changed = true;
}
if ui.button("dec").clicked() {
pos[1] -= 10;
changed = true;
}
});
if changed {
glfw_backend.window.set_pos(pos[0], pos[1]);
}
});

// here you decide if you want to be passthrough or not.
Expand Down

0 comments on commit 815d9e8

Please sign in to comment.