pub struct XComponent(/* private fields */);Expand description
Accept XComponent with env and exports
§Example
#[module_exports]
pub fn init(exports: Object, env: Env) -> Result<()> {
let xcomponent = XComponent::init(env, exports)?;
Ok(())
}Implementations§
Source§impl XComponent
impl XComponent
pub fn init(env: Env, exports: Object<'_>) -> Result<Self>
Sourcepub fn raw(&self) -> *mut OH_NativeXComponent
pub fn raw(&self) -> *mut OH_NativeXComponent
get raw point
pub fn set_frame_rate(&self, min: i32, max: i32, expected: i32) -> Result<()>
Sourcepub fn register_callback(&self) -> Result<()>
pub fn register_callback(&self) -> Result<()>
Register callbacks
For multi-mode, it will use hashmap to store all of your callbacks closure.
This may cause xcomponent being slower, if you want to avoid this.
You can disable feature with callbacks and use register_native_callback
Sourcepub unsafe fn register_native_callback(
&self,
callbacks: Box<OH_NativeXComponent_Callback>,
) -> Result<()>
pub unsafe fn register_native_callback( &self, callbacks: Box<OH_NativeXComponent_Callback>, ) -> Result<()>
Use ffi to register callbacks directly.
Sourcepub fn size(&self, window: WindowRaw) -> Result<XComponentSize>
pub fn size(&self, window: WindowRaw) -> Result<XComponentSize>
Get current XComponent’s size info include width and height.
Sourcepub fn offset(&self, window: WindowRaw) -> Result<XComponentOffset>
pub fn offset(&self, window: WindowRaw) -> Result<XComponentOffset>
Get the offset of the surface held by the current XComponent.
pub fn on_frame_callback( &self, cb: fn(XComponentRaw, u64, u64) -> Result<()>, ) -> Result<()>
pub fn on_surface_changed(&self, cb: fn(XComponentRaw, WindowRaw) -> Result<()>)
pub fn on_surface_created(&self, cb: fn(XComponentRaw, WindowRaw) -> Result<()>)
pub fn on_surface_destroyed( &self, cb: fn(XComponentRaw, WindowRaw) -> Result<()>, )
pub fn on_touch_event( &self, cb: fn(XComponentRaw, WindowRaw, TouchEventData) -> Result<()>, )
Auto Trait Implementations§
impl Freeze for XComponent
impl RefUnwindSafe for XComponent
impl !Send for XComponent
impl !Sync for XComponent
impl Unpin for XComponent
impl UnsafeUnpin for XComponent
impl UnwindSafe for XComponent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more