pub struct BoardModel {
pub id: WidgetId,
pub columns: Vec<BoardColumn>,
pub selected_card_id: Option<CardId>,
pub col_scroll_offset: usize,
}Expand description
Top-level model for a [Board] widget.
The host constructs this from its own state each frame and passes it
to backend.draw_board(rect, &model).
§Examples
use quadraui::{board_layout, BoardCard, BoardColumn, BoardHit, BoardMeasure, BoardModel, WidgetId};
let model = BoardModel {
id: WidgetId::new("board:issues"),
columns: vec![BoardColumn {
id: WidgetId::new("column:backlog"),
title: "Backlog".to_string(),
cards: vec![BoardCard {
id: WidgetId::new("card:1"),
title: "Fix flaky test".to_string(),
labels: vec![],
badges: vec![],
hint: None,
}],
scroll_offset: 0,
}],
selected_card_id: None,
col_scroll_offset: 0,
};
let measure = BoardMeasure::new(20.0, 1.0, 1.0, 3.0, 1.0);
let layout = board_layout(&model, 0.0, 0.0, 80.0, 24.0, measure);
assert_eq!(layout.hit_test(1.0, 2.0), BoardHit::Card(WidgetId::new("card:1")));Fields§
§id: WidgetIdUnique identifier for this board widget.
columns: Vec<BoardColumn>Ordered list of columns rendered left-to-right.
selected_card_id: Option<CardId>The currently selected card, if any (host-owned).
col_scroll_offset: usizeHorizontal scroll: index of the first visible column.
Updated by the host in response to h/l navigation when
the board overflows the viewport.
Implementations§
Source§impl BoardModel
impl BoardModel
Sourcepub fn move_selection(&mut self, dir: MoveDir)
pub fn move_selection(&mut self, dir: MoveDir)
Handle a keyboard event on the focused board.
Returns a BoardAction if the key is consumed, None if the
caller should handle it.
§Keybindings (v1 hardcoded, generic navigation only)
| Key | Action |
|---|---|
j / ↓ | Move selection down |
k / ↑ | Move selection up |
h / ← | Move selection left (between columns) |
l / → | Move selection right (between columns) |
Enter | Open issue |
g | Jump to top of focused column |
G | Jump to bottom of focused column |
Hosts that need workflow-specific verbs (e.g. merge, dispatch,
review) should handle those keys themselves before or after calling
this method — it only ever consumes the generic navigation keys
above.
Move the selection in the given direction, updating selected_card_id
and col_scroll_offset as needed.
Callers that want the BoardAction for external routing should use
[handle_key] instead. This method is for apps (like BoardApp) that
just want the state to update immediately.
Sourcepub fn jump_to_top(&mut self)
pub fn jump_to_top(&mut self)
Select the first card in the currently-focused column.
Sourcepub fn jump_to_bottom(&mut self)
pub fn jump_to_bottom(&mut self)
Select the last card in the currently-focused column.
Sourcepub fn selected_col_index(&self) -> Option<usize>
pub fn selected_col_index(&self) -> Option<usize>
Return the column index of the currently-selected card, if any.
Sourcepub fn selected_position(&self) -> Option<(usize, usize)>
pub fn selected_position(&self) -> Option<(usize, usize)>
Return (col_index, card_index) of the currently-selected card, or
None if no card is selected (or the selected id is no longer
present on the board).
pub fn handle_key( &self, key: &str, _modifiers: Modifiers, ) -> Option<BoardAction>
Trait Implementations§
Source§impl Clone for BoardModel
impl Clone for BoardModel
Source§impl Debug for BoardModel
impl Debug for BoardModel
Source§impl<'de> Deserialize<'de> for BoardModel
impl<'de> Deserialize<'de> for BoardModel
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for BoardModel
Source§impl PartialEq for BoardModel
impl PartialEq for BoardModel
Source§impl Serialize for BoardModel
impl Serialize for BoardModel
impl StructuralPartialEq for BoardModel
Auto Trait Implementations§
impl Freeze for BoardModel
impl RefUnwindSafe for BoardModel
impl Send for BoardModel
impl Sync for BoardModel
impl Unpin for BoardModel
impl UnsafeUnpin for BoardModel
impl UnwindSafe for BoardModel
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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