/builds/framezero/productivity/src/ui/screen_layout.rs
Line | Count | Source |
1 | | //! Shared screen chrome. Screens supply content and controls, never their own header. |
2 | | use chrono::NaiveDate; |
3 | | use gpui::{ |
4 | | AnyElement, App, IntoElement, RenderOnce, ScrollHandle, SharedString, Window, div, prelude::*, |
5 | | px, rgb, |
6 | | }; |
7 | | use gpui_component::scroll::{Scrollbar, ScrollbarMode}; |
8 | | |
9 | | use super::theme::t; |
10 | | |
11 | | /// Narrowest the toolbar summary gets before the controls beside it wrap below. |
12 | | const TOOLBAR_SUMMARY_MIN_WIDTH: f32 = 220.; |
13 | | |
14 | | #[derive(Clone, Copy, PartialEq, Eq)] |
15 | | pub(super) enum ScreenDensity { |
16 | | Standard, |
17 | | /// Less padding and no subtitle, but still the same date and title. |
18 | | Editor, |
19 | | } |
20 | | |
21 | | pub(super) struct ScreenToolbar { |
22 | | pub left: AnyElement, |
23 | | pub right: Option<AnyElement>, |
24 | | } |
25 | | |
26 | | /// How a screen's content uses the space between the toolbar and the footer. |
27 | | /// |
28 | | /// Every screen picks exactly one in `Workspace::content_fit`, which drives both this |
29 | | /// layout's scroll container and the workspace's content wrapper, so the two cannot disagree. |
30 | | #[derive(Clone)] |
31 | | pub(super) enum ContentFit { |
32 | | /// Board-like screens (planner, matrix, columns, calendar, editors) get exactly the |
33 | | /// visible content height and scroll inside their own regions, so nothing runs under |
34 | | /// the footer. Size them with `flex_1().min_h_0()`, never with fixed heights; a UI test |
35 | | /// checks at several window sizes that every such root ends exactly above the footer. |
36 | | Fill { |
37 | | /// Debug selector of the screen's root element, checked by the layout test. |
38 | | #[cfg_attr(not(all(test, feature = "ui-tests")), allow(dead_code))] |
39 | | root: &'static str, |
40 | | /// Lets a wide minimum layout scroll sideways in narrow windows. |
41 | | horizontal: bool, |
42 | | }, |
43 | | /// Document-like screens (lists, forms, read-only notes) keep their natural height, |
44 | | /// and the whole content area scrolls. |
45 | | Flow { |
46 | | horizontal: bool, |
47 | | handle: Option<ScrollHandle>, |
48 | | }, |
49 | | } |
50 | | |
51 | | impl ContentFit { |
52 | 3.26k | pub(super) fn fills(&self) -> bool { |
53 | 3.26k | matches!(self, Self::Fill { .. }) |
54 | 3.26k | } |
55 | | } |
56 | | |
57 | | /// Date and title are required and cannot be disabled by a screen variant. |
58 | | #[derive(IntoElement)] |
59 | | pub(super) struct ScreenLayout { |
60 | | pub date: NaiveDate, |
61 | | pub title: &'static str, |
62 | | pub subtitle: &'static str, |
63 | | pub density: ScreenDensity, |
64 | | pub actions: Vec<AnyElement>, |
65 | | pub toolbar: Option<ScreenToolbar>, |
66 | | pub content: AnyElement, |
67 | | pub fit: ContentFit, |
68 | | pub compact: bool, |
69 | | pub error: Option<String>, |
70 | | pub footer: Option<String>, |
71 | | } |
72 | | |
73 | | impl RenderOnce for ScreenLayout { |
74 | 3.26k | fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement { |
75 | 3.26k | let editor = self.density == ScreenDensity::Editor; |
76 | 3.26k | let header = div() |
77 | 3.26k | .id("screen-header") |
78 | 3.26k | .debug_selector(|| "screen-header".into()) |
79 | | .px_6() |
80 | 3.26k | .when(editor, |this| this543 .py_3()) |
81 | 3.26k | .when(!editor, |this| this.pt_6()2.72k .pb_4()) |
82 | | .flex() |
83 | | .flex_wrap() |
84 | | .items_center() |
85 | | .justify_between() |
86 | | .gap_3() |
87 | | .child( |
88 | 3.26k | div() |
89 | 3.26k | .flex() |
90 | 3.26k | .flex_col() |
91 | 3.26k | .flex_1() |
92 | 3.26k | .min_w_0() |
93 | 3.26k | .gap_2() |
94 | | .child( |
95 | 3.26k | div() |
96 | 3.26k | .id("view-date") |
97 | 3.26k | .debug_selector(|| "view-date".into()) |
98 | | .text_xs() |
99 | 3.26k | .text_color(rgb(t().muted)) |
100 | 3.26k | .child(self.date.format("%A, %B %-d").to_string()), |
101 | | ) |
102 | | .child( |
103 | 3.26k | div() |
104 | 3.26k | .flex() |
105 | 3.26k | .items_center() |
106 | 3.26k | .gap_3() |
107 | 3.26k | .min_w_0() |
108 | | .child( |
109 | 3.26k | div() |
110 | 3.26k | .id("view-title") |
111 | 3.26k | .debug_selector(|| "view-title".into()) |
112 | | .min_w_0() |
113 | | .truncate() |
114 | | .text_2xl() |
115 | 3.26k | .font_weight(gpui::FontWeight::SEMIBOLD) |
116 | 3.26k | .child(self.title), |
117 | | ) |
118 | 3.26k | .when(!editor, |this| {2.72k |
119 | 2.72k | this.child( |
120 | 2.72k | div() |
121 | 2.72k | .id("view-subtitle") |
122 | 2.72k | .debug_selector(|| "view-subtitle".into()) |
123 | | .min_w_0() |
124 | | .truncate() |
125 | | .text_sm() |
126 | 2.72k | .text_color(rgb(t().muted)) |
127 | 2.72k | .child(self.subtitle), |
128 | | ) |
129 | 2.72k | }), |
130 | | ), |
131 | | ) |
132 | 3.26k | .children(self.actions); |
133 | 3.26k | let toolbar = self.toolbar.map(|toolbar| {3.23k |
134 | 3.23k | div() |
135 | 3.23k | .id("page-toolbar") |
136 | 3.23k | .debug_selector(|| "page-toolbar".into()) |
137 | | .px_6() |
138 | 3.23k | .when(editor, |this| this543 .pb_3()) |
139 | 3.23k | .when(!editor, |this| this2.69k .pb_4()) |
140 | | .flex() |
141 | | .flex_wrap() |
142 | | .items_center() |
143 | | .justify_between() |
144 | | .gap_3() |
145 | | .border_b_1() |
146 | 3.23k | .border_color(rgb(t().line)) |
147 | | // A minimum width wraps the controls onto their own line before the summary |
148 | | // would be squeezed to a few letters per line. |
149 | | .child( |
150 | 3.23k | div() |
151 | 3.23k | .id("page-toolbar-summary") |
152 | 3.23k | .debug_selector(|| "page-toolbar-summary".into()) |
153 | | .flex_1() |
154 | 3.23k | .min_w(px(TOOLBAR_SUMMARY_MIN_WIDTH)) |
155 | 3.23k | .child(toolbar.left), |
156 | | ) |
157 | 3.23k | .children(toolbar.right) |
158 | 3.23k | }); |
159 | 3.26k | let horizontal = match &self.fit { |
160 | | ContentFit::Fill { horizontal, .. } | ContentFit::Flow { horizontal, .. } => { |
161 | 3.26k | *horizontal |
162 | | } |
163 | | }; |
164 | | // Sideways scrolling gets a visible scrollbar, since most mice have no horizontal |
165 | | // wheel; each screen keeps its own offset. |
166 | 3.26k | let handle = match &self.fit { |
167 | | ContentFit::Flow { |
168 | | handle: Some(handle), |
169 | | .. |
170 | 133 | } => Some(handle.clone()), |
171 | 3.13k | _ if horizontal => Some( |
172 | 304 | window |
173 | | .use_keyed_state( |
174 | 304 | SharedString::from(format!("screen-scroll-{}", self.title)), |
175 | 304 | cx, |
176 | 46 | |_, _| ScrollHandle::new(), |
177 | | ) |
178 | 304 | .read(cx) |
179 | | .clone(), |
180 | | ), |
181 | 2.83k | _ => None, |
182 | | }; |
183 | 3.26k | let scrollbar = handle.clone().filter(|_| horizontal).map(|handle| {304 |
184 | 304 | div().absolute().inset_0().child( |
185 | 304 | Scrollbar::horizontal(&handle) |
186 | 304 | .id("screen-horizontal-scrollbar") |
187 | 304 | .mode(ScrollbarMode::Always) |
188 | 304 | .viewport_from_layout(), |
189 | 304 | ) |
190 | 304 | }); |
191 | 3.26k | let content = div() |
192 | 3.26k | .id("workspace-scroll") |
193 | 3.26k | .debug_selector(|| "workspace-scroll".into()) |
194 | | .flex_1() |
195 | | .min_h_0() |
196 | 3.26k | .when_some(handle, |this, handle| this437 .track_scroll(&handle437 )); |
197 | | // GPUI measures the scrollable extent from this container's direct child, the |
198 | | // content wrapper. To scroll sideways, the wrapper is a flex-row item so it grows to |
199 | | // the screen's minimum width instead of being clipped at the viewport width. |
200 | | // Sideways scrolling sticks to its axis so a vertical wheel over an inner list does |
201 | | // not also slide the page; Shift+wheel and trackpads scroll horizontally. |
202 | 3.26k | let content = match self.fit { |
203 | | // Fill: the wrapper takes the full height with `flex_1` (or by stretching). |
204 | 2.56k | ContentFit::Fill { horizontal, .. } => content |
205 | 2.56k | .flex() |
206 | 2.56k | .when(!horizontal, |this| this2.26k .flex_col()) |
207 | | .overflow_hidden() |
208 | 2.56k | .when(horizontal, |this| {304 |
209 | 304 | this.overflow_x_scroll().restrict_scroll_to_axis() |
210 | 304 | }), |
211 | | // Flow: the wrapper keeps its natural height so the page can scroll down. |
212 | | ContentFit::Flow { horizontal, .. } => { |
213 | 700 | content.overflow_y_scroll().when(horizontal, |this| {0 |
214 | 0 | this.flex() |
215 | 0 | .items_start() |
216 | 0 | .overflow_x_scroll() |
217 | 0 | .restrict_scroll_to_axis() |
218 | 0 | }) |
219 | | } |
220 | | }; |
221 | 3.26k | div() |
222 | 3.26k | .id("screen-layout") |
223 | 3.26k | .debug_selector(|| "screen-layout".into()) |
224 | | .flex() |
225 | | .flex_col() |
226 | | .flex_1() |
227 | | .min_w_0() |
228 | | .h_full() |
229 | 3.26k | .child(header) |
230 | 3.26k | .children(toolbar) |
231 | 3.26k | .when_some(self.error, |this, error| {17 |
232 | 17 | this.child( |
233 | 17 | div() |
234 | 17 | .mx_6() |
235 | 17 | .mt_4() |
236 | 17 | .p_3() |
237 | 17 | .rounded_md() |
238 | 17 | .bg(rgb(t().danger_bg)) |
239 | 17 | .text_color(rgb(t().danger_text)) |
240 | 17 | .child(error), |
241 | 17 | ) |
242 | 17 | }) |
243 | | .child( |
244 | 3.26k | div() |
245 | 3.26k | .relative() |
246 | 3.26k | .flex() |
247 | 3.26k | .flex_col() |
248 | 3.26k | .flex_1() |
249 | 3.26k | .min_h_0() |
250 | | .child( |
251 | 3.26k | content |
252 | 3.26k | .p_6() |
253 | 3.26k | .when(self.compact, |this| this385 .p_3()) |
254 | 3.26k | .when(editor, |this| this543 .pt_3()) |
255 | 3.26k | .child(self.content), |
256 | | ) |
257 | 3.26k | .children(scrollbar), |
258 | | ) |
259 | 3.26k | .when_some(self.footer, |this, footer| {3.15k |
260 | 3.15k | this.child( |
261 | 3.15k | div() |
262 | 3.15k | .id("screen-footer") |
263 | 3.15k | .debug_selector(|| "screen-footer".into()) |
264 | | .px_6() |
265 | | .py_3() |
266 | | .border_t_1() |
267 | 3.15k | .border_color(rgb(t().line)) |
268 | | .text_xs() |
269 | 3.15k | .text_color(rgb(t().muted)) |
270 | 3.15k | .child(footer), |
271 | | ) |
272 | 3.15k | }) |
273 | 3.26k | } |
274 | | } |
275 | | |
276 | | #[cfg(all(test, feature = "ui-tests"))] |
277 | | pub(in crate::ui) mod tests { |
278 | | use gpui::{TestAppContext, VisualTestContext, px}; |
279 | | |
280 | | use super::ContentFit; |
281 | | use crate::ui::{DisplaySettings, View, tests::setup_with_settings}; |
282 | | |
283 | 72 | pub(in crate::ui) fn assert_screen_layout( |
284 | 72 | cx: &mut VisualTestContext, |
285 | 72 | editor: bool, |
286 | 72 | has_toolbar: bool, |
287 | 72 | ) { |
288 | 72 | let screen = cx.debug_bounds("screen-layout").unwrap(); |
289 | 72 | let header = cx.debug_bounds("screen-header").unwrap(); |
290 | 72 | let date = cx.debug_bounds("view-date").unwrap(); |
291 | 72 | let title = cx.debug_bounds("view-title").unwrap(); |
292 | 72 | let content = cx.debug_bounds("workspace-scroll").unwrap(); |
293 | 72 | assert_eq!(header.left(), screen.left()); |
294 | 72 | assert_eq!(header.right(), screen.right()); |
295 | 72 | assert_eq!(date.left(), header.left() + px(24.)); |
296 | 72 | assert_eq!( |
297 | 72 | date.top(), |
298 | 72 | header.top() + px(if editor { 12.12 } else { 24.60 }) |
299 | | ); |
300 | 72 | assert_eq!(date.left(), title.left()); |
301 | 72 | assert!(date.size.height > px(0.) && date.bottom() <= title.top()); |
302 | 72 | assert!(title.size.width > px(0.) && title.bottom() <= header.bottom()); |
303 | 72 | for selector in ["new-task", "new-note"] { |
304 | 144 | let action = cx.debug_bounds(selector).unwrap(); |
305 | 144 | assert!(action.left() >= header.left() && action.right() <= header.right()); |
306 | 144 | assert!(action.top() >= header.top() && action.bottom() <= header.bottom()); |
307 | | } |
308 | 72 | assert!(content.size.height > px(0.) && content.bottom() <= screen.bottom()); |
309 | 72 | assert!(content.top() >= header.bottom()); |
310 | 72 | if has_toolbar { |
311 | 66 | let toolbar = cx.debug_bounds("page-toolbar").unwrap(); |
312 | 66 | assert_eq!(toolbar.left(), header.left()); |
313 | 66 | assert_eq!(toolbar.right(), header.right()); |
314 | 66 | assert!(toolbar.top() >= header.bottom()); |
315 | 66 | assert!(toolbar.bottom() <= content.top()); |
316 | 66 | let summary = cx.debug_bounds("page-toolbar-summary").unwrap(); |
317 | 66 | assert!(summary.size.width >= px(super::TOOLBAR_SUMMARY_MIN_WIDTH)); |
318 | | } else { |
319 | 6 | assert!(cx.debug_bounds("page-toolbar").is_none()); |
320 | | } |
321 | 72 | if !editor { |
322 | 60 | let subtitle = cx.debug_bounds("view-subtitle").unwrap(); |
323 | 60 | assert!((title.center().y - subtitle.center().y).abs() < px(1.)); |
324 | 60 | assert!(subtitle.left() >= title.right()); |
325 | 12 | } |
326 | 72 | } |
327 | | |
328 | | /// Fill screens must end exactly at the content padding above the footer, whatever the |
329 | | /// window size, so no screen relies on a fixed height that leaves a gap or runs under it. |
330 | | #[gpui::test] |
331 | 1 | fn fill_screens_end_above_the_footer_at_every_size(cx: &mut TestAppContext) { |
332 | 1 | let mut checked = 0; |
333 | 1 | for view in [ |
334 | 1 | View::Today, |
335 | 1 | View::List, |
336 | 1 | View::Matrix, |
337 | 1 | View::Kanban, |
338 | 1 | View::Projects, |
339 | 1 | View::Calendar, |
340 | 1 | View::NotesBrowse, |
341 | 1 | View::NotesWrite, |
342 | 1 | View::NotesPreview, |
343 | 1 | View::Settings, |
344 | 1 | View::About, |
345 | 1 | ] { |
346 | 11 | for compact in [false, true] { |
347 | 22 | let settings = DisplaySettings { |
348 | 22 | notes_visible: true, |
349 | 22 | compact, |
350 | 22 | ..Default::default() |
351 | 22 | }; |
352 | 22 | let (_directory, workspace, cx) = setup_with_settings(cx, vec![], settings); |
353 | 22 | cx.update(|window, cx| { |
354 | 22 | workspace.update(cx, |state, cx| state.switch_view(view, window, cx)) |
355 | 22 | }); |
356 | 22 | let fit = cx.update(|_, cx| workspace.read(cx).content_fit()); |
357 | 22 | let ContentFit::Fill { root, .. } = fit else { |
358 | 10 | continue; |
359 | | }; |
360 | 12 | checked += 1; |
361 | 12 | let padding = px(if compact { 12.6 } else { 24.6 }); |
362 | 12 | for (width, height) in [(1000., 560.), (1320., 840.), (1920., 1400.)] { |
363 | 36 | cx.simulate_resize(gpui::size(px(width), px(height))); |
364 | 36 | cx.run_until_parked(); |
365 | 36 | let content = cx.debug_bounds("workspace-scroll").unwrap(); |
366 | 36 | let footer = cx.debug_bounds("screen-footer").unwrap(); |
367 | 36 | let screen = cx.debug_bounds(root).unwrap_or_else(|| {0 |
368 | 0 | panic!("{root} is declared as the fill root but is not rendered") |
369 | | }); |
370 | 36 | assert!(content.bottom() <= footer.top()); |
371 | 36 | assert!( |
372 | 36 | (content.bottom() - padding - screen.bottom()).abs() < px(1.), |
373 | | "{root} at {width}x{height}: ends at {:?}, content area at {:?}", |
374 | | screen.bottom(), |
375 | | content.bottom() - padding, |
376 | | ); |
377 | | } |
378 | | } |
379 | | } |
380 | 1 | assert_eq!(checked, 12, "six fill screens in both densities"); |
381 | 1 | } |
382 | | |
383 | | /// At the minimum window size the Kanban columns shrink to fit, so the last column keeps |
384 | | /// the content padding instead of running into the window edge. |
385 | | #[gpui::test] |
386 | 1 | fn kanban_fits_the_minimum_window_with_its_padding(cx: &mut TestAppContext) { |
387 | 1 | for compact in [false, true] { |
388 | 2 | let settings = DisplaySettings { |
389 | 2 | compact, |
390 | 2 | ..Default::default() |
391 | 2 | }; |
392 | 2 | let (_directory, workspace, cx) = setup_with_settings(cx, vec![], settings); |
393 | 2 | cx.update(|window, cx| { |
394 | 2 | workspace.update(cx, |state, cx| state.switch_view(View::Kanban, window, cx)) |
395 | 2 | }); |
396 | 2 | cx.simulate_resize(gpui::size(px(1000.), px(640.))); |
397 | 2 | cx.run_until_parked(); |
398 | 2 | let content = cx.debug_bounds("workspace-scroll").unwrap(); |
399 | 2 | let padding = px(if compact { 12.1 } else { 24.1 }); |
400 | 2 | let last = cx.debug_bounds("kanban-on_hold").unwrap(); |
401 | 2 | assert!( |
402 | 2 | (last.right() - (content.right() - padding)).abs() < px(1.), |
403 | | "compact={compact}: {last:?} in {content:?}" |
404 | | ); |
405 | | } |
406 | 1 | } |
407 | | |
408 | | /// Screens with a minimum width scroll sideways in narrow windows rather than |
409 | | /// clipping their last columns. |
410 | | #[gpui::test] |
411 | 1 | fn wide_screens_scroll_sideways_in_narrow_windows(cx: &mut TestAppContext) { |
412 | 1 | for (view, root) in [(View::Kanban, "kanban"), (View::Calendar, "calendar-view")] { |
413 | | let (_directory, workspace, cx) = |
414 | 2 | setup_with_settings(cx, vec![], DisplaySettings::default()); |
415 | 2 | cx.update(|window, cx| { |
416 | 2 | workspace.update(cx, |state, cx| state.switch_view(view, window, cx)) |
417 | 2 | }); |
418 | 2 | cx.simulate_resize(gpui::size(px(700.), px(800.))); |
419 | 2 | cx.run_until_parked(); |
420 | 2 | let content = cx.debug_bounds("workspace-scroll").unwrap(); |
421 | 2 | let before = cx.debug_bounds(root).unwrap(); |
422 | 2 | assert!( |
423 | 2 | before.right() > content.right(), |
424 | | "{root} fits; nothing to test" |
425 | | ); |
426 | 2 | cx.simulate_event(gpui::ScrollEvent { |
427 | 2 | position: content.center(), |
428 | 2 | delta: gpui::ScrollDelta::Pixels(gpui::point(px(-2000.), px(0.))), |
429 | 2 | ..Default::default() |
430 | 2 | }); |
431 | 2 | cx.run_until_parked(); |
432 | 2 | let after = cx.debug_bounds(root).unwrap(); |
433 | 2 | assert_eq!(after.size, before.size); |
434 | | // Scrolled fully, the screen's right edge sits at the content padding. |
435 | 2 | assert!( |
436 | 2 | (after.right() - (content.right() - px(24.))).abs() < px(1.), |
437 | | "{root}: {after:?} in {content:?}" |
438 | | ); |
439 | | } |
440 | 1 | } |
441 | | |
442 | | /// Most mice have no horizontal wheel, so wide screens show a scrollbar to drag. |
443 | | #[gpui::test] |
444 | 1 | fn wide_screens_scroll_sideways_with_the_scrollbar(cx: &mut TestAppContext) { |
445 | 1 | for (view, root) in [(View::Kanban, "kanban"), (View::Calendar, "calendar-view")] { |
446 | | let (_directory, workspace, cx) = |
447 | 2 | setup_with_settings(cx, vec![], DisplaySettings::default()); |
448 | 2 | cx.update(|window, cx| { |
449 | 2 | workspace.update(cx, |state, cx| state.switch_view(view, window, cx)) |
450 | 2 | }); |
451 | 2 | cx.simulate_resize(gpui::size(px(700.), px(800.))); |
452 | 2 | cx.run_until_parked(); |
453 | 2 | let content = cx.debug_bounds("workspace-scroll").unwrap(); |
454 | 2 | let before = cx.debug_bounds(root).unwrap(); |
455 | | // Clicking the right end of the bar along the bottom edge shows the last column. |
456 | 2 | let end = gpui::point(content.right() - px(10.), content.bottom() - px(4.)); |
457 | 2 | let modifiers = gpui::Modifiers::default(); |
458 | 2 | cx.simulate_mouse_move(end, None, modifiers); |
459 | 2 | cx.run_until_parked(); |
460 | 2 | cx.simulate_click(end, modifiers); |
461 | 2 | cx.run_until_parked(); |
462 | 2 | let after = cx.debug_bounds(root).unwrap(); |
463 | 2 | assert!( |
464 | 2 | after.left() < before.left(), |
465 | | "{root}: {before:?} -> {after:?}" |
466 | | ); |
467 | 2 | assert_eq!(after.top(), before.top()); |
468 | | } |
469 | 1 | } |
470 | | |
471 | | #[gpui::test] |
472 | 1 | fn every_screen_uses_the_shared_layout_at_supported_sizes(cx: &mut TestAppContext) { |
473 | 1 | for view in [ |
474 | 1 | View::Today, |
475 | 1 | View::List, |
476 | 1 | View::Matrix, |
477 | 1 | View::Kanban, |
478 | 1 | View::Projects, |
479 | 1 | View::Calendar, |
480 | 1 | View::NotesBrowse, |
481 | 1 | View::NotesWrite, |
482 | 1 | View::NotesPreview, |
483 | 1 | View::Settings, |
484 | 1 | View::About, |
485 | 1 | ] { |
486 | 11 | for compact in [false, true] { |
487 | | // A fresh window per screen avoids GPUI's retained debug selectors |
488 | | // masking a missing element after navigation. |
489 | 22 | let settings = DisplaySettings { |
490 | 22 | notes_visible: true, |
491 | 22 | compact, |
492 | 22 | ..Default::default() |
493 | 22 | }; |
494 | 22 | let (_directory, workspace, cx) = setup_with_settings(cx, vec![], settings); |
495 | 22 | cx.update(|window, cx| { |
496 | 22 | workspace.update(cx, |state, cx| state.switch_view(view, window, cx)) |
497 | 22 | }); |
498 | 22 | for (width, height) in [(1000., 640.), (1320., 840.), (1920., 1200.)] { |
499 | 66 | cx.simulate_resize(gpui::size(px(width), px(height))); |
500 | 66 | cx.run_until_parked(); |
501 | 66 | cx.update(|_, cx| assert!(workspace.read(cx).view == view)); |
502 | 66 | assert_screen_layout(cx, view == View::NotesWrite, view != View::About); |
503 | | } |
504 | | } |
505 | | } |
506 | 1 | } |
507 | | } |