mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
Merge branch 'main' into accesskit-subtrees
This commit is contained in:
@@ -1066,7 +1066,7 @@ impl CentralPanel {
|
||||
id,
|
||||
UiBuilder::new()
|
||||
.layer_id(LayerId::background())
|
||||
.max_rect(ctx.available_rect().round_ui()),
|
||||
.max_rect(ctx.available_rect()),
|
||||
);
|
||||
panel_ui.set_clip_rect(ctx.content_rect());
|
||||
|
||||
|
||||
@@ -1198,10 +1198,9 @@ impl Prepared {
|
||||
// Clear scroll delta so no parent scroll will use it:
|
||||
ui.input_mut(|input| {
|
||||
if always_scroll_enabled_direction {
|
||||
input.smooth_scroll_delta()[0] = 0.0;
|
||||
input.smooth_scroll_delta()[1] = 0.0;
|
||||
input.smooth_scroll_delta = Vec2::ZERO;
|
||||
} else {
|
||||
input.smooth_scroll_delta()[d] = 0.0;
|
||||
input.smooth_scroll_delta[d] = 0.0;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -798,7 +798,7 @@ impl Context {
|
||||
Id::new((ctx.viewport_id(), "__top_ui")),
|
||||
UiBuilder::new()
|
||||
.layer_id(LayerId::background())
|
||||
.max_rect(ctx.available_rect().round_ui()),
|
||||
.max_rect(ctx.available_rect()),
|
||||
);
|
||||
|
||||
{
|
||||
|
||||
@@ -319,7 +319,9 @@ pub struct InputState {
|
||||
/// Which modifier keys are down at the start of the frame?
|
||||
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>,
|
||||
|
||||
/// In-order events received this frame
|
||||
@@ -765,6 +767,8 @@ impl InputState {
|
||||
}
|
||||
|
||||
/// Is the given key currently held down?
|
||||
///
|
||||
/// Keys released this frame are NOT considered down.
|
||||
pub fn key_down(&self, desired_key: Key) -> bool {
|
||||
self.keys_down.contains(&desired_key)
|
||||
}
|
||||
@@ -1020,6 +1024,7 @@ pub struct PointerState {
|
||||
/// Used for calculating velocity of pointer.
|
||||
pos_history: History<Pos2>,
|
||||
|
||||
/// Buttons currently down, excluding those released this frame.
|
||||
down: [bool; NUM_POINTER_BUTTONS],
|
||||
|
||||
/// Where did the current click/drag originate?
|
||||
@@ -1407,6 +1412,8 @@ impl PointerState {
|
||||
}
|
||||
|
||||
/// Is any pointer button currently down?
|
||||
///
|
||||
/// Buttons released this frame are NOT considered down.
|
||||
pub fn any_down(&self) -> bool {
|
||||
self.down.iter().any(|&down| down)
|
||||
}
|
||||
@@ -1462,6 +1469,8 @@ impl PointerState {
|
||||
}
|
||||
|
||||
/// Is this button currently down?
|
||||
///
|
||||
/// Buttons released this frame are NOT considered down.
|
||||
#[inline(always)]
|
||||
pub fn button_down(&self, button: PointerButton) -> bool {
|
||||
self.down[button as usize]
|
||||
@@ -1518,18 +1527,24 @@ impl PointerState {
|
||||
}
|
||||
|
||||
/// Is the primary button currently down?
|
||||
///
|
||||
/// Buttons released this frame are NOT considered down.
|
||||
#[inline(always)]
|
||||
pub fn primary_down(&self) -> bool {
|
||||
self.button_down(PointerButton::Primary)
|
||||
}
|
||||
|
||||
/// Is the secondary button currently down?
|
||||
///
|
||||
/// Buttons released this frame are NOT considered down.
|
||||
#[inline(always)]
|
||||
pub fn secondary_down(&self) -> bool {
|
||||
self.button_down(PointerButton::Secondary)
|
||||
}
|
||||
|
||||
/// Is the middle button currently down?
|
||||
///
|
||||
/// Buttons released this frame are NOT considered down.
|
||||
#[inline(always)]
|
||||
pub fn middle_down(&self) -> bool {
|
||||
self.button_down(PointerButton::Middle)
|
||||
|
||||
@@ -685,7 +685,7 @@ pub fn __run_test_ctx(mut run_ui: impl FnMut(&Context)) {
|
||||
}
|
||||
|
||||
/// For use in tests; especially doctests.
|
||||
pub fn __run_test_ui(add_contents: impl Fn(&mut Ui)) {
|
||||
pub fn __run_test_ui(mut add_contents: impl FnMut(&mut Ui)) {
|
||||
let ctx = Context::default();
|
||||
ctx.set_fonts(FontDefinitions::empty()); // prevent fonts from being loaded (save CPU time)
|
||||
let _ = ctx.run_ui(Default::default(), |ui| {
|
||||
|
||||
@@ -543,22 +543,19 @@ impl Focus {
|
||||
..
|
||||
} = event
|
||||
&& let Some(cardinality) = match key {
|
||||
crate::Key::ArrowUp => Some(FocusDirection::Up),
|
||||
crate::Key::ArrowRight => Some(FocusDirection::Right),
|
||||
crate::Key::ArrowDown => Some(FocusDirection::Down),
|
||||
crate::Key::ArrowLeft => Some(FocusDirection::Left),
|
||||
crate::Key::ArrowUp if !modifiers.any() => Some(FocusDirection::Up),
|
||||
crate::Key::ArrowRight if !modifiers.any() => Some(FocusDirection::Right),
|
||||
crate::Key::ArrowDown if !modifiers.any() => Some(FocusDirection::Down),
|
||||
crate::Key::ArrowLeft if !modifiers.any() => Some(FocusDirection::Left),
|
||||
|
||||
crate::Key::Tab => {
|
||||
if modifiers.shift {
|
||||
Some(FocusDirection::Previous)
|
||||
} else {
|
||||
Some(FocusDirection::Next)
|
||||
}
|
||||
}
|
||||
crate::Key::Escape => {
|
||||
crate::Key::Tab if !modifiers.any() => Some(FocusDirection::Next),
|
||||
crate::Key::Tab if modifiers.shift_only() => Some(FocusDirection::Previous),
|
||||
|
||||
crate::Key::Escape if !modifiers.any() => {
|
||||
self.focused_widget = None;
|
||||
Some(FocusDirection::None)
|
||||
}
|
||||
|
||||
_ => None,
|
||||
}
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::{Layout, Painter, Pos2, Rect, Region, Vec2, grid, vec2};
|
||||
use emath::GuiRounding as _;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
use crate::{Align2, Color32, Stroke};
|
||||
@@ -92,6 +93,7 @@ impl Placer {
|
||||
} else {
|
||||
self.layout.available_rect_before_wrap(&self.region)
|
||||
}
|
||||
.round_ui()
|
||||
}
|
||||
|
||||
/// Amount of space available for a widget.
|
||||
|
||||
@@ -54,8 +54,8 @@ impl UiBuilder {
|
||||
///
|
||||
/// This is a shortcut for `.id_salt(my_id).global_scope(true)`.
|
||||
#[inline]
|
||||
pub fn id(mut self, id: impl Hash) -> Self {
|
||||
self.id_salt = Some(Id::new(id));
|
||||
pub fn id(mut self, id: Id) -> Self {
|
||||
self.id_salt = Some(id);
|
||||
self.global_scope = true;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:604f716e687fc26abba92769fe2dae75d850b18598d2e8a9524451ab0f760251
|
||||
size 65403
|
||||
oid sha256:56b44d26946770c0878e11e3197633697ad339a7e8fcffe7279a6b4c45cd3582
|
||||
size 65384
|
||||
|
||||
@@ -721,11 +721,14 @@ impl<State> Harness<'_, State> {
|
||||
})
|
||||
.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)]
|
||||
{
|
||||
println!("Wrote debug snapshot to: {}", path.display());
|
||||
}
|
||||
let result = open::that(path);
|
||||
let result = open::that(&path);
|
||||
if let Err(err) = result {
|
||||
#[expect(clippy::print_stderr)]
|
||||
{
|
||||
@@ -856,6 +859,7 @@ impl From<SnapshotResults> for Vec<SnapshotError> {
|
||||
}
|
||||
|
||||
impl Drop for SnapshotResults {
|
||||
#[track_caller]
|
||||
fn drop(&mut self) {
|
||||
// Don't panic if we are already panicking (the test probably failed for another reason)
|
||||
if std::thread::panicking() {
|
||||
|
||||
Reference in New Issue
Block a user