pub struct WindowConfig {
pub kind: WindowKind,
pub size: Size,
pub activates: bool,
pub anchor: Rect,
}Expand description
What a frame says about a window it declares (Core::declare_window).
Plain data by ADR 0004 decision 5 — no title, no callbacks — so a
WindowCommand stays Copy and equality is derived, which is how the
diff tells two declarations of one name apart.
Read on the opening edge only. The config that reaches
WindowCommand::Open is the one the declaration carried on the frame
it started; a live window’s config is never looked at again, so
re-declaring "palette" at a new size does not resize it. The user owns
a window’s geometry once it exists.
Fields§
§kind: WindowKind§size: SizeInitial inner size, logical px.
activates: boolWhether opening it takes OS focus. True for a normal window;
WindowConfig::popup turns it off, so the field that opened a
dropdown keeps the ring while the list is up.
anchor: RectWindowKind::Popup only: what the popup is placed against, as a
rect in the declaring window’s logical viewport coordinates —
which is exactly the rect an onLayout node reports, so an app
needs no new geometry query to fill it. The driver resolves it to
screen coordinates against the owner’s own position and puts the
popup below it, flipping above when the display’s bottom edge is
nearer than the popup is tall.
Read on the opening edge with the rest of the config and never
again: a popup that has to follow a moving anchor stops being
declared and is declared again, which is what a dropdown does when
its field scrolls away anyway. Ignored by a Normal window.
Implementations§
Source§impl WindowConfig
impl WindowConfig
Sourcepub const DEFAULT_SIZE: Size
pub const DEFAULT_SIZE: Size
The size a declaration that names none gets.
Sourcepub fn sized(w: f32, h: f32) -> WindowConfig
pub fn sized(w: f32, h: f32) -> WindowConfig
A normal, activating window of w x h logical px.
Sourcepub fn popup(anchor: Rect, w: f32, h: f32) -> WindowConfig
pub fn popup(anchor: Rect, w: f32, h: f32) -> WindowConfig
A WindowKind::Popup of w x h logical px placed against
anchor — the rect, in the declaring window’s viewport
coordinates, that an onLayout handler reported for the field or
button the menu belongs to.
Non-activating, which is the default a popup wants and the reason
this is a constructor rather than a kind you set: a popup that
takes OS focus blurs whatever opened it. Set activates back to
true afterwards for the rare surface that should steal focus.
Sourcepub fn of_kind(kind: WindowKind) -> WindowConfig
pub fn of_kind(kind: WindowKind) -> WindowConfig
The defaults for a window of kind: the one decision the kind
makes on its own is whether opening it takes OS focus — a popup
that did would blur the field that opened it, so it does not unless
asked. Every binding’s window entry starts from this.
Sourcepub fn from_value(v: &Value) -> Result<(String, WindowConfig), String>
pub fn from_value(v: &Value) -> Result<(String, WindowConfig), String>
A declaration from plain data: a bare name (the defaults), or a map
with name, kind ("normal" | "popup"), width and height
(both and positive, or the default size), activates, and the anchor rect
({x, y, w, h}) a popup is placed against. Returns the name with
the config. An entry is plain data with a fixed shape, not a node’s
loose prop bag, so a value that does nothing is refused rather than
dropped: a kind kui does not have would otherwise open a normal
window and read as the popup having worked.
Trait Implementations§
Source§impl Clone for WindowConfig
impl Clone for WindowConfig
Source§fn clone(&self) -> WindowConfig
fn clone(&self) -> WindowConfig
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 WindowConfig
Source§impl Debug for WindowConfig
impl Debug for WindowConfig
Source§impl Default for WindowConfig
impl Default for WindowConfig
Source§fn default() -> WindowConfig
fn default() -> WindowConfig
Source§impl PartialEq for WindowConfig
impl PartialEq for WindowConfig
impl StructuralPartialEq for WindowConfig
Auto Trait Implementations§
impl Freeze for WindowConfig
impl RefUnwindSafe for WindowConfig
impl Send for WindowConfig
impl Sync for WindowConfig
impl Unpin for WindowConfig
impl UnsafeUnpin for WindowConfig
impl UnwindSafe for WindowConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.