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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
//! Test TextInput widget with transforms
//!
//! Tests that text input works correctly when inside transformed containers:
//! - Click-to-position cursor works with rotation, scale, and translation
//! - Selection works correctly
//! - Visual rendering is correct
use guido::prelude::*;
fn main() {
App::new().run(|app| {
let input1 = create_signal(String::from("Normal input"));
let input2 = create_signal(String::from("Rotated 15°"));
let input3 = create_signal(String::from("Scaled 1.2x"));
let input4 = create_signal(String::from("Translated"));
let input5 = create_signal(String::from("All transforms"));
let view = container()
.background(Color::rgb(0.1, 0.1, 0.15))
.padding(32.0)
.layout(Flex::column().spacing(32.0))
.child(
container().child(
text("TextInput Transform Test")
.font_size(18.0)
.color(Color::WHITE),
),
)
// 1. Normal (no transform) - baseline
.child(
container()
.layout(Flex::column().spacing(4.0))
.child(
container().child(
text("No transform (baseline)")
.font_size(12.0)
.color(Color::rgb(0.6, 0.6, 0.7)),
),
)
.child(
container()
.width(300.0)
.padding(8.0)
.background(Color::rgb(0.18, 0.18, 0.24))
.border(1.0, Color::rgb(0.3, 0.8, 0.3))
.corners(6.0)
.child(
text_input(input1)
.cursor_color(Color::rgb(0.4, 0.8, 1.0))
.font_size(14.0)
.color(Color::WHITE),
),
),
)
// 2. Rotated container
.child(
container()
.layout(Flex::column().spacing(4.0))
.child(
container().child(
text("Rotated 15°")
.font_size(12.0)
.color(Color::rgb(0.6, 0.6, 0.7)),
),
)
.child(
container()
.width(300.0)
.padding(8.0)
.background(Color::rgb(0.18, 0.18, 0.24))
.border(1.0, Color::rgb(0.8, 0.5, 0.3))
.corners(6.0)
.rotate(15.0)
.child(
text_input(input2)
.cursor_color(Color::rgb(0.4, 0.8, 1.0))
.font_size(14.0)
.color(Color::WHITE),
),
),
)
// 3. Scaled container
.child(
container()
.layout(Flex::column().spacing(4.0))
.child(
container().child(
text("Scaled 1.2x")
.font_size(12.0)
.color(Color::rgb(0.6, 0.6, 0.7)),
),
)
.child(
container()
.width(250.0)
.padding(8.0)
.background(Color::rgb(0.18, 0.18, 0.24))
.border(1.0, Color::rgb(0.3, 0.5, 0.8))
.corners(6.0)
.scale(1.2)
.child(
text_input(input3)
.cursor_color(Color::rgb(0.4, 0.8, 1.0))
.font_size(14.0)
.color(Color::WHITE),
),
),
)
// 4. Translated container
.child(
container()
.layout(Flex::column().spacing(4.0))
.child(
container().child(
text("Translated (50, 10)")
.font_size(12.0)
.color(Color::rgb(0.6, 0.6, 0.7)),
),
)
.child(
container()
.width(300.0)
.padding(8.0)
.background(Color::rgb(0.18, 0.18, 0.24))
.border(1.0, Color::rgb(0.8, 0.8, 0.3))
.corners(6.0)
.translate((50.0, 10.0))
.child(
text_input(input4)
.cursor_color(Color::rgb(0.4, 0.8, 1.0))
.font_size(14.0)
.color(Color::WHITE),
),
),
)
// 5. All transforms combined: translate + rotate + scale
.child(
container()
.layout(Flex::column().spacing(4.0))
.child(
container().child(
text("Translate(20,5) + Rotate(-10°) + Scale(0.9)")
.font_size(12.0)
.color(Color::rgb(0.6, 0.6, 0.7)),
),
)
.child(
container()
.width(300.0)
.padding(8.0)
.background(Color::rgb(0.18, 0.18, 0.24))
.border(1.0, Color::rgb(0.8, 0.3, 0.8))
.corners(6.0)
.translate((20.0, 5.0))
.rotate(-10.0)
.scale(0.9)
.child(
text_input(input5)
.cursor_color(Color::rgb(0.4, 0.8, 1.0))
.font_size(14.0)
.color(Color::WHITE),
),
),
)
// Instructions
.child(
container().child(
text("Click in each input to test cursor positioning")
.font_size(11.0)
.color(Color::rgb(0.5, 0.5, 0.6)),
),
);
app.add_surface(
SurfaceConfig::new()
.width(550)
.height(680)
.anchor(Anchor::TOP | Anchor::LEFT)
.layer(Layer::Top)
.namespace("text-input-transform-test")
.background_color(Color::rgb(0.1, 0.1, 0.15)),
move || view,
);
});
}