pub struct FloatConfig {
pub anchor: FloatAnchor,
pub anchor_point: (Align, Align),
pub self_point: (Align, Align),
pub offset: Vec2Offset,
pub fit: bool,
pub clip: bool,
}Expand description
Takes a node out of flex flow: it doesn’t consume space in its parent,
sizes Grow/Percent against its anchor, is positioned by attach points,
and escapes ancestor clips unless FloatConfig::clip keeps it in its
parent’s. It paints as a layer of its own — above the
in-flow tree and every float that opened before it, under every one
that opened after — and takes input in the same order
(docs/adr/0023-layers-stack-in-the-order-they-open.md).
Fields§
§anchor: FloatAnchor§anchor_point: (Align, Align)Attach point on the anchor rect (horizontal, vertical).
self_point: (Align, Align)Attach point on the floating node itself.
offset: Vec2OffsetExtra offset applied after attaching, logical px.
fit: boolKeep the float on screen: if the attached placement leaves the viewport on an axis, mirror the attachment across the anchor on that axis (below ↔ above, after ↔ before) when that fits better, then clamp whatever still overflows. Tooltips/menus want this.
This is the in-window approximation of an OS popup, and it is the
one to reach for first: a float costs one tree, one hit list and one
draw call. What it cannot do is leave the window — a dropdown taller
than the viewport, or a menu with nowhere in-window to go, gets
clamped rather than placed. Those want a popup window — which this
release does not have: it is docs/adr/0004-multi-window.md’s step
4, and the ADR’s Consequences say so. So fit plus a modal float
(docs/adr/0003-modal-surfaces.md) is not merely the first thing to
reach for today, it is the only thing.
clip: boolTake the parent’s clip, as a child does, instead of escaping every
ancestor’s: a node on a clip canvas panned past the canvas’s edge
is cut there, and its hit region with it, rather than drawn over
and clicked through the toolbar beside it (backlog F90). Only a
FloatAnchor::Parent float reads it — a viewport or node anchor
is placed against something other than the parent, and escapes
with it set or not. Paint order is unchanged: the float is still a
layer of its own above its in-flow siblings, only cut. A line or
polygon anchored in its parent’s box has it set by the core (ADR
0010, decision 5, as amended).
Implementations§
Source§impl FloatConfig
impl FloatConfig
pub fn parent() -> FloatConfig
pub fn viewport() -> FloatConfig
Sourcepub fn below() -> FloatConfig
pub fn below() -> FloatConfig
Tooltip-style: hang below the parent, centered.
Sourcepub fn above() -> FloatConfig
pub fn above() -> FloatConfig
Tooltip-style: hover above the parent, centered.
pub fn at(self, x: Align, y: Align) -> FloatConfig
pub fn self_at(self, x: Align, y: Align) -> FloatConfig
Sourcepub fn inside(self, x: Align, y: Align) -> FloatConfig
pub fn inside(self, x: Align, y: Align) -> FloatConfig
Self::at and Self::self_at at the same point: the float sits
inside the anchor against that edge or corner — (End, End) is a
toast in the viewport’s bottom-right, (Center, Center) a dialog.
pub fn offset(self, x: f32, y: f32) -> FloatConfig
Sourcepub fn fit(self) -> FloatConfig
pub fn fit(self) -> FloatConfig
Flip across the anchor / clamp as needed to stay in the viewport;
see FloatConfig::fit for where that stops being enough.
Sourcepub fn clipped(self) -> FloatConfig
pub fn clipped(self) -> FloatConfig
Cut by the parent’s clip instead of escaping it; see
FloatConfig::clip for which anchors read it.
Sourcepub fn clipped_by_parent(&self) -> bool
pub fn clipped_by_parent(&self) -> bool
Whether this float takes its parent’s clip: FloatConfig::clip
declared on a parent-anchored float. The one reading both paint
passes and the hit regions share.
Sourcepub fn preset_at(i: usize) -> Option<FloatConfig>
pub fn preset_at(i: usize) -> Option<FloatConfig>
A preset by its wire index — its position in FLOAT_PRESETS, which
is what the binary protocol carries and what KUI_FLOAT_* counts
from. None for an index no preset claims.
Sourcepub fn preset(name: &str) -> Option<FloatConfig>
pub fn preset(name: &str) -> Option<FloatConfig>
A preset by name. Every binding that spells a float as a word —
float="below", float = "above", kui_spec_float_preset — resolves
it here, so “below” cannot mean one thing in JS and another in Lua.
Sourcepub fn build(
base: FloatConfig,
anchor_at: Option<(Align, Align)>,
self_at: Option<(Align, Align)>,
dx: Option<f32>,
dy: Option<f32>,
fit: bool,
clip: bool,
) -> FloatConfig
pub fn build( base: FloatConfig, anchor_at: Option<(Align, Align)>, self_at: Option<(Align, Align)>, dx: Option<f32>, dy: Option<f32>, fit: bool, clip: bool, ) -> FloatConfig
One config from the pieces a binding can extract without deciding
anything: a base preset (from FloatConfig::preset or
FloatConfig::preset_at) and the overrides that were actually
declared. None leaves the base’s own value — that is what lets
float="below" keep its 6px gap while { anchor: "below", dx: 2 }
moves it sideways without flattening the gap to zero. fit and
clip are ORed in: no preset sets either.
Trait Implementations§
Source§impl Clone for FloatConfig
impl Clone for FloatConfig
Source§fn clone(&self) -> FloatConfig
fn clone(&self) -> FloatConfig
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 FloatConfig
Source§impl Debug for FloatConfig
impl Debug for FloatConfig
Source§impl Default for FloatConfig
impl Default for FloatConfig
Source§fn default() -> FloatConfig
fn default() -> FloatConfig
Source§impl PartialEq for FloatConfig
impl PartialEq for FloatConfig
impl StructuralPartialEq for FloatConfig
Auto Trait Implementations§
impl Freeze for FloatConfig
impl RefUnwindSafe for FloatConfig
impl Send for FloatConfig
impl Sync for FloatConfig
impl Unpin for FloatConfig
impl UnsafeUnpin for FloatConfig
impl UnwindSafe for FloatConfig
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.