Skip to main content

nativeview_abi/runtime/
focus.rs

1//! Focus-traversal direction and flag ABI constants ([`super::NvRuntimeApi::focus_traverse`]).
2
3nativeview_abi_macros::abi_consts! {
4    pub(super) const FOCUS_CONSTS;
5
6    /// `NvRuntimeApi::focus_traverse` direction: next tabbable element in focus order.
7    pub const NV_FOCUS_DIR_NEXT: u8 = 0;
8    /// `NvRuntimeApi::focus_traverse` direction: previous tabbable element in focus order.
9    pub const NV_FOCUS_DIR_PREV: u8 = 1;
10    /// `NvRuntimeApi::focus_traverse` direction: geometric up (spatial policies).
11    pub const NV_FOCUS_DIR_UP: u8 = 2;
12    /// `NvRuntimeApi::focus_traverse` direction: geometric down (spatial policies).
13    pub const NV_FOCUS_DIR_DOWN: u8 = 3;
14    /// `NvRuntimeApi::focus_traverse` direction: geometric left (spatial policies).
15    pub const NV_FOCUS_DIR_LEFT: u8 = 4;
16    /// `NvRuntimeApi::focus_traverse` direction: geometric right (spatial policies).
17    pub const NV_FOCUS_DIR_RIGHT: u8 = 5;
18    /// `NvRuntimeApi::focus_traverse` direction: first tabbable element in active scope.
19    pub const NV_FOCUS_DIR_FIRST: u8 = 6;
20    /// `NvRuntimeApi::focus_traverse` direction: last tabbable element in active scope.
21    pub const NV_FOCUS_DIR_LAST: u8 = 7;
22
23    /// `NvRuntimeApi::focus_traverse` input flags: default behavior (wrap, no scroll-into-view).
24    pub const NV_FOCUS_TRAVERSE_NONE: u32 = 0;
25    /// `NvRuntimeApi::focus_traverse` input flag: do not wrap at start/end outside modals.
26    /// Ignored when a modal is active so modals always trap focus.
27    pub const NV_FOCUS_TRAVERSE_NO_WRAP: u32 = 1 << 0;
28    /// `NvRuntimeApi::focus_traverse` input flag: scroll the resolved target into view and set
29    /// `NV_FOCUS_TRAVERSE_OUT_SCROLLED` when any scroll container moved.
30    pub const NV_FOCUS_TRAVERSE_SCROLL_INTO_VIEW: u32 = 1 << 1;
31    /// Every defined `NvRuntimeApi::focus_traverse` input flag bit; readers reject any other bit.
32    pub const NV_FOCUS_TRAVERSE_MASK: u32 = 0x3;
33
34    /// `NvRuntimeApi::focus_traverse` output flag: active modal owns focus even when
35    /// `out_target == NodeId::NULL`.
36    pub const NV_FOCUS_TRAVERSE_OUT_TRAPPED: u32 = 1 << 0;
37    /// `NvRuntimeApi::focus_traverse` output flag: one or more scroll containers adjusted.
38    pub const NV_FOCUS_TRAVERSE_OUT_SCROLLED: u32 = 1 << 1;
39    /// `NvRuntimeApi::focus_traverse` output flag: wrapped across start/end boundary.
40    pub const NV_FOCUS_TRAVERSE_OUT_WRAPPED: u32 = 1 << 2;
41}
42
43/// Typed focus-traversal movement direction matching `NV_FOCUS_DIR_*`.
44#[repr(u8)]
45#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, nativeview_abi_macros::ReprEnum)]
46pub enum FocusMove {
47    Next = 0,
48    Prev = 1,
49    Up = 2,
50    Down = 3,
51    Left = 4,
52    Right = 5,
53    First = 6,
54    Last = 7,
55}
56
57const _: () = {
58    assert!(FocusMove::Next as u8 == NV_FOCUS_DIR_NEXT);
59    assert!(FocusMove::Prev as u8 == NV_FOCUS_DIR_PREV);
60    assert!(FocusMove::Up as u8 == NV_FOCUS_DIR_UP);
61    assert!(FocusMove::Down as u8 == NV_FOCUS_DIR_DOWN);
62    assert!(FocusMove::Left as u8 == NV_FOCUS_DIR_LEFT);
63    assert!(FocusMove::Right as u8 == NV_FOCUS_DIR_RIGHT);
64    assert!(FocusMove::First as u8 == NV_FOCUS_DIR_FIRST);
65    assert!(FocusMove::Last as u8 == NV_FOCUS_DIR_LAST);
66};
67