pub struct Timeline<Msg> { /* private fields */ }Expand description
A day as a strip: blocks of colour for what filled it, the empty track for the gaps between them — breaks, sleep, time not recorded.
The day is 24 hours from day_starts_at, midnight by default. Blocks
are placed on it by time: a block covers the cells its stretch falls in, and a block shorter
than a cell still takes one cell, so a two-minute task is never lost on a whole-day strip.
Blocks without a tone take the accent; two blocks of the same tone that
touch are told apart by a quieter first cell on the later one, a seam of tone rather than a
line. A block wide enough for its name with a cell of air on each side writes the name inside
itself.
Overlapping blocks stand in lanes: each block takes the first lane, from the top, in which nothing overlaps it, so a strip is one row tall for a day of consecutive blocks and grows a row for each block that runs at the same time as another. An area shorter than the lanes puts the lanes that do not fit into its last row, where the later block is drawn over the earlier and the selected block is always drawn on top.
Midnight. A day that starts at 18:00 runs to 18:00 the next day, so a block from 23:00 to
01:30 is one block in it. In a day that starts at midnight the same block is cut at the end
of the day; its part after midnight belongs to the next day’s strip, where the caller gives
it from 00:00. A range is placed in the same day, so a night from 22:00 to
06:00 is a range of a day that starts before 22:00.
Zoom is the visible range, which the caller owns: range shows a stretch
of the day across the whole width, and with on_zoom the timeline asks for
a new one — + and - step through a day, 12, 6 and 3 hours and one hour around the selected
block, 0 goes back to the whole day, and the mouse wheel zooms around the pointer once the
timeline holds the focus (a click gives it), so scrolling a page past a timeline never gets
caught in it. Selecting a block outside a zoomed range moves the range to it.
A timeline is a picture until it is given on_select. Then the block
under the pointer and the selected block step towards the text colour, ←/→ (or h/l) walk the
blocks in time order, Home and End go to the first and the last, and a click selects the
block under it. readout adds a row that writes the block being read — the
one under the pointer, else the selected one — as its name, its times and its length, so the
pointer and the keyboard read the same words. Nothing moves or resizes when a block is
hovered or selected: a timeline is a narrow strip, not a list, so it never slides.
Open edges and faint blocks. A block marked open_end or
open_start fades towards the track over its last or first two
cells, a tone transition rather than a glyph, and the readout writes what the open edge means.
A faint block stands halfway between its tone and the track. On a
terminal with few colours every fading cell and every faint tone is kept apart from the track,
so a block never looks shorter than it is.
axis adds a row of hours under the strip, an Axis placed with
the same arithmetic as the blocks. An area too short for every row gives up the axis first,
then the readout, then lanes. The strip is made of colour, so it reads the same in every glyph
mode; on a terminal with few colours a tone that would merge with the track or with its own
hovered step is pushed further until the two differ.
Style keys: timeline (track for the empty day, fill for a block without a tone, hover
and selected for the tones a block steps towards), timeline:focus (selected while the
keyboard is on the timeline), timeline-readout (fg for the name, detail for the times
and the length), and axis for the hours.
Implementations§
Source§impl<Msg: 'static> Timeline<Msg>
impl<Msg: 'static> Timeline<Msg>
Sourcepub fn new(blocks: impl IntoIterator<Item = TimeBlock>) -> Self
pub fn new(blocks: impl IntoIterator<Item = TimeBlock>) -> Self
A whole-day timeline of blocks, a day that starts at midnight.
Sourcepub fn day_starts_at(self, time: TimeOfDay) -> Self
pub fn day_starts_at(self, time: TimeOfDay) -> Self
Starts the day at time instead of midnight, e.g. 18:00 for a night shift, so blocks
across midnight stay whole.
Sourcepub fn range(self, from: TimeOfDay, to: TimeOfDay) -> Self
pub fn range(self, from: TimeOfDay, to: TimeOfDay) -> Self
Shows only the stretch from from to to across the whole width: into the next day when
to is not after from, the whole day when the two are the same. The range is kept
inside the day, so a range that runs past the day’s end stops there.
Sourcepub fn readout(self) -> Self
pub fn readout(self) -> Self
Adds a row that writes the block being read: its name, its times and its length.
Sourcepub fn selected(self, index: Option<usize>) -> Self
pub fn selected(self, index: Option<usize>) -> Self
The selected block, as an index into the blocks given.
Sourcepub fn disabled(self, disabled: bool) -> Self
pub fn disabled(self, disabled: bool) -> Self
Greys the timeline out: it cannot be focused, hovered, selected or zoomed.
Trait Implementations§
Source§impl<Msg: 'static> Widget<Msg> for Timeline<Msg>
impl<Msg: 'static> Widget<Msg> for Timeline<Msg>
Source§fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size
fn measure(&self, _cx: &mut MeasureCx<'_>, available: Size) -> Size
available.Source§fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
true when the event was used; unused key and scroll events
bubble to the parent widget.Source§fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
PaintCx::request_overlay. anchor is the area the widget was painted in.Source§fn children_mut(&mut self) -> &mut [Node<Msg>]
fn children_mut(&mut self) -> &mut [Node<Msg>]
Auto Trait Implementations§
impl<Msg> !RefUnwindSafe for Timeline<Msg>
impl<Msg> !Send for Timeline<Msg>
impl<Msg> !Sync for Timeline<Msg>
impl<Msg> !UnwindSafe for Timeline<Msg>
impl<Msg> Freeze for Timeline<Msg>
impl<Msg> Unpin for Timeline<Msg>
impl<Msg> UnsafeUnpin for Timeline<Msg>
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> 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