#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RenderingMode {
Native,
Custom,
Hybrid,
}
#[derive(Debug, Clone)]
pub struct TranslationContract {
pub cvkg_type: &'static str,
pub platform_type: &'static str,
pub rendering_mode: RenderingMode,
pub native_accessibility: bool,
}
pub struct TranslationContractRegistry {
contracts: Vec<TranslationContract>,
}
impl TranslationContractRegistry {
pub fn new() -> Self {
Self {
contracts: vec![
TranslationContract {
cvkg_type: "Button",
platform_type: "NSButton/Button/GTKButton",
rendering_mode: RenderingMode::Native,
native_accessibility: true,
},
TranslationContract {
cvkg_type: "TextInput",
platform_type: "NSTextField/TextBox/GTKEntry",
rendering_mode: RenderingMode::Native,
native_accessibility: true,
},
TranslationContract {
cvkg_type: "Canvas",
platform_type: "NSView/HWND/GtkDrawingArea",
rendering_mode: RenderingMode::Custom,
native_accessibility: false,
},
TranslationContract {
cvkg_type: "TreeView",
platform_type: "NSTableView/TreeView/GTKTreeView",
rendering_mode: RenderingMode::Hybrid,
native_accessibility: true,
},
],
}
}
pub fn find(&self, cvkg_type: &str) -> Option<&TranslationContract> {
self.contracts.iter().find(|c| c.cvkg_type == cvkg_type)
}
}
impl Default for TranslationContractRegistry {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SyncDirection {
CvkgToNative,
NativeToCvkg,
Bidirectional,
}
#[derive(Debug, Clone)]
pub struct StateSyncContract {
pub widget_type: &'static str,
pub direction: SyncDirection,
pub debounce: bool,
pub debounce_ms: u64,
}
pub struct StateSyncRegistry {
contracts: Vec<StateSyncContract>,
}
impl StateSyncRegistry {
pub fn new() -> Self {
Self {
contracts: vec![
StateSyncContract {
widget_type: "Button",
direction: SyncDirection::Bidirectional,
debounce: false,
debounce_ms: 0,
},
StateSyncContract {
widget_type: "TextInput",
direction: SyncDirection::Bidirectional,
debounce: true,
debounce_ms: 50,
},
StateSyncContract {
widget_type: "Slider",
direction: SyncDirection::Bidirectional,
debounce: true,
debounce_ms: 16,
},
StateSyncContract {
widget_type: "Checkbox",
direction: SyncDirection::Bidirectional,
debounce: false,
debounce_ms: 0,
},
],
}
}
pub fn find(&self, widget_type: &str) -> Option<&StateSyncContract> {
self.contracts.iter().find(|c| c.widget_type == widget_type)
}
}
impl Default for StateSyncRegistry {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone, Copy)]
pub struct WidgetVirtualizationConfig {
pub buffer_size: usize,
pub recycle_handles: bool,
pub max_active_handles: usize,
}
impl Default for WidgetVirtualizationConfig {
fn default() -> Self {
Self {
buffer_size: 5,
recycle_handles: true,
max_active_handles: 100,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SemanticRoleMapping {
pub role: accesskit::Role,
pub mac_ax_role: &'static str,
pub win_uia_control_type: &'static str,
pub linux_atk_role: &'static str,
}
pub struct SemanticRoleRegistry {
mappings: Vec<SemanticRoleMapping>,
}
impl SemanticRoleRegistry {
pub fn new() -> Self {
Self {
mappings: vec![
SemanticRoleMapping {
role: accesskit::Role::Button,
mac_ax_role: "AXButton",
win_uia_control_type: "UIA_ButtonControlTypeId",
linux_atk_role: "ATK_ROLE_PUSH_BUTTON",
},
SemanticRoleMapping {
role: accesskit::Role::TextInput,
mac_ax_role: "AXTextField",
win_uia_control_type: "UIA_EditControlTypeId",
linux_atk_role: "ATK_ROLE_ENTRY",
},
SemanticRoleMapping {
role: accesskit::Role::CheckBox,
mac_ax_role: "AXCheckBox",
win_uia_control_type: "UIA_CheckBoxControlTypeId",
linux_atk_role: "ATK_ROLE_CHECK_BOX",
},
SemanticRoleMapping {
role: accesskit::Role::Slider,
mac_ax_role: "AXSlider",
win_uia_control_type: "UIA_SliderControlTypeId",
linux_atk_role: "ATK_ROLE_SLIDER",
},
SemanticRoleMapping {
role: accesskit::Role::Label,
mac_ax_role: "AXStaticText",
win_uia_control_type: "UIA_TextControlTypeId",
linux_atk_role: "ATK_ROLE_LABEL",
},
],
}
}
pub fn find(&self, role: accesskit::Role) -> Option<&SemanticRoleMapping> {
self.mappings.iter().find(|m| m.role == role)
}
}
impl Default for SemanticRoleRegistry {
fn default() -> Self {
Self::new()
}
}