mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Add public egui_kittest::Node constructor
This commit is contained in:
@@ -735,10 +735,7 @@ impl<'a, State> Harness<'a, State> {
|
|||||||
|
|
||||||
/// The root node of the test harness.
|
/// The root node of the test harness.
|
||||||
pub fn root(&self) -> Node<'_> {
|
pub fn root(&self) -> Node<'_> {
|
||||||
Node {
|
Node::new(self.kittest.root(), &self.queued_events)
|
||||||
accesskit_node: self.kittest.root(),
|
|
||||||
queue: &self.queued_events,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Spawn a real native eframe window running this harness's app, reusing its [`egui::Context`].
|
/// Spawn a real native eframe window running this harness's app, reusing its [`egui::Context`].
|
||||||
|
|||||||
@@ -4,12 +4,16 @@ use egui::{Modifiers, PointerButton, Pos2, accesskit};
|
|||||||
use kittest::{AccessKitNode, NodeT, debug_fmt_node};
|
use kittest::{AccessKitNode, NodeT, debug_fmt_node};
|
||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
|
|
||||||
pub(crate) enum EventType {
|
/// Modifiers aren't part of [`egui::Event`] and must be handled by the integration, so we need
|
||||||
|
/// an enum to handle these.
|
||||||
|
///
|
||||||
|
/// The most recent [`Self::Modifiers`] should always be passed to [`egui::RawInput`].
|
||||||
|
pub enum EventType {
|
||||||
Event(egui::Event),
|
Event(egui::Event),
|
||||||
Modifiers(Modifiers),
|
Modifiers(Modifiers),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) type EventQueue = Mutex<Vec<EventType>>;
|
pub type EventQueue = Mutex<Vec<EventType>>;
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct Node<'tree> {
|
pub struct Node<'tree> {
|
||||||
@@ -29,14 +33,19 @@ impl<'tree> NodeT<'tree> for Node<'tree> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn new_related(&self, child_node: AccessKitNode<'tree>) -> Self {
|
fn new_related(&self, child_node: AccessKitNode<'tree>) -> Self {
|
||||||
Self {
|
Self::new(child_node, self.queue)
|
||||||
queue: self.queue,
|
|
||||||
accesskit_node: child_node,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Node<'_> {
|
impl Node<'_> {
|
||||||
|
/// Construct a new accesskit node
|
||||||
|
pub fn new(accesskit_node: AccessKitNode<'_>, queue: &EventQueue) -> Self {
|
||||||
|
Self {
|
||||||
|
queue,
|
||||||
|
accesskit_node,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn event(&self, event: egui::Event) {
|
fn event(&self, event: egui::Event) {
|
||||||
self.queue.lock().push(EventType::Event(event));
|
self.queue.lock().push(EventType::Event(event));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user