mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Merge branch 'emilk:main' into main
This commit is contained in:
@@ -319,7 +319,9 @@ pub struct InputState {
|
|||||||
/// Which modifier keys are down at the start of the frame?
|
/// Which modifier keys are down at the start of the frame?
|
||||||
pub modifiers: Modifiers,
|
pub modifiers: Modifiers,
|
||||||
|
|
||||||
// The keys that are currently being held down.
|
/// The keys that are currently being held down.
|
||||||
|
///
|
||||||
|
/// Keys released this frame are NOT considered down.
|
||||||
pub keys_down: HashSet<Key>,
|
pub keys_down: HashSet<Key>,
|
||||||
|
|
||||||
/// In-order events received this frame
|
/// In-order events received this frame
|
||||||
@@ -765,6 +767,8 @@ impl InputState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Is the given key currently held down?
|
/// Is the given key currently held down?
|
||||||
|
///
|
||||||
|
/// Keys released this frame are NOT considered down.
|
||||||
pub fn key_down(&self, desired_key: Key) -> bool {
|
pub fn key_down(&self, desired_key: Key) -> bool {
|
||||||
self.keys_down.contains(&desired_key)
|
self.keys_down.contains(&desired_key)
|
||||||
}
|
}
|
||||||
@@ -1018,6 +1022,7 @@ pub struct PointerState {
|
|||||||
/// Used for calculating velocity of pointer.
|
/// Used for calculating velocity of pointer.
|
||||||
pos_history: History<Pos2>,
|
pos_history: History<Pos2>,
|
||||||
|
|
||||||
|
/// Buttons currently down, excluding those released this frame.
|
||||||
down: [bool; NUM_POINTER_BUTTONS],
|
down: [bool; NUM_POINTER_BUTTONS],
|
||||||
|
|
||||||
/// Where did the current click/drag originate?
|
/// Where did the current click/drag originate?
|
||||||
@@ -1405,6 +1410,8 @@ impl PointerState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Is any pointer button currently down?
|
/// Is any pointer button currently down?
|
||||||
|
///
|
||||||
|
/// Buttons released this frame are NOT considered down.
|
||||||
pub fn any_down(&self) -> bool {
|
pub fn any_down(&self) -> bool {
|
||||||
self.down.iter().any(|&down| down)
|
self.down.iter().any(|&down| down)
|
||||||
}
|
}
|
||||||
@@ -1460,6 +1467,8 @@ impl PointerState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Is this button currently down?
|
/// Is this button currently down?
|
||||||
|
///
|
||||||
|
/// Buttons released this frame are NOT considered down.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn button_down(&self, button: PointerButton) -> bool {
|
pub fn button_down(&self, button: PointerButton) -> bool {
|
||||||
self.down[button as usize]
|
self.down[button as usize]
|
||||||
@@ -1516,18 +1525,24 @@ impl PointerState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Is the primary button currently down?
|
/// Is the primary button currently down?
|
||||||
|
///
|
||||||
|
/// Buttons released this frame are NOT considered down.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn primary_down(&self) -> bool {
|
pub fn primary_down(&self) -> bool {
|
||||||
self.button_down(PointerButton::Primary)
|
self.button_down(PointerButton::Primary)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the secondary button currently down?
|
/// Is the secondary button currently down?
|
||||||
|
///
|
||||||
|
/// Buttons released this frame are NOT considered down.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn secondary_down(&self) -> bool {
|
pub fn secondary_down(&self) -> bool {
|
||||||
self.button_down(PointerButton::Secondary)
|
self.button_down(PointerButton::Secondary)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is the middle button currently down?
|
/// Is the middle button currently down?
|
||||||
|
///
|
||||||
|
/// Buttons released this frame are NOT considered down.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn middle_down(&self) -> bool {
|
pub fn middle_down(&self) -> bool {
|
||||||
self.button_down(PointerButton::Middle)
|
self.button_down(PointerButton::Middle)
|
||||||
|
|||||||
@@ -721,11 +721,14 @@ impl<State> Harness<'_, State> {
|
|||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
// Close temp file so it isn't locked when `open` tries to launch it (on Windows)
|
||||||
|
let path = temp_file.into_temp_path();
|
||||||
|
|
||||||
#[expect(clippy::print_stdout)]
|
#[expect(clippy::print_stdout)]
|
||||||
{
|
{
|
||||||
println!("Wrote debug snapshot to: {}", path.display());
|
println!("Wrote debug snapshot to: {}", path.display());
|
||||||
}
|
}
|
||||||
let result = open::that(path);
|
let result = open::that(&path);
|
||||||
if let Err(err) = result {
|
if let Err(err) = result {
|
||||||
#[expect(clippy::print_stderr)]
|
#[expect(clippy::print_stderr)]
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user