Redesign span layout around retained placement
This commit is contained in:
1 parent
4b69f3cc6b
commit
992482414f
23 files changed
+426
-1005
No files matched your search
+17
-31
@@ -1,4 +1,4 @@
|
||||
use crate::{Painter, Size};
|
||||
use crate::{Axis, Len, Painter, Size};
|
||||
use std::any::Any;
|
||||
|
||||
mod data;
|
||||
@@ -16,46 +16,28 @@ pub use view::*;
|
||||
pub use widgets::*;
|
||||
|
||||
pub trait Widget: Any {
|
||||
/// Draw within `painter.region()` (the space the parent offered) and
|
||||
/// report how much of it was actually used, per axis.
|
||||
fn draw(&mut self, painter: &mut Painter) -> Size;
|
||||
|
||||
/// True if `draw`'s output (both the primitives it writes and the
|
||||
/// `Size` it returns) is the same for any `painter.region()` of the
|
||||
/// same *content* -- an icon, a fixed-size rect, an already-decoded
|
||||
/// image at its natural size. Default `false` (redraw on any change to
|
||||
/// the offered region) because assuming independence wrongly produces
|
||||
/// a stale draw; a widget must opt in. See LAYOUT.md.
|
||||
/// An exact, context-free length known without drawing or inspecting children.
|
||||
fn size_hint(&self, _axis: Axis) -> Option<Len> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Whether the draw result is independent of the offered region.
|
||||
fn is_size_independent(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// What kind of control this is, for the AccessKit tree `ui::access`
|
||||
/// builds (RUST.md's I4). Only consulted for a widget that also has an
|
||||
/// explicit `.label()` -- an unnamed widget is never visited by that
|
||||
/// tree at all, named or not, so the default here costs nothing except
|
||||
/// at the handful of call sites that opt in. Default `Unknown` (a
|
||||
/// generic control with no more specific semantics); a widget with a
|
||||
/// real platform equivalent -- `TextEdit`'s `MultilineTextInput` --
|
||||
/// overrides it.
|
||||
fn requires_exact_region(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// The AccessKit role for a labelled widget.
|
||||
fn access_role(&self) -> accesskit::Role {
|
||||
accesskit::Role::Unknown
|
||||
}
|
||||
|
||||
/// Advance whatever this widget is animating to `now`, and say whether
|
||||
/// it is still animating afterwards. Default: nothing is, so a widget
|
||||
/// opts in by overriding this *and* by something calling
|
||||
/// [`crate::UiData::animate`] with its id when the animation starts --
|
||||
/// which is that animation's path out, since the driver
|
||||
/// ([`crate::UiData::tick_animations`]) drops every id whose `tick`
|
||||
/// answers `false`.
|
||||
///
|
||||
/// Called once per frame, before the frame's draw, by whichever
|
||||
/// backend owns the surface; a `true` answer is what makes that
|
||||
/// backend ask for another frame. So this is the only thing in iris
|
||||
/// that moves without an input event, and a widget that animates
|
||||
/// without registering simply never moves -- which is exactly how a
|
||||
/// finger fling looked on Iris's phone before this existed.
|
||||
/// Advance an animation and report whether it needs another frame.
|
||||
#[allow(unused_variables)]
|
||||
fn tick(&mut self, now: std::time::Instant) -> bool {
|
||||
false
|
||||
@@ -70,6 +52,10 @@ impl Widget for () {
|
||||
fn is_size_independent(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn size_hint(&self, _axis: Axis) -> Option<Len> {
|
||||
Some(Len::ZERO)
|
||||
}
|
||||
}
|
||||
|
||||
impl dyn Widget {
|
||||
|
||||
Reference in new issue
Block a user