use crate::rendering::IPresentationSource;
use crate::{Ref, Visual};
use std::rc::Rc;
#[derive(Clone)]
pub struct VisualTreeAttachmentEventArgs {
attachment_point: Option<Ref<Visual>>,
presentation_source: Rc<dyn IPresentationSource>,
root_visual: Ref<Visual>,
}
impl VisualTreeAttachmentEventArgs {
pub fn new(attachment_point: Option<Ref<Visual>>, presentation_source: Rc<dyn IPresentationSource>) -> Self {
let root_visual =
presentation_source.root_visual().expect("PresentationSource must have a non-null RootVisual.");
Self { attachment_point, presentation_source, root_visual }
}
pub fn attachment_point(&self) -> Option<&Ref<Visual>> {
self.attachment_point.as_ref()
}
#[deprecated(note = "Use attachment_point")]
pub fn parent(&self) -> Option<&Ref<Visual>> {
self.attachment_point()
}
pub fn presentation_source(&self) -> &Rc<dyn IPresentationSource> {
&self.presentation_source
}
#[deprecated(
note = "This was previously always returning TopLevel. This is no longer guaranteed. Use TopLevel::get_top_level(visual) if you need a TopLevel or root_visual if you are interested in the root of the visual tree."
)]
pub fn root(&self) -> &Ref<Visual> {
&self.root_visual
}
pub fn root_visual(&self) -> &Ref<Visual> {
&self.root_visual
}
pub fn set_root_visual(&mut self, value: Ref<Visual>) {
self.root_visual = value;
}
}
impl PartialEq for VisualTreeAttachmentEventArgs {
fn eq(&self, other: &Self) -> bool {
self.attachment_point == other.attachment_point
&& self.root_visual == other.root_visual
&& std::ptr::addr_eq(Rc::as_ptr(&self.presentation_source), Rc::as_ptr(&other.presentation_source))
}
}