mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-28 21:04:47 +00:00
40 lines
1.5 KiB
Rust
40 lines
1.5 KiB
Rust
#![warn(missing_docs)]
|
|
|
|
//! This module contains the basic datastructures that are exposed to the C API
|
|
|
|
use crate::input::{InputEventResult, MouseEvent};
|
|
use crate::item_tree::{ItemVisitorVTable, TraversalOrder, VisitChildrenResult};
|
|
use crate::layout::LayoutInfo;
|
|
use vtable::*;
|
|
|
|
/// A Component is representing an unit that is allocated together
|
|
#[vtable]
|
|
#[repr(C)]
|
|
pub struct ComponentVTable {
|
|
/// Visit the children of the item at index `index`.
|
|
/// Note that the root item is at index 0, so passing 0 would visit the item under root (the children of root).
|
|
/// If you want to visit the root item, you need to pass -1 as an index.
|
|
pub visit_children_item: extern "C" fn(
|
|
core::pin::Pin<VRef<ComponentVTable>>,
|
|
index: isize,
|
|
order: TraversalOrder,
|
|
visitor: VRefMut<ItemVisitorVTable>,
|
|
) -> VisitChildrenResult,
|
|
|
|
/// Returns the layout info for this component
|
|
pub layout_info: extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>) -> LayoutInfo,
|
|
|
|
/// Will compute the layout of
|
|
pub compute_layout: extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>),
|
|
|
|
/// input event
|
|
pub input_event:
|
|
extern "C" fn(core::pin::Pin<VRef<ComponentVTable>>, MouseEvent) -> InputEventResult,
|
|
}
|
|
|
|
/// Alias for `vtable::VRef<ComponentVTable>` which represent a pointer to a `dyn Component` with
|
|
/// the associated vtable
|
|
pub type ComponentRef<'a> = vtable::VRef<'a, ComponentVTable>;
|
|
|
|
/// Type alias to the commonly use `Pin<VRef<ComponentVTable>>>`
|
|
pub type ComponentRefPin<'a> = core::pin::Pin<ComponentRef<'a>>;
|