transcript-ui: build_tree, the screen without claiming the window root (RUST.md's E4)
build() always finished by calling ui_state.set_root(), which is right for a window that *is* the transcript screen and wrong for a caller embedding it beside something else (the desktop app's session list). build_tree() is build() minus that last step, returning the widget tree instead of planting it; build() is now one line on top of it, so nothing else changes for existing callers. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
6d5fd64bb0
commit
8f0aec449a
1 file changed
+30
-7
@@ -88,6 +88,25 @@ pub fn build<Rsc: HasEvents>(
|
|||||||
ui_state: &mut impl HasRoot,
|
ui_state: &mut impl HasRoot,
|
||||||
rows: Vec<FoldedRow>,
|
rows: Vec<FoldedRow>,
|
||||||
) -> TranscriptScreen
|
) -> TranscriptScreen
|
||||||
|
where
|
||||||
|
Rsc::State: FocusHost,
|
||||||
|
{
|
||||||
|
let (screen, tree) = build_tree(rsc, rows);
|
||||||
|
ui_state.set_root(tree);
|
||||||
|
screen
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The same widget tree [`build`] makes, without claiming the window's
|
||||||
|
/// whole root -- what a caller embedding this screen alongside something
|
||||||
|
/// else of its own needs (RUST.md's E4: a session list beside the
|
||||||
|
/// transcript on the desktop). `build` is `build_tree` plus
|
||||||
|
/// `ui_state.set_root(tree)`; kept as its own function since most callers
|
||||||
|
/// (the winit example, an eventual Android cdylib) want the screen to *be*
|
||||||
|
/// the window and don't need the strong handle back.
|
||||||
|
pub fn build_tree<Rsc: HasEvents>(
|
||||||
|
rsc: &mut Rsc,
|
||||||
|
rows: Vec<FoldedRow>,
|
||||||
|
) -> (TranscriptScreen, StrongWidget)
|
||||||
where
|
where
|
||||||
Rsc::State: FocusHost,
|
Rsc::State: FocusHost,
|
||||||
{
|
{
|
||||||
@@ -111,13 +130,17 @@ where
|
|||||||
|
|
||||||
let (composer, composer_bar) = composer::build_composer(rsc);
|
let (composer, composer_bar) = composer::build_composer(rsc);
|
||||||
|
|
||||||
(list.width(rest(1)).height(rest(1)), composer_bar)
|
let tree = (list.width(rest(1)).height(rest(1)), composer_bar)
|
||||||
.span(Dir::DOWN)
|
.span(Dir::DOWN)
|
||||||
.set_root(rsc, ui_state);
|
.add_strong(rsc)
|
||||||
|
.any();
|
||||||
|
|
||||||
TranscriptScreen {
|
(
|
||||||
list,
|
TranscriptScreen {
|
||||||
composer,
|
list,
|
||||||
selection,
|
composer,
|
||||||
}
|
selection,
|
||||||
|
},
|
||||||
|
tree,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user