mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
kittest: add drag-and-drop helpers (#7690)
This commit is contained in:
@@ -8,9 +8,7 @@ mod builder;
|
|||||||
mod snapshot;
|
mod snapshot;
|
||||||
|
|
||||||
#[cfg(feature = "snapshot")]
|
#[cfg(feature = "snapshot")]
|
||||||
pub use snapshot::*;
|
pub use crate::snapshot::*;
|
||||||
use std::fmt::{Debug, Display, Formatter};
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
mod app_kind;
|
mod app_kind;
|
||||||
mod node;
|
mod node;
|
||||||
@@ -20,19 +18,26 @@ mod texture_to_image;
|
|||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
pub mod wgpu;
|
pub mod wgpu;
|
||||||
|
|
||||||
pub use kittest;
|
// re-exports:
|
||||||
|
pub use {
|
||||||
|
self::{builder::*, node::*, renderer::*},
|
||||||
|
kittest,
|
||||||
|
};
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
fmt::{Debug, Display, Formatter},
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
|
use egui::{
|
||||||
|
Color32, Key, Modifiers, PointerButton, Pos2, Rect, RepaintCause, Shape, Vec2, ViewportId,
|
||||||
|
epaint::{ClippedShape, RectShape},
|
||||||
|
style::ScrollAnimation,
|
||||||
|
};
|
||||||
|
use kittest::Queryable;
|
||||||
|
|
||||||
use crate::app_kind::AppKind;
|
use crate::app_kind::AppKind;
|
||||||
|
|
||||||
pub use builder::*;
|
|
||||||
pub use node::*;
|
|
||||||
pub use renderer::*;
|
|
||||||
|
|
||||||
use egui::epaint::{ClippedShape, RectShape};
|
|
||||||
use egui::style::ScrollAnimation;
|
|
||||||
use egui::{Color32, Key, Modifiers, Pos2, Rect, RepaintCause, Shape, Vec2, ViewportId};
|
|
||||||
use kittest::Queryable;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ExceededMaxStepsError {
|
pub struct ExceededMaxStepsError {
|
||||||
pub max_steps: u64,
|
pub max_steps: u64,
|
||||||
@@ -607,6 +612,32 @@ impl<'a, State> Harness<'a, State> {
|
|||||||
self.key_combination_modifiers(modifiers, &[key]);
|
self.key_combination_modifiers(modifiers, &[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Move mouse cursor to this position.
|
||||||
|
pub fn hover_at(&self, pos: egui::Pos2) {
|
||||||
|
self.event(egui::Event::PointerMoved(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Start dragging from a position.
|
||||||
|
pub fn drag_at(&self, pos: egui::Pos2) {
|
||||||
|
self.event(egui::Event::PointerButton {
|
||||||
|
pos,
|
||||||
|
button: PointerButton::Primary,
|
||||||
|
pressed: true,
|
||||||
|
modifiers: Modifiers::NONE,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Stop dragging and remove cursor.
|
||||||
|
pub fn drop_at(&self, pos: egui::Pos2) {
|
||||||
|
self.event(egui::Event::PointerButton {
|
||||||
|
pos,
|
||||||
|
button: PointerButton::Primary,
|
||||||
|
pressed: false,
|
||||||
|
modifiers: Modifiers::NONE,
|
||||||
|
});
|
||||||
|
self.remove_cursor();
|
||||||
|
}
|
||||||
|
|
||||||
/// Remove the cursor from the screen.
|
/// Remove the cursor from the screen.
|
||||||
///
|
///
|
||||||
/// Will fire a [`egui::Event::PointerGone`] event.
|
/// Will fire a [`egui::Event::PointerGone`] event.
|
||||||
|
|||||||
Reference in New Issue
Block a user