1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! # Layout System - taffyレイアウトエンジン統合と配置計算
//!
//! このモジュールは、taffyレイアウトエンジンとの統合、および階層的な配置計算を提供します。
//!
//! ## サブモジュール構成
//!
//! - **`taffy`**: taffyエンジン連携 (`TaffyStyle`, `TaffyComputedLayout`)
//! - **`metrics`**: レイアウトメトリクス (`Size`, `Offset`, `LayoutScale`, `TextLayoutMetrics`)
//! - **`arrangement`**: 配置情報コンポーネント (`Arrangement`, `GlobalArrangement`, `ArrangementTreeChanged`)
//! - **`rect`**: 矩形操作ユーティリティ (`Rect`, `D2DRectExt`, `transform_rect_axis_aligned`)
//! - **`systems`**: 配置伝播システム関数 (`sync_simple_arrangements`, `propagate_global_arrangements`)
//!
//! ## 主要コンポーネント
//!
//! ### Arrangement - ローカル配置
//! 親エンティティからの相対的な位置・スケール・サイズを保持します。
//!
//! ```rust,ignore
//! use wintf::ecs::*;
//!
//! commands.spawn((
//! Arrangement {
//! offset: Offset { x: 100.0, y: 50.0 },
//! scale: LayoutScale { x: 1.5, y: 1.5 },
//! size: Size { width: 200.0, height: 100.0 },
//! },
//! // GlobalArrangementは自動的に追加されます(on_add hook)
//! ));
//! ```
//!
//! ### GlobalArrangement - グローバル累積変換
//! 親からの累積変換行列とワールド座標系でのバウンディングボックスを保持します。
//! `propagate_global_arrangements`システムにより自動的に伝播されます。
//!
//! ## taffyレイアウトエンジン統合
//!
//! `TaffyStyle`でflexboxレイアウトを宣言的に記述できます:
//!
//! ```rust,ignore
//! use wintf::ecs::*;
//! use taffy::prelude::*;
//!
//! commands.spawn((
//! TaffyStyle::new(Style {
//! size: Size { width: length(200.0), height: length(100.0) },
//! padding: Rect { left: length(10.0), right: length(10.0), top: length(5.0), bottom: length(5.0) },
//! ..Default::default()
//! }),
//! TaffyComputedLayout::default(), // taffyが自動計算
//! ));
//! ```
//!
//! The Layout System supports only translation and scaling, optimized for axis-aligned transformations.
//! The transform_rect_axis_aligned function transforms only the top-left and bottom-right points
//! instead of all four points, achieving O(2) fast rectangle transformation.
//!
//! Constraint: Rotation and skew transformations are not supported. They will be handled by the
//! DirectComposition Visual layer in the future.
//!
//! The arrangement propagation systems in the systems module leverage generic functions from
//! ecs::common::tree_system: sync_simple_transforms, mark_dirty_trees, and propagate_parent_transforms.
// Layout System サブモジュール
// 公開API
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *; // D2DRect, D2DRectExt, transform_rect_axis_aligned
pub use *;
pub use *;
use *;
/// レイアウト計算のルートを示すマーカーコンポーネント
///
/// このコンポーネントが付与されたエンティティは、Taffyレイアウト計算のルートとして扱われます。
/// 通常、仮想デスクトップ(VirtualDesktop)またはテスト用のルートエンティティに付与されます。
///
/// # 設計意図
///
/// - `Window`コンポーネントはレイアウトの対象であり、ルートではありません
/// - 真のルート階層: `VirtualDesktop → Monitor → Window → Widget`
/// - 現在の実装では仮想デスクトップ未実装のため、暫定的にルートマーカーを使用
///
/// # ストレージ戦略
///
/// `SparseSet`を使用します。このコンポーネントは通常1つのエンティティにのみ付与されるため、
/// メモリ効率の良い疎行列ストレージが適しています。
///
/// # 使用例
///
/// ```rust,ignore
/// use wintf::ecs::layout::LayoutRoot;
///
/// // テスト用のルートエンティティ
/// commands.spawn((
/// LayoutRoot,
/// BoxSize { width: Some(Dimension::Px(800.0)), height: Some(Dimension::Px(600.0)) },
/// FlexContainer::default(),
/// ));
/// ```
///
/// # ライフタイムイベント
/// - `on_add`: `Arrangement::default()`を自動挿入
/// - これにより`Arrangement`の`on_add`が連鎖的に`GlobalArrangement`と`ArrangementTreeChanged`を挿入
;
/// LayoutRootコンポーネントが追加されたときに呼ばれるフック
/// Arrangementを自動挿入する(既に存在する場合はスキップ)