#[non_exhaustive]pub struct OverlayOptions {Show 13 fields
pub width: Option<Dim>,
pub min_width: Option<u16>,
pub max_height: Option<Dim>,
pub anchor: OverlayAnchor,
pub offset_x: i16,
pub offset_y: i16,
pub row: Option<Dim>,
pub col: Option<Dim>,
pub margin: OverlayMargin,
pub z: i16,
pub min_viewport: Size,
pub modal: bool,
pub fill_height: bool,
}Expand description
Declarative sizing, placement, and visibility options for an overlay.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.width: Option<Dim>Requested width, resolved against the full viewport width.
min_width: Option<u16>Minimum width applied before fitting the overlay to its margins.
max_height: Option<Dim>Maximum height, resolved against the full viewport height.
anchor: OverlayAnchorViewport position used when no explicit row or column is supplied.
offset_x: i16Horizontal displacement from the resolved position.
offset_y: i16Vertical displacement from the resolved position.
row: Option<Dim>Explicit absolute or percentage row position.
col: Option<Dim>Explicit absolute or percentage column position.
margin: OverlayMarginInsets from viewport edges.
z: i16Stacking height: higher layers composite above lower ones; ties stack by creation order.
min_viewport: SizeSmallest viewport in which the overlay is visible.
modal: boolWhether the layer captures the keyboard while visible (the default).
A non-modal layer — a sidebar, a status rail — leaves keys and paste
with the base tree unless explicitly focused through
crate::Ui::focus_overlay, and never triggers the crate::App
alternate-screen hold: the document keeps committing to native
scrollback beneath it while the layer rides the live viewport.
fill_height: boolStretches a retained overlay tree to the full available viewport
height (after margin and max_height) instead of its content
height, so grow/valign fill the band like a full-height rail.
Raw-frame Layer hosts control their frame height directly; the
band there always follows the frame.
Implementations§
Source§impl OverlayOptions
impl OverlayOptions
Sourcepub const fn width(self, width: Dim) -> Self
pub const fn width(self, width: Dim) -> Self
Sets the requested width.
Examples found in repository?
56 pub fn new(model: &str, ctx: &UiContext) -> Self {
57 let options = OverlayOptions::default()
58 .anchor(OverlayAnchor::Right)
59 .width(Dim::Cells(WIDTH))
60 .non_modal()
61 .min_viewport(MIN_VIEWPORT);
62 let mut ui = build(model, ctx);
63 // The rail starts without the keyboard: no focus chrome or frame
64 // cursor until `toggle` or a click hands it over.
65 ui.blur();
66 Self { ui, options, open: true, focused: false, elapsed_seconds: 0, height: 0 }
67 }More examples
257 pub fn open(current: usize, ctx: &UiContext) -> Self {
258 let options = OverlayOptions::default()
259 .anchor(OverlayAnchor::Bottom)
260 .width(Dim::Pct(100))
261 .z(10);
262 let mode = Mode::Models;
263 let tier = PerfTier::Full;
264 let ui = build(mode, tier, current, "", 5, 100, ctx);
265 let mut picker = Self {
266 ui,
267 mode,
268 tier,
269 current,
270 ctx: ctx.clone(),
271 options,
272 query: Str::default(),
273 rows: 5,
274 };
275 picker.show_detail(Some(current));
276 picker
277 }35pub(crate) fn show_picker(ui: &mut Ui) -> OverlayId {
36 ui.show_overlay(
37 dom! {
38 <box border=round title="Switch Model">
39 <col gap=1>
40 <text dim>{"Session-only switch — role models stay unchanged"}</text>
41 <select id=model>
42 for (value, label, stats) in MODELS {
43 <option value={value} desc={stats}>{label}</option>
44 }
45 </select>
46 </col>
47 </box>
48 },
49 OverlayOptions::default()
50 .anchor(OverlayAnchor::Center)
51 .width(Dim::Pct(70))
52 .min_width(48)
53 .max_height(Dim::Pct(60))
54 .min_viewport(Size::new(40, 8)),
55 )
56}
57
58/// Opens the keybinding help layer.
59pub(crate) fn show_help(ui: &mut Ui) -> OverlayId {
60 ui.show_overlay(
61 dom! {
62 <box border=round title="Help">
63 <col>
64 <text>{"Ctrl+K switch model"}</text>
65 <text>{"Ctrl+G toggle this help"}</text>
66 <text>{"Esc close top layer"}</text>
67 <text>{"Ctrl+C quit"}</text>
68 </col>
69 </box>
70 },
71 OverlayOptions::default()
72 .anchor(OverlayAnchor::BottomRight)
73 .width(Dim::Cells(30))
74 .margin(OverlayMargin::uniform(1)),
75 )
76}108 pub fn layer(&mut self, viewport: Size) -> Layer<'_> {
109 let width = (viewport.width * 3 / 5).max(48).min(viewport.width);
110 let rows = (viewport.height / 2).saturating_sub(FRAME_ROWS).max(5);
111 if rows != self.rows {
112 self.rows = rows;
113 // One query row plus the windowed list.
114 self
115 .ui
116 .set_prop("commands", Prop::H, rows.saturating_add(1));
117 }
118 if self.ui.frame().size().width != width {
119 self.ui = build(&self.query, self.rows, width, &self.ctx);
120 }
121 self.options = self.options.width(Dim::Cells(width));
122 Layer { frame: self.ui.frame(), options: &self.options, active: true }
123 }Sourcepub const fn min_width(self, min_width: u16) -> Self
pub const fn min_width(self, min_width: u16) -> Self
Sets the minimum width in cells.
Examples found in repository?
35pub(crate) fn show_picker(ui: &mut Ui) -> OverlayId {
36 ui.show_overlay(
37 dom! {
38 <box border=round title="Switch Model">
39 <col gap=1>
40 <text dim>{"Session-only switch — role models stay unchanged"}</text>
41 <select id=model>
42 for (value, label, stats) in MODELS {
43 <option value={value} desc={stats}>{label}</option>
44 }
45 </select>
46 </col>
47 </box>
48 },
49 OverlayOptions::default()
50 .anchor(OverlayAnchor::Center)
51 .width(Dim::Pct(70))
52 .min_width(48)
53 .max_height(Dim::Pct(60))
54 .min_viewport(Size::new(40, 8)),
55 )
56}Sourcepub const fn max_height(self, max_height: Dim) -> Self
pub const fn max_height(self, max_height: Dim) -> Self
Sets the maximum height.
Examples found in repository?
35pub(crate) fn show_picker(ui: &mut Ui) -> OverlayId {
36 ui.show_overlay(
37 dom! {
38 <box border=round title="Switch Model">
39 <col gap=1>
40 <text dim>{"Session-only switch — role models stay unchanged"}</text>
41 <select id=model>
42 for (value, label, stats) in MODELS {
43 <option value={value} desc={stats}>{label}</option>
44 }
45 </select>
46 </col>
47 </box>
48 },
49 OverlayOptions::default()
50 .anchor(OverlayAnchor::Center)
51 .width(Dim::Pct(70))
52 .min_width(48)
53 .max_height(Dim::Pct(60))
54 .min_viewport(Size::new(40, 8)),
55 )
56}Sourcepub const fn z(self, z: i16) -> Self
pub const fn z(self, z: i16) -> Self
Sets the stacking height.
Examples found in repository?
More examples
257 pub fn open(current: usize, ctx: &UiContext) -> Self {
258 let options = OverlayOptions::default()
259 .anchor(OverlayAnchor::Bottom)
260 .width(Dim::Pct(100))
261 .z(10);
262 let mode = Mode::Models;
263 let tier = PerfTier::Full;
264 let ui = build(mode, tier, current, "", 5, 100, ctx);
265 let mut picker = Self {
266 ui,
267 mode,
268 tier,
269 current,
270 ctx: ctx.clone(),
271 options,
272 query: Str::default(),
273 rows: 5,
274 };
275 picker.show_detail(Some(current));
276 picker
277 }Sourcepub const fn anchor(self, anchor: OverlayAnchor) -> Self
pub const fn anchor(self, anchor: OverlayAnchor) -> Self
Sets the fallback anchor position.
Examples found in repository?
More examples
56 pub fn new(model: &str, ctx: &UiContext) -> Self {
57 let options = OverlayOptions::default()
58 .anchor(OverlayAnchor::Right)
59 .width(Dim::Cells(WIDTH))
60 .non_modal()
61 .min_viewport(MIN_VIEWPORT);
62 let mut ui = build(model, ctx);
63 // The rail starts without the keyboard: no focus chrome or frame
64 // cursor until `toggle` or a click hands it over.
65 ui.blur();
66 Self { ui, options, open: true, focused: false, elapsed_seconds: 0, height: 0 }
67 }257 pub fn open(current: usize, ctx: &UiContext) -> Self {
258 let options = OverlayOptions::default()
259 .anchor(OverlayAnchor::Bottom)
260 .width(Dim::Pct(100))
261 .z(10);
262 let mode = Mode::Models;
263 let tier = PerfTier::Full;
264 let ui = build(mode, tier, current, "", 5, 100, ctx);
265 let mut picker = Self {
266 ui,
267 mode,
268 tier,
269 current,
270 ctx: ctx.clone(),
271 options,
272 query: Str::default(),
273 rows: 5,
274 };
275 picker.show_detail(Some(current));
276 picker
277 }35pub(crate) fn show_picker(ui: &mut Ui) -> OverlayId {
36 ui.show_overlay(
37 dom! {
38 <box border=round title="Switch Model">
39 <col gap=1>
40 <text dim>{"Session-only switch — role models stay unchanged"}</text>
41 <select id=model>
42 for (value, label, stats) in MODELS {
43 <option value={value} desc={stats}>{label}</option>
44 }
45 </select>
46 </col>
47 </box>
48 },
49 OverlayOptions::default()
50 .anchor(OverlayAnchor::Center)
51 .width(Dim::Pct(70))
52 .min_width(48)
53 .max_height(Dim::Pct(60))
54 .min_viewport(Size::new(40, 8)),
55 )
56}
57
58/// Opens the keybinding help layer.
59pub(crate) fn show_help(ui: &mut Ui) -> OverlayId {
60 ui.show_overlay(
61 dom! {
62 <box border=round title="Help">
63 <col>
64 <text>{"Ctrl+K switch model"}</text>
65 <text>{"Ctrl+G toggle this help"}</text>
66 <text>{"Esc close top layer"}</text>
67 <text>{"Ctrl+C quit"}</text>
68 </col>
69 </box>
70 },
71 OverlayOptions::default()
72 .anchor(OverlayAnchor::BottomRight)
73 .width(Dim::Cells(30))
74 .margin(OverlayMargin::uniform(1)),
75 )
76}Sourcepub const fn margin(self, margin: OverlayMargin) -> Self
pub const fn margin(self, margin: OverlayMargin) -> Self
Sets the viewport-edge insets.
Examples found in repository?
59pub(crate) fn show_help(ui: &mut Ui) -> OverlayId {
60 ui.show_overlay(
61 dom! {
62 <box border=round title="Help">
63 <col>
64 <text>{"Ctrl+K switch model"}</text>
65 <text>{"Ctrl+G toggle this help"}</text>
66 <text>{"Esc close top layer"}</text>
67 <text>{"Ctrl+C quit"}</text>
68 </col>
69 </box>
70 },
71 OverlayOptions::default()
72 .anchor(OverlayAnchor::BottomRight)
73 .width(Dim::Cells(30))
74 .margin(OverlayMargin::uniform(1)),
75 )
76}Sourcepub const fn min_viewport(self, min_viewport: Size) -> Self
pub const fn min_viewport(self, min_viewport: Size) -> Self
Sets the minimum viewport required for visibility.
Examples found in repository?
56 pub fn new(model: &str, ctx: &UiContext) -> Self {
57 let options = OverlayOptions::default()
58 .anchor(OverlayAnchor::Right)
59 .width(Dim::Cells(WIDTH))
60 .non_modal()
61 .min_viewport(MIN_VIEWPORT);
62 let mut ui = build(model, ctx);
63 // The rail starts without the keyboard: no focus chrome or frame
64 // cursor until `toggle` or a click hands it over.
65 ui.blur();
66 Self { ui, options, open: true, focused: false, elapsed_seconds: 0, height: 0 }
67 }More examples
35pub(crate) fn show_picker(ui: &mut Ui) -> OverlayId {
36 ui.show_overlay(
37 dom! {
38 <box border=round title="Switch Model">
39 <col gap=1>
40 <text dim>{"Session-only switch — role models stay unchanged"}</text>
41 <select id=model>
42 for (value, label, stats) in MODELS {
43 <option value={value} desc={stats}>{label}</option>
44 }
45 </select>
46 </col>
47 </box>
48 },
49 OverlayOptions::default()
50 .anchor(OverlayAnchor::Center)
51 .width(Dim::Pct(70))
52 .min_width(48)
53 .max_height(Dim::Pct(60))
54 .min_viewport(Size::new(40, 8)),
55 )
56}Sourcepub const fn non_modal(self) -> Self
pub const fn non_modal(self) -> Self
Leaves keys and paste with the base tree while the layer is visible.
crate::Ui::focus_overlay hands the keyboard to the layer on
demand; a click inside its band does the same, and a click outside
(or an unconsumed Esc) returns it.
Examples found in repository?
56 pub fn new(model: &str, ctx: &UiContext) -> Self {
57 let options = OverlayOptions::default()
58 .anchor(OverlayAnchor::Right)
59 .width(Dim::Cells(WIDTH))
60 .non_modal()
61 .min_viewport(MIN_VIEWPORT);
62 let mut ui = build(model, ctx);
63 // The rail starts without the keyboard: no focus chrome or frame
64 // cursor until `toggle` or a click hands it over.
65 ui.blur();
66 Self { ui, options, open: true, focused: false, elapsed_seconds: 0, height: 0 }
67 }Sourcepub const fn fill_height(self) -> Self
pub const fn fill_height(self) -> Self
Stretches a retained overlay tree to the full available viewport height.
Trait Implementations§
Source§impl Clone for OverlayOptions
impl Clone for OverlayOptions
Source§fn clone(&self) -> OverlayOptions
fn clone(&self) -> OverlayOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for OverlayOptions
Source§impl Debug for OverlayOptions
impl Debug for OverlayOptions
Source§impl Default for OverlayOptions
impl Default for OverlayOptions
impl Eq for OverlayOptions
Source§impl PartialEq for OverlayOptions
impl PartialEq for OverlayOptions
impl StructuralPartialEq for OverlayOptions
Auto Trait Implementations§
impl Freeze for OverlayOptions
impl RefUnwindSafe for OverlayOptions
impl Send for OverlayOptions
impl Sync for OverlayOptions
impl Unpin for OverlayOptions
impl UnsafeUnpin for OverlayOptions
impl UnwindSafe for OverlayOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more