#open-harmony #harmony-os #experimental #bindings #component #native #ark-ui

xcomponent

Experimental bindings of the OpenHarmonyOS ArkUI XComponent

3 unstable releases

0.1.2 Jun 28, 2024
0.1.0 Jun 27, 2024
0.0.1 Apr 29, 2024

#10 in #open-harmony

41 downloads per month

Apache-2.0

11KB
145 lines

XComponent

Rust bindings to the native XComponent of ArkUI on OpenHarmony.

License

This crate is licensed under the Apache-2.0 license, matching the OpenHarmony OS SDK.


lib.rs:

An abstraction over the OpenHarmony XComponent

Example

pub extern "C" fn on_surface_created_cb(xcomponent: *mut OH_NativeXComponent, window: *mut c_void) {
    let xc = xcomponent::XComponent::new(xcomponent, window).expect("Invalid XC");
    let size = xc.size();
    // do something with the xcomponent ...
}

pub extern "C" fn on_dispatch_touch_event_cb(
    component: *mut OH_NativeXComponent,
    window: *mut c_void,
) {
     let xc = xcomponent::XComponent::new(component, window).unwrap();
     let touch_event = xc.get_touch_event().unwrap();
     // Handle the touch event ....
}

Features

  • log: Outputs error and diagnostic messages via the log crate if enabled.
  • register: Add register_xcomponent_callbacks function to register XComponent callbacks.

Dependencies

~0.2–5MB
~11K SLoC