docs: explain Tessera modules and execution flows in Chinese
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
//! 宿主管理工具和页面列表的唯一侧栏。展开时占据页面左侧空间,折叠后只保留展开按钮区域。
|
||||
//! 页面标题和身份来自发布帧;实际切换/关闭通过带版本的事件进入运行时,不在绘制时修改业务对象。
|
||||
//!
|
||||
//! The only persistent host toolbar. A collapsed sidebar owns just its toggle
|
||||
//! and the native traffic-light safe area; the page owns the rest of the window.
|
||||
use crate::{
|
||||
@@ -15,6 +18,7 @@ pub const HEADER: f32 = 40.0;
|
||||
pub const CONTROLS: f32 = if cfg!(target_os = "macos") { 86.0 } else { 0.0 };
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
/// 侧栏释放激活后要执行的管理动作,绘制本身只登记它。
|
||||
pub enum Action {
|
||||
Toggle,
|
||||
NewPage,
|
||||
@@ -23,6 +27,7 @@ pub enum Action {
|
||||
Close(u64),
|
||||
}
|
||||
|
||||
/// 侧栏开合、控件交互和本帧目标集合,决定实际占用页面宽度。
|
||||
pub struct State {
|
||||
pub open: bool,
|
||||
pub interaction: Interaction,
|
||||
@@ -31,6 +36,7 @@ pub struct State {
|
||||
}
|
||||
|
||||
impl Default for State {
|
||||
/// 建立类型约定的初始值,供尚未发布或尚未交互的状态使用。
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
open: true,
|
||||
@@ -42,10 +48,12 @@ impl Default for State {
|
||||
}
|
||||
|
||||
impl State {
|
||||
/// 返回展开侧栏占据的逻辑宽度,折叠时页面收回这部分空间。
|
||||
pub fn left(&self) -> f32 {
|
||||
if self.open { WIDTH } else { 0.0 }
|
||||
}
|
||||
|
||||
/// 判断指针是否落入宿主侧栏/展开按钮区域,保护页面输入边界。
|
||||
pub fn covers(&self, point: Point) -> bool {
|
||||
if self.open {
|
||||
point.x >= 0.0 && point.x < WIDTH
|
||||
@@ -54,6 +62,7 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
/// 绘制工具入口、页面列表和展开控制,同时登记稳定的交互目标。
|
||||
pub fn draw(
|
||||
&mut self,
|
||||
tabs: &[Tab],
|
||||
|
||||
Reference in New Issue
Block a user