use super::tree::LayoutNodeId;
use crate::types::WidgetId;
macro_rules! node_handle {
($name:ident, $doc:expr) => {
#[doc = $doc]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct $name(pub LayoutNodeId);
impl From<$name> for LayoutNodeId {
fn from(h: $name) -> Self {
h.0
}
}
impl AsRef<LayoutNodeId> for $name {
fn as_ref(&self) -> &LayoutNodeId {
&self.0
}
}
};
}
node_handle!(ModalNode, "Typed handle for a modal composite node.");
node_handle!(PopupNode, "Typed handle for a popup composite node.");
node_handle!(DropdownNode, "Typed handle for a dropdown composite node.");
node_handle!(ContextMenuNode, "Typed handle for a context menu composite node.");
node_handle!(SidebarNode, "Typed handle for a sidebar composite node.");
node_handle!(PanelNode, "Typed handle for a panel composite node.");
node_handle!(ToolbarNode, "Typed handle for a toolbar composite node.");
node_handle!(ChromeNode, "Typed handle for a chrome composite node.");
node_handle!(BlackboxPanelNode, "Typed handle for a blackbox panel composite node.");
macro_rules! state_handle {
($name:ident, $doc:expr) => {
#[doc = $doc]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct $name {
pub(crate) id: WidgetId,
}
impl $name {
pub fn id_str(&self) -> &str {
self.id.as_str()
}
}
};
}
state_handle!(ModalHandle, "Opaque handle to a modal composite owned by LayoutManager.");
state_handle!(PopupHandle, "Opaque handle to a popup composite owned by LayoutManager.");
state_handle!(DropdownHandle, "Opaque handle to a dropdown composite owned by LayoutManager.");
state_handle!(ToolbarHandle, "Opaque handle to a toolbar composite owned by LayoutManager.");
state_handle!(SidebarHandle, "Opaque handle to a sidebar composite owned by LayoutManager.");
state_handle!(ContextMenuHandle, "Opaque handle to a context menu composite owned by LayoutManager.");
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OverlayHandle {
Modal(ModalHandle),
Popup(PopupHandle),
Dropdown(DropdownHandle),
ContextMenu(ContextMenuHandle),
Other {
overlay_id: WidgetId,
kind: Option<super::types::OverlayKind>,
},
}