pub struct CalendarState<const N: usize, Selection> {
pub area: Rect,
pub inner: Rect,
pub widget_area: Rect,
pub months: [MonthState<Selection>; N],
pub selection: Rc<RefCell<Selection>>,
pub focus: FocusFlag,
pub non_exhaustive: NonExhaustive,
/* private fields */
}Expand description
A struct that contains an array of MonthState to get a true calendar behaviour. There is no Widget for this, the exact layout is left to the user. This takes care of all the rest.
Fields§
§area: RectComplete area read only. renewed for each render.
inner: RectArea inside the block. read only. renewed for each render.
widget_area: RectArea inside the block. read only. renewed for each render.
months: [MonthState<Selection>; N]Months.
selection: Rc<RefCell<Selection>>Selection model.
focus: FocusFlagCalendar focus
non_exhaustive: NonExhaustiveImplementations§
Source§impl<const N: usize, Selection> CalendarState<N, Selection>
impl<const N: usize, Selection> CalendarState<N, Selection>
pub fn new() -> Selfwhere
Selection: Default,
pub fn named(name: &str) -> Selfwhere
Selection: Default,
Sourcepub fn set_step(&mut self, step: usize)
pub fn set_step(&mut self, step: usize)
Step-size when navigating outside the displayed calendar.
You can do a rolling calendar which goes back 1 month or a yearly calendar which goes back 12 months. Or any other value you like.
If you set step to 0 this kind of navigation is deactivated.
Default is 1.
Sourcepub fn step(&self) -> usize
pub fn step(&self) -> usize
Step-size when navigating outside the displayed calendar.
You can do a rolling calendar which goes back 1 month or a yearly calendar which goes back 12 months. Or any other value you like.
If you set step to 0 this kind of navigation is deactivated.
Default is 1.
Sourcepub fn set_today_policy(&mut self, home: TodayPolicy)
pub fn set_today_policy(&mut self, home: TodayPolicy)
How should move_to_today() work.
Sourcepub fn today_policy(&mut self) -> TodayPolicy
pub fn today_policy(&mut self) -> TodayPolicy
How should move_to_today() work.
Sourcepub fn set_primary_idx(&mut self, primary: usize)
pub fn set_primary_idx(&mut self, primary: usize)
Set the primary month for the calendar.
The primary month will be focused with Tab navigation. That means you can jump over all calendar months with just one Tab.
Movement within the calendar is possible with the arrow-keys. This will change the primary month for future Tab navigation.
Sourcepub fn primary_idx(&self) -> usize
pub fn primary_idx(&self) -> usize
The primary month for the calendar.
The primary month will be focused with Tab navigation. That means you can jump over all calendar months with just one Tab.
Movement within the calendar is possible with the arrow-keys. This will change the primary month for future Tab navigation.
Sourcepub fn set_start_date(&mut self, date: NaiveDate)
pub fn set_start_date(&mut self, date: NaiveDate)
Set the start-date for the calendar. This will set the start-date for each month.
Sourcepub fn start_date(&self) -> NaiveDate
pub fn start_date(&self) -> NaiveDate
Start-date of the calendar.
Sourcepub fn scroll_forward(&mut self, n: usize) -> CalOutcome
pub fn scroll_forward(&mut self, n: usize) -> CalOutcome
Changes the start-date for each month. Doesn’t change any selection.
Sourcepub fn scroll_back(&mut self, n: usize) -> CalOutcome
pub fn scroll_back(&mut self, n: usize) -> CalOutcome
Changes the start-date for each month. Doesn’t change any selection.
Sourcepub fn scroll_to(&mut self, date: NaiveDate) -> CalOutcome
pub fn scroll_to(&mut self, date: NaiveDate) -> CalOutcome
Changes the start-date for each month. Doesn’t change any selection.
Sourcepub fn screen_cursor(&self) -> Option<(u16, u16)>
pub fn screen_cursor(&self) -> Option<(u16, u16)>
Returns None
Source§impl<const N: usize, Selection> CalendarState<N, Selection>where
Selection: CalendarSelection,
impl<const N: usize, Selection> CalendarState<N, Selection>where
Selection: CalendarSelection,
Sourcepub fn is_selected(&self, date: NaiveDate) -> bool
pub fn is_selected(&self, date: NaiveDate) -> bool
Is the date selected?
Sourcepub fn lead_selection(&self) -> Option<NaiveDate>
pub fn lead_selection(&self) -> Option<NaiveDate>
Lead selection.
Source§impl<const N: usize> CalendarState<N, NoSelection>
impl<const N: usize> CalendarState<N, NoSelection>
Sourcepub fn prev_month(&mut self, n: usize) -> CalOutcome
pub fn prev_month(&mut self, n: usize) -> CalOutcome
Move to the previous month. Scrolls the calendar if necessary.
Sourcepub fn next_month(&mut self, n: usize) -> CalOutcome
pub fn next_month(&mut self, n: usize) -> CalOutcome
Move to the next month. Scrolls the calendar if necessary.
Sourcepub fn move_to_today(&mut self) -> CalOutcome
pub fn move_to_today(&mut self) -> CalOutcome
Move the calendar to show the current date.
Resets the start-dates according to TodayPolicy. Focuses the primary index and selects the current day.
pub fn move_to(&mut self, date: NaiveDate) -> CalOutcome
Source§impl<const N: usize> CalendarState<N, SingleSelection>
impl<const N: usize> CalendarState<N, SingleSelection>
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear the selection.
Sourcepub fn select(&mut self, date: NaiveDate) -> bool
pub fn select(&mut self, date: NaiveDate) -> bool
Select the given date. Doesn’t scroll the calendar.
Sourcepub fn move_to_today(&mut self) -> CalOutcome
pub fn move_to_today(&mut self) -> CalOutcome
Move the calendar to show the current date.
Resets the start-dates according to TodayPolicy. Focuses the primary index and selects the current day.
Sourcepub fn move_to(&mut self, date: NaiveDate) -> CalOutcome
pub fn move_to(&mut self, date: NaiveDate) -> CalOutcome
Move the calendar to show the given date.
Resets the start-dates according to TodayPolicy. Focuses the primary index and selects the current day.
Sourcepub fn prev_day(&mut self, n: usize) -> CalOutcome
pub fn prev_day(&mut self, n: usize) -> CalOutcome
Select previous day. Scrolls the calendar if necessary.
Sourcepub fn next_day(&mut self, n: usize) -> CalOutcome
pub fn next_day(&mut self, n: usize) -> CalOutcome
Select previous week. Scrolls the calendar if necessary.
Sourcepub fn prev_month(&mut self, n: usize) -> CalOutcome
pub fn prev_month(&mut self, n: usize) -> CalOutcome
Select the same day in the previous month.
This may shift the date a bit if it’s out of range of the new month.
Sourcepub fn next_month(&mut self, n: usize) -> CalOutcome
pub fn next_month(&mut self, n: usize) -> CalOutcome
Select the same day in the next month.
This may shift the date a bit if it’s out of range of the new month.
Source§impl<const N: usize> CalendarState<N, RangeSelection>
impl<const N: usize> CalendarState<N, RangeSelection>
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear the selection.
Sourcepub fn select_month(&mut self, date: NaiveDate, extend: bool) -> bool
pub fn select_month(&mut self, date: NaiveDate, extend: bool) -> bool
Select the full month of the date. Any date of the month will do. Can extend the selection to encompass the month. Any existing selection is buffed up to fill one month.
Sourcepub fn select_week(&mut self, date: NaiveDate, extend: bool) -> bool
pub fn select_week(&mut self, date: NaiveDate, extend: bool) -> bool
Select the week of the given date. Any date of the week will do. Can extend the selection to encompass the week. Any existing selection is buffed up to fill one week.
Sourcepub fn select_day(&mut self, date: NaiveDate, extend: bool) -> bool
pub fn select_day(&mut self, date: NaiveDate, extend: bool) -> bool
Select the given date. Can extend the selection to the given date.
Sourcepub fn select(&mut self, selection: (NaiveDate, NaiveDate)) -> bool
pub fn select(&mut self, selection: (NaiveDate, NaiveDate)) -> bool
Set the selection as (anchor, lead) pair.
Sourcepub fn selected_range(&self) -> Option<RangeInclusive<NaiveDate>>
pub fn selected_range(&self) -> Option<RangeInclusive<NaiveDate>>
Selection as NaiveDate range.
Sourcepub fn move_to_today(&mut self) -> CalOutcome
pub fn move_to_today(&mut self) -> CalOutcome
Move the calendar to today.
Uses TodayPolicy to build the new calendar and focuses and selects the given date.
Sourcepub fn move_to(&mut self, date: NaiveDate) -> CalOutcome
pub fn move_to(&mut self, date: NaiveDate) -> CalOutcome
Move the calendar the given day.
Uses TodayPolicy to build the new calendar and focuses and selects the given date.
Sourcepub fn move_to_prev(&mut self, months: Months, days: Days) -> CalOutcome
pub fn move_to_prev(&mut self, months: Months, days: Days) -> CalOutcome
Move the lead selection back by months/days. Clears the current selection and scrolls if necessary.
Sourcepub fn move_to_next(&mut self, months: Months, days: Days) -> CalOutcome
pub fn move_to_next(&mut self, months: Months, days: Days) -> CalOutcome
Move the lead selection forward by months/days. Clears the current selection and scrolls if necessary.
Sourcepub fn prev_day(&mut self, n: usize, extend: bool) -> CalOutcome
pub fn prev_day(&mut self, n: usize, extend: bool) -> CalOutcome
Select previous day.
Can extend the selection to include the new date.
Sourcepub fn next_day(&mut self, n: usize, extend: bool) -> CalOutcome
pub fn next_day(&mut self, n: usize, extend: bool) -> CalOutcome
Select next day.
Can extend the selection to include the new date.
Sourcepub fn prev_week(&mut self, n: usize, extend: bool) -> CalOutcome
pub fn prev_week(&mut self, n: usize, extend: bool) -> CalOutcome
Select the previous week.
When extending a selection, the current selection buffs up to fill one week.
Sourcepub fn next_week(&mut self, n: usize, extend: bool) -> CalOutcome
pub fn next_week(&mut self, n: usize, extend: bool) -> CalOutcome
Select the next week.
When extending a selection, the current selection buffs up to fill one week.
Sourcepub fn prev_month(&mut self, n: usize, extend: bool) -> CalOutcome
pub fn prev_month(&mut self, n: usize, extend: bool) -> CalOutcome
Select the previous month.
When extending a selection, the current selection buffs up to fill one month.
Sourcepub fn next_month(&mut self, n: usize, extend: bool) -> CalOutcome
pub fn next_month(&mut self, n: usize, extend: bool) -> CalOutcome
Select the previous month.
When extending a selection, the current selection buffs up to fill one month.
Trait Implementations§
Source§impl<const N: usize, Selection: Clone> Clone for CalendarState<N, Selection>
impl<const N: usize, Selection: Clone> Clone for CalendarState<N, Selection>
Source§fn clone(&self) -> CalendarState<N, Selection>
fn clone(&self) -> CalendarState<N, Selection>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const N: usize, Selection> Default for CalendarState<N, Selection>where
Selection: Default,
impl<const N: usize, Selection> Default for CalendarState<N, Selection>where
Selection: Default,
Source§impl<const N: usize> HandleEvent<Event, MouseOnly, CalOutcome> for CalendarState<N, NoSelection>
impl<const N: usize> HandleEvent<Event, MouseOnly, CalOutcome> for CalendarState<N, NoSelection>
Source§impl<const N: usize> HandleEvent<Event, MouseOnly, CalOutcome> for CalendarState<N, RangeSelection>
impl<const N: usize> HandleEvent<Event, MouseOnly, CalOutcome> for CalendarState<N, RangeSelection>
Source§impl<const N: usize> HandleEvent<Event, MouseOnly, CalOutcome> for CalendarState<N, SingleSelection>
impl<const N: usize> HandleEvent<Event, MouseOnly, CalOutcome> for CalendarState<N, SingleSelection>
Source§impl<const N: usize> HandleEvent<Event, Regular, CalOutcome> for CalendarState<N, NoSelection>
impl<const N: usize> HandleEvent<Event, Regular, CalOutcome> for CalendarState<N, NoSelection>
Source§impl<const N: usize> HandleEvent<Event, Regular, CalOutcome> for CalendarState<N, RangeSelection>
impl<const N: usize> HandleEvent<Event, Regular, CalOutcome> for CalendarState<N, RangeSelection>
Source§impl<const N: usize> HandleEvent<Event, Regular, CalOutcome> for CalendarState<N, SingleSelection>
impl<const N: usize> HandleEvent<Event, Regular, CalOutcome> for CalendarState<N, SingleSelection>
Source§impl<const N: usize, Selection> HasFocus for CalendarState<N, Selection>
impl<const N: usize, Selection> HasFocus for CalendarState<N, Selection>
Source§fn build(&self, builder: &mut FocusBuilder)
fn build(&self, builder: &mut FocusBuilder)
Source§fn is_focused(&self) -> bool
fn is_focused(&self) -> bool
Source§fn lost_focus(&self) -> bool
fn lost_focus(&self) -> bool
Source§fn gained_focus(&self) -> bool
fn gained_focus(&self) -> bool
Source§impl<const N: usize, Selection> HasScreenCursor for CalendarState<N, Selection>
impl<const N: usize, Selection> HasScreenCursor for CalendarState<N, Selection>
Source§impl<const N: usize, Selection> RelocatableState for CalendarState<N, Selection>
impl<const N: usize, Selection> RelocatableState for CalendarState<N, Selection>
Source§fn relocate(&mut self, shift: (i16, i16), clip: Rect)
fn relocate(&mut self, shift: (i16, i16), clip: Rect)
Source§fn relocate_popup(&mut self, shift: (i16, i16), clip: Rect)
fn relocate_popup(&mut self, shift: (i16, i16), clip: Rect)
Auto Trait Implementations§
impl<const N: usize, Selection> !Freeze for CalendarState<N, Selection>
impl<const N: usize, Selection> !RefUnwindSafe for CalendarState<N, Selection>
impl<const N: usize, Selection> !Send for CalendarState<N, Selection>
impl<const N: usize, Selection> !Sync for CalendarState<N, Selection>
impl<const N: usize, Selection> Unpin for CalendarState<N, Selection>
impl<const N: usize, Selection> !UnwindSafe for CalendarState<N, Selection>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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