pan_core/traits.rs
1// Copyright (c) 2023 Xu Shaohua <shaohua@biofan.org>. All rights reserved.
2// Use of this source is governed by Apache-2.0 License that can be found
3// in the LICENSE file.
4
5use crate::types::{
6 ComputePositionConfig, ComputePositionReturn, MiddlewareReturn, MiddlewareState,
7};
8
9/// Impl Platform trait to support new platform environment.
10pub trait Platform {
11 fn dimensions(&self) -> i32;
12
13 /// Returns true if layout direction is Right-To-Left.
14 fn is_rtl(&self) -> bool;
15
16 fn clipping_rect(&mut self) -> (f32, f32);
17}
18
19pub trait Middleware {
20 fn name(&self) -> &str;
21 fn run(&mut self, state: &MiddlewareState) -> MiddlewareReturn;
22}
23
24pub type ComputePosition = fn(config: &ComputePositionConfig) -> ComputePositionReturn;