Add scoped overlay hosts
This commit is contained in:
1 parent
b53a17c436
commit
599d33287c
24 files changed
+910
-60
No files matched your search
@@ -93,7 +93,7 @@ impl DefaultAppState for Client {
|
||||
.pad(dp(16))
|
||||
.add_strong(rsc)
|
||||
.any();
|
||||
ui_state.set_root(text);
|
||||
ui_state.set_root(rsc, text);
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
@@ -142,7 +142,7 @@ impl AndroidAppState for BenchClient {
|
||||
.span(Dir::DOWN)
|
||||
.add_strong(rsc)
|
||||
.any();
|
||||
ui_state.set_root(tree);
|
||||
ui_state.set_root(rsc, tree);
|
||||
|
||||
let font = rsc.ui.text.font_diagnostics();
|
||||
log::info!(
|
||||
|
||||
@@ -99,7 +99,7 @@ impl AndroidAppState for TranscriptClient {
|
||||
.span(Dir::DOWN)
|
||||
.add_strong(rsc)
|
||||
.any();
|
||||
ui_state.set_root(tree);
|
||||
ui_state.set_root(rsc, tree);
|
||||
|
||||
let mut client = Self {
|
||||
ui_state,
|
||||
|
||||
@@ -99,12 +99,15 @@ where
|
||||
))
|
||||
}
|
||||
|
||||
pub fn open<Rsc: HasEvents>(rsc: &mut Rsc, ui_state: &mut impl HasRoot) -> Result<Opened, String>
|
||||
pub fn open<Rsc: HasEvents>(
|
||||
rsc: &mut Rsc,
|
||||
ui_state: &mut impl HasRoot<Rsc>,
|
||||
) -> Result<Opened, String>
|
||||
where
|
||||
Rsc::State: FocusHost + OpenUrl,
|
||||
{
|
||||
let (opened, tree) = build_screen(rsc)?;
|
||||
ui_state.set_root(tree);
|
||||
ui_state.set_root(rsc, tree);
|
||||
Ok(opened)
|
||||
}
|
||||
|
||||
|
||||
@@ -224,14 +224,14 @@ impl TranscriptScreen {
|
||||
|
||||
pub fn build<Rsc: HasEvents>(
|
||||
rsc: &mut Rsc,
|
||||
ui_state: &mut impl HasRoot,
|
||||
ui_state: &mut impl HasRoot<Rsc>,
|
||||
rows: Vec<FoldedRow>,
|
||||
) -> TranscriptScreen
|
||||
where
|
||||
Rsc::State: FocusHost + OpenUrl,
|
||||
{
|
||||
let (screen, tree) = build_tree(rsc, rows);
|
||||
ui_state.set_root(tree);
|
||||
ui_state.set_root(rsc, tree);
|
||||
screen
|
||||
}
|
||||
|
||||
@@ -281,10 +281,9 @@ where
|
||||
{
|
||||
list.on(CursorSense::drag_senses(), move |ctx, rsc: &mut Rsc| {
|
||||
let input = &ctx.data;
|
||||
rsc.with_nearest_controller::<SelectionController, _>(
|
||||
list,
|
||||
|id, selection, rsc| selection.drag(id, rsc, input),
|
||||
);
|
||||
rsc.with_nearest_controller::<SelectionController, _>(list, |id, selection, rsc| {
|
||||
selection.drag(id, rsc, input)
|
||||
});
|
||||
})
|
||||
.add(rsc);
|
||||
}
|
||||
|
||||
@@ -214,10 +214,9 @@ where
|
||||
let (pos, size) = (ctx.data.pos, ctx.data.size);
|
||||
let input = &ctx.data;
|
||||
let outcome = rsc
|
||||
.with_nearest_controller::<SelectionController, _>(
|
||||
field,
|
||||
|id, selection, rsc| selection.drag(id, rsc, input),
|
||||
)
|
||||
.with_nearest_controller::<SelectionController, _>(field, |id, selection, rsc| {
|
||||
selection.drag(id, rsc, input)
|
||||
})
|
||||
.unwrap_or(SelectionInput::Tapped);
|
||||
// A *tap*, decided by the same `DragArbiter` the pan and
|
||||
// the selection are: a gesture that panned the list past
|
||||
|
||||
@@ -11,10 +11,9 @@ pub(crate) fn on_tap<Rsc: HasEvents>(
|
||||
ptr.on(CursorSense::drag_senses(), move |ctx, rsc: &mut Rsc| {
|
||||
let input = &ctx.data;
|
||||
let outcome = rsc
|
||||
.with_nearest_controller::<SelectionController, _>(
|
||||
list,
|
||||
|id, selection, rsc| selection.drag(id, rsc, input),
|
||||
)
|
||||
.with_nearest_controller::<SelectionController, _>(list, |id, selection, rsc| {
|
||||
selection.drag(id, rsc, input)
|
||||
})
|
||||
.unwrap_or(SelectionInput::Tapped);
|
||||
if outcome == SelectionInput::Tapped {
|
||||
f(rsc);
|
||||
|
||||
@@ -14,7 +14,7 @@ fn opened() -> (Harness, ai_app::ui::TranscriptScreen) {
|
||||
.span(Dir::DOWN)
|
||||
.add_strong(&mut h.rsc)
|
||||
.any();
|
||||
h.state.set_root(root);
|
||||
h.state.set_root(&mut h.rsc, root);
|
||||
h.frame(0);
|
||||
h.frame(PHONE_FRAME_MS);
|
||||
(h, opened.screen)
|
||||
|
||||
Reference in new issue
Block a user