pub struct Scheduler { /* private fields */ }Expand description
A timeline of resources: a row for each person, room or account, a time axis across the top, and events as bars that can be dragged along the time and between rows, resized by their ends, and drawn on an empty stretch. Weekends are shaded, and only what is in view gets built, so large plans stay smooth.
The app holds the data: on_change reports where an event would go, and the
app stores it and passes the events again. can_drop can refuse a place.
From the keyboard, Tab reaches the events. Left and Right move one by a step, Up and Down to the next row, Shift with Left and Right resize it, Enter opens it and Delete removes it.
use ravenrs_reactive::State;
use ravenrs_widgets::{Date, Resource, Scheduler, SchedulerEvent, TimeAxis, TimePoint, Ui};
let first = Date::new(2026, 11, 1).unwrap();
let axis = State::new(TimeAxis::days(first, 30));
let start = TimePoint::from_date(first.add_days(4));
let scheduler = Scheduler::new(axis.binding())
.resources([Resource::new(1, "Ana"), Resource::new(2, "Bruno")])
.events([SchedulerEvent::new(7, 1, start, start.plus_days(3), "Férias")])
.on_change(|change| println!("{change:?}"));
let mut ui = Ui::new(scheduler, ravenrs_style::Theme::raven_light());
ui.update();Implementations§
Source§impl Scheduler
impl Scheduler
Sourcepub fn new(axis: Binding<TimeAxis>) -> Self
pub fn new(axis: Binding<TimeAxis>) -> Self
A scheduler over this stretch of time. Zooming and moving through time change axis.
Sourcepub fn resources(self, resources: impl IntoIterator<Item = Resource>) -> Self
pub fn resources(self, resources: impl IntoIterator<Item = Resource>) -> Self
The rows.
Sourcepub fn events(self, events: impl IntoIterator<Item = SchedulerEvent>) -> Self
pub fn events(self, events: impl IntoIterator<Item = SchedulerEvent>) -> Self
The bars. Those on no row are ignored.
Sourcepub fn ranges(self, ranges: impl IntoIterator<Item = SchedulerRange>) -> Self
pub fn ranges(self, ranges: impl IntoIterator<Item = SchedulerRange>) -> Self
Shaded stretches of time across all rows.
Sourcepub fn now(self, now: TimePoint) -> Self
pub fn now(self, now: TimePoint) -> Self
Draws a line at this moment, and offers a button to come back to it.
Sourcepub fn resource_width(self, width: f32) -> Self
pub fn resource_width(self, width: f32) -> Self
The width of the resources column (200 by default).
Sourcepub fn fill_rows(self, fill: bool) -> Self
pub fn fill_rows(self, fill: bool) -> Self
Rows share the height left over, so a few of them do not leave the timeline half empty. Off by default; a row never gets shorter than its bars.
Sourcepub fn card(self, card: bool) -> Self
pub fn card(self, card: bool) -> Self
The look of a full scheduler, as a card among other cards: rounded and with a soft shadow, a tinted header with the month over the days of the week, a line between the rows’ names and the timeline, and today’s column marked. Bars are a soft tint with a stripe of their color. Opens with today in the first column.
Sourcepub fn avatars(self, avatars: bool) -> Self
pub fn avatars(self, avatars: bool) -> Self
Shows the initials of each row’s name beside it, for rows that are people.
Sourcepub fn event_detail(
self,
detail: impl Fn(u64) -> Option<String> + 'static,
) -> Self
pub fn event_detail( self, detail: impl Fn(u64) -> Option<String> + 'static, ) -> Self
A second line on the bars, such as an amount, by the event’s id. Rows get taller.
What a right click on a bar offers, by the event’s id.
What a right click on an empty stretch offers, given the row and the time there.
Sourcepub fn toolbar(self, show: bool) -> Self
pub fn toolbar(self, show: bool) -> Self
The buttons to move through time and zoom (on by default).
Sourcepub fn on_change(self, handler: impl Fn(SchedulerChange) + 'static) -> Self
pub fn on_change(self, handler: impl Fn(SchedulerChange) + 'static) -> Self
An event was moved or resized.
Sourcepub fn on_create(self, handler: impl Fn(SchedulerChange) + 'static) -> Self
pub fn on_create(self, handler: impl Fn(SchedulerChange) + 'static) -> Self
A stretch of time was drawn on a row, by dragging or double-clicking.
Sourcepub fn on_open(self, handler: impl Fn(u64) + 'static) -> Self
pub fn on_open(self, handler: impl Fn(u64) + 'static) -> Self
An event was double-clicked, or Enter was pressed on it.
Sourcepub fn on_delete(self, handler: impl Fn(u64) + 'static) -> Self
pub fn on_delete(self, handler: impl Fn(u64) + 'static) -> Self
Delete was pressed on an event.
Sourcepub fn can_drop(self, rule: impl Fn(&SchedulerChange) -> bool + 'static) -> Self
pub fn can_drop(self, rule: impl Fn(&SchedulerChange) -> bool + 'static) -> Self
Says whether a place is allowed. A refused one shows in red and changes nothing.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Scheduler
impl !Send for Scheduler
impl !Sync for Scheduler
impl !UnwindSafe for Scheduler
impl Freeze for Scheduler
impl Unpin for Scheduler
impl UnsafeUnpin for Scheduler
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<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.