Skip to main content

ferroui_diagnostics/diagnostics/views/
hot_key_page_view.rs

1//! Port of `Diagnostics/Views/HotKeyPageView.xaml.cs`: the class of the
2//! document `HotKeyPageView.xaml`.
3
4use ferroui_base::input::InputElementImpl;
5use ferroui_base::interactivity::InteractiveImpl;
6use ferroui_base::layout::LayoutableImpl;
7use ferroui_base::{
8    ferro_class, ferro_class_info, ferro_impl_classes, instantiate, FerroObjectImpl, Ref, StyledElementImpl,
9    VisualImpl,
10};
11use ferroui_controls::primitives::TemplatedControlImpl;
12use ferroui_controls::{ContentControlImpl, ControlImpl, UserControl};
13
14/// The view of the hot keys page: the hot keys of the developer tools and
15/// what they do.
16#[repr(C)]
17pub struct HotKeyPageView {
18    base: UserControl,
19}
20
21ferro_class!(HotKeyPageView: UserControl);
22ferro_impl_classes!(
23    HotKeyPageView: FerroObjectImpl,
24    StyledElementImpl,
25    VisualImpl,
26    LayoutableImpl,
27    InteractiveImpl,
28    InputElementImpl,
29    ControlImpl,
30    TemplatedControlImpl,
31    ContentControlImpl
32);
33ferro_class_info!(HotKeyPageView { new: HotKeyPageView::new });
34
35impl HotKeyPageView {
36    /// The URI of the document of the class.
37    pub const DOCUMENT_URI: &'static str = "ferres://FerroUI.Diagnostics/diagnostics/views/HotKeyPageView.xaml";
38
39    pub fn construct() -> Self {
40        Self { base: UserControl::construct() }
41    }
42
43    /// Creates the view and populates it from its document
44    /// (`InitializeComponent()`: the compiled markup of the document, which
45    /// the build of the crate generates).
46    ///
47    /// # Panics
48    /// Panics when the document fails to load (an exception of the
49    /// constructor in the original).
50    pub fn new() -> Ref<Self> {
51        crate::register_types();
52        let this = instantiate(Self::construct());
53        Self::initialize_component(&this);
54        this
55    }
56
57    /// `InitializeComponent()`.
58    fn initialize_component(this: &Ref<Self>) {
59        if let Err(error) = crate::compiled_diagnostics_views_hot_key_page_view::populate(None, this) {
60            panic!("{}: {error}", Self::DOCUMENT_URI);
61        }
62    }
63}