page band fills the room the shell gives it so its move band spans the free part; PageBand gets a story; title test reaches the button by Tab, as a button takes no focus from a click

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Martin Ball
2026-11-18 16:20:12 +00:00
co-authored by Claude Sonnet 5.5
parent d1c070ec19
commit 6c2cda8799
3 changed files with 26 additions and 5 deletions
@@ -1,10 +1,13 @@
//! `PageBand`: the move band the shell's page shows over the window.
#[cfg(feature = "testing")]
mod stories;
use super::bar::{Window, act_on_double_click, show_end, window, window_acting};
use super::measure::End;
use crate::contract::{
BodyCx, BodyLayout, Common, Component, Container, ContainerProps, Cx, DragBand, EndRegion, HeaderRegion, Pad, Props as _, Role,
ShowContainer as _,
ShowContainer as _, Sizing,
};
use crate::runtime::egui::pass;
use crate::runtime::env::{Env, PageBandRoom, ShellEntry};
@@ -57,9 +60,11 @@ pub(crate) struct PageBand {
impl PageBand {
/// A band with the window's ends at the room the shell gives it.
pub(crate) fn new() -> Self {
// No surface: the page shows through the band.
// No surface: the page shows through the band. It fills the room the shell gives it, so its move band spans
// the free part between the ends whatever they hold.
let props = ContainerProps::new()
.pad(Pad::None)
.sizing(Sizing::Fill)
.layout(BodyLayout::row())
.header(HeaderRegion::new().band(DragBand::Move).inline(true))
.end(EndRegion::new());
@@ -0,0 +1,14 @@
//! Stories of `PageBand`: the band over a shown page, at the top of the room a shell gives it.
use super::PageBand;
use crate::contract::{Props as _, ShowContainer as _};
use crate::testing::{Drive, StoryData, StoryOutput, story};
use egui::{Rect, Ui, vec2};
/// The band with the window's ends, as a shell shows it over a page.
#[story(PageBand, covers = [Default], drive = Drive::Never)]
fn page_band(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
let room = ui.available_rect_before_wrap();
let rect = Rect::from_min_size(room.min, vec2(room.width(), ui.spacing().interact_size.y));
PageBand::new().label("Window").show_at(ui, rect, |_, _| {}).into()
}
+5 -3
View File
@@ -164,8 +164,8 @@ fn titled(title: &'static str) -> (Fixture, Rc<Cell<TitleSeen>>) {
const LONG: &str = "A very long document title that cannot fit in the free gap of a title bar six hundred points wide, \
so the bar cuts it with an ellipsis and keeps the whole of it for the tooltip and the name.psd";
/// An action title is a focusable button named by the shown title. A click and Enter each report it in the pass they
/// land in and no later pass. The button sits on the window's centre line, and a title too long for the gap is cut to
/// An action title is a focusable button named by the shown title. A click and Enter (on the title Tab focused) each
/// report it in the pass they land in and no later pass. The button sits on the window's centre line, and a title too long for the gap is cut to
/// fit inside the bar.
#[trial]
fn an_action_title_is_a_button_and_reports_its_activation() {
@@ -178,7 +178,9 @@ fn an_action_title_is_a_button_and_reports_its_activation() {
fixture.click(&title).idle(3);
assert_eq!(seen.get().activations, 1, "a click reports the title once, in its pass only");
assert!(fixture.focused_stop().is_some(), "the click focuses the title");
// A button takes no focus from a click (it senses no `TAKE_FOCUS`); Tab reaches the title, and Enter then reports it.
fixture.key(egui::Key::Tab, egui::Modifiers::NONE).idle(3);
assert!(fixture.focused_stop().is_some(), "Tab focuses the title");
fixture.key(egui::Key::Enter, egui::Modifiers::NONE).idle(3);
assert_eq!(seen.get().activations, 2, "Enter on the focused title reports it once");