mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-20 12:51:16 -06:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4af551c178 |
@@ -94,6 +94,9 @@ pub struct Windows {
|
||||
/// Whether the root OS window had focus in the last pass; a [`DocumentWindow`] reports its own gain
|
||||
/// (`focus_gained`), the root's is read from the window host's facts.
|
||||
root_focused: bool,
|
||||
/// The room each window's last draw had, by window key (tests read it).
|
||||
#[cfg(test)]
|
||||
drawn: std::collections::HashMap<u64, egui::Rect>,
|
||||
}
|
||||
|
||||
impl Windows {
|
||||
@@ -101,7 +104,16 @@ impl Windows {
|
||||
pub(crate) fn new(doc: u64) -> Windows {
|
||||
let mut list = WindowList::new();
|
||||
let id = list.open(Window::new(doc, None, None, false));
|
||||
Windows { native: cfg!(not(target_arch = "wasm32")), list, root: id, shown: id, arranged: arrange::State::default(), root_focused: false }
|
||||
Windows {
|
||||
native: cfg!(not(target_arch = "wasm32")),
|
||||
list,
|
||||
root: id,
|
||||
shown: id,
|
||||
arranged: arrange::State::default(),
|
||||
root_focused: false,
|
||||
#[cfg(test)]
|
||||
drawn: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether documents get native windows of their own.
|
||||
@@ -528,7 +540,10 @@ impl WordApp {
|
||||
let (raise, place) = (std::mem::take(&mut w.raise), std::mem::take(&mut w.place));
|
||||
let mut window = DocumentWindow::new(Self::title_in(&menu, id))
|
||||
.id(window_container_id(id))
|
||||
.overlay(|overlay| overlay.size_limits(SizeLimits::at_least(MIN_SIZE)));
|
||||
// The window's body is the whole interface, which lays itself out in the window's room. A
|
||||
// scrolling body gives it an unbounded height instead (#7149 item 5): the interface lands
|
||||
// 32768 points tall, off the window, and the window shows nothing.
|
||||
.overlay(|overlay| overlay.size_limits(SizeLimits::at_least(MIN_SIZE)).body_scroll(false));
|
||||
if raise {
|
||||
window = window.raise();
|
||||
}
|
||||
@@ -586,6 +601,8 @@ impl WordApp {
|
||||
if self.windows.shown() != key {
|
||||
return;
|
||||
}
|
||||
#[cfg(test)]
|
||||
self.windows.drawn.insert(key, ui.max_rect());
|
||||
self.window_ui(ui);
|
||||
arrange::forward_scroll(self, &ctx);
|
||||
}
|
||||
|
||||
@@ -139,6 +139,24 @@ fn new_opens_a_second_window_and_each_keeps_its_state() {
|
||||
assert_eq!((text(&a), a.ui.tab.as_str(), prompt(&a).as_deref()), ("Second".into(), crate::DEFAULT_TAB, None));
|
||||
}
|
||||
|
||||
/// Each window draws its interface in the room its OS window gives it. A window's body that scrolls lays the
|
||||
/// interface out 32768 points tall, so a second window opened blank (#7149 item 5).
|
||||
#[test]
|
||||
fn a_second_window_draws_its_interface_in_the_room_of_its_window() {
|
||||
let mut rig = Rig::new();
|
||||
let mut a = app("First");
|
||||
rig.frames(&mut a, 3);
|
||||
a.run("file.new", json!({})).unwrap();
|
||||
rig.frames(&mut a, 6);
|
||||
let child = a.active_viewport();
|
||||
assert_ne!(child, ViewportId::ROOT);
|
||||
assert!(rig.drawn.contains(&child), "the second window draws: {:?}", rig.drawn);
|
||||
let key = a.windows.active().unwrap();
|
||||
let room = a.windows.drawn.get(&key).copied().unwrap();
|
||||
// The kit's child window is 400 by 300 points.
|
||||
assert!(room.height() <= 300.0 && room.min.y >= 0.0, "the interface has the window's room, not {room:?}");
|
||||
}
|
||||
|
||||
/// Each window has its own key, and the root window's stays `main` when it adopts another entry.
|
||||
#[test]
|
||||
fn window_keys_differ_and_the_root_keeps_main() {
|
||||
|
||||
Reference in New Issue
Block a user