[−][src]Struct kas::widget::List
A generic row/column widget
This type is generic over both directionality and the type of child widgets.
Essentially, it is a Vec
which also implements the Widget
trait.
Row
and Column
are parameterisations with set directionality.
BoxList
(and its derivatives BoxRow
, BoxColumn
) parameterise
W = Box<dyn Widget>
, thus supporting individually boxed child widgets.
This allows use of multiple types of child widget at the cost of extra
allocation, and requires dynamic dispatch of methods.
Configuring and resizing elements is O(n) in the number of children. Drawing and event handling is O(log n) in the number of children (assuming only a small number are visible at any one time).
For fixed configurations of child widgets, make_widget
can be used
instead. make_widget
has the advantage that it can support child widgets
of multiple types without allocation and via static dispatch, but the
disadvantage that drawing and event handling are O(n) in the number of
children.
Implementations
impl<D: Directional + Default, W: Widget> List<D, W>
[src]
pub fn new(widgets: Vec<W>) -> Self
[src]
Construct a new instance
This constructor is available where the direction is determined by the
type: for D: Directional + Default
. In other cases, use
List::new_with_direction
.
impl<D: Directional, W: Widget> List<D, W>
[src]
pub fn new_with_direction(direction: D, widgets: Vec<W>) -> Self
[src]
Construct a new instance with explicit direction
pub fn direction(&self) -> Direction
[src]
Get the direction of contents
pub fn is_empty(&self) -> bool
[src]
True if there are no child widgets
pub fn len(&self) -> usize
[src]
Returns the number of child widgets
pub fn capacity(&self) -> usize
[src]
Returns the number of elements the vector can hold without reallocating.
pub fn reserve(&mut self, additional: usize)
[src]
Reserves capacity for at least additional
more elements to be inserted
into the list. See documentation of Vec::reserve
.
pub fn clear(&mut self) -> TkAction
[src]
Remove all child widgets
Triggers a reconfigure action if any widget is removed.
pub fn push(&mut self, widget: W) -> TkAction
[src]
Append a child widget
Triggers a reconfigure action.
pub fn pop(&mut self) -> (Option<W>, TkAction)
[src]
Remove the last child widget
Returns None
if there are no children. Otherwise, this
triggers a reconfigure before the next draw operation.
Triggers a reconfigure action if any widget is removed.
pub fn insert(&mut self, index: usize, widget: W) -> TkAction
[src]
pub fn remove(&mut self, index: usize) -> (W, TkAction)
[src]
Removes the child widget at position index
Panics if index
is out of bounds.
Triggers a reconfigure action.
pub fn replace(&mut self, index: usize, widget: W) -> (W, TkAction)
[src]
pub fn extend<T: IntoIterator<Item = W>>(&mut self, iter: T) -> TkAction
[src]
Append child widgets from an iterator
Triggers a reconfigure action if any widgets are added.
pub fn resize_with<F: Fn(usize) -> W>(&mut self, len: usize, f: F) -> TkAction
[src]
Resize, using the given closure to construct new widgets
Triggers a reconfigure action.
pub fn retain<F: FnMut(&W) -> bool>(&mut self, f: F) -> TkAction
[src]
Retain only widgets satisfying predicate f
See documentation of Vec::retain
.
Triggers a reconfigure action if any widgets are removed.
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'a W>
[src]
Iterate over childern
Trait Implementations
impl<D: Clone + Directional, W: Clone + Widget> Clone for List<D, W>
[src]
impl<D: Debug + Directional, W: Debug + Widget> Debug for List<D, W>
[src]
impl<D: Default + Directional, W: Default + Widget> Default for List<D, W>
[src]
impl<D: Directional, W: Widget> Handler for List<D, W>
[src]
type Msg = <W as Handler>::Msg
Type of message returned by this widget Read more
pub fn activation_via_press(&self) -> bool
[src]
pub fn handle(
&mut self,
_: &mut Manager<'_>,
event: Event
) -> Response<Self::Msg>
[src]
&mut self,
_: &mut Manager<'_>,
event: Event
) -> Response<Self::Msg>
impl<D: Directional, W: Widget> Index<usize> for List<D, W>
[src]
type Output = W
The returned type after indexing.
pub fn index(&self, index: usize) -> &Self::Output
[src]
impl<D: Directional, W: Widget> IndexMut<usize> for List<D, W>
[src]
impl<D: Directional, W: Widget> Layout for List<D, W>
[src]
pub fn size_rules(
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
[src]
&mut self,
size_handle: &mut dyn SizeHandle,
axis: AxisInfo
) -> SizeRules
pub fn set_rect(&mut self, rect: Rect, align: AlignHints)
[src]
pub fn spatial_range(&self) -> (usize, usize)
[src]
pub fn find_id(&self, coord: Coord) -> Option<WidgetId>
[src]
pub fn draw(
&self,
draw_handle: &mut dyn DrawHandle,
mgr: &ManagerState,
disabled: bool
)
[src]
&self,
draw_handle: &mut dyn DrawHandle,
mgr: &ManagerState,
disabled: bool
)
pub fn translation(&self, _child_index: usize) -> Coord
[src]
impl<D: Directional, W: Widget> SendEvent for List<D, W>
[src]
pub fn send(
&mut self,
mgr: &mut Manager<'_>,
id: WidgetId,
event: Event
) -> Response<Self::Msg>
[src]
&mut self,
mgr: &mut Manager<'_>,
id: WidgetId,
event: Event
) -> Response<Self::Msg>
impl<D: Directional, W: Widget> Widget for List<D, W>
[src]
impl<D: Directional, W: Widget> WidgetChildren for List<D, W>
[src]
pub fn first_id(&self) -> WidgetId
[src]
pub fn record_first_id(&mut self, id: WidgetId)
[src]
pub fn len(&self) -> usize
[src]
pub fn get(&self, index: usize) -> Option<&dyn WidgetConfig>
[src]
pub fn get_mut(&mut self, index: usize) -> Option<&mut dyn WidgetConfig>
[src]
pub fn is_ancestor_of(&self, id: WidgetId) -> bool
[src]
pub fn find(&self, id: WidgetId) -> Option<&dyn WidgetConfig>
[src]
pub fn find_mut(&mut self, id: WidgetId) -> Option<&mut dyn WidgetConfig>
[src]
pub fn walk<F: FnMut(&dyn WidgetConfig)>(&self, f: F) where
Self: Sized,
[src]
Self: Sized,
pub fn walk_mut<F: FnMut(&mut dyn WidgetConfig)>(&mut self, f: F) where
Self: Sized,
[src]
Self: Sized,
impl<D: Directional, W: Widget> WidgetConfig for List<D, W>
[src]
pub fn key_nav(&self) -> bool
[src]
pub fn cursor_icon(&self) -> CursorIcon
[src]
pub fn configure(&mut self, _: &mut Manager<'_>)
[src]
pub fn configure_recurse<'a, 'b>(&mut self, cmgr: ConfigureManager<'a, 'b>)
[src]
impl<D: Directional, W: Widget> WidgetCore for List<D, W>
[src]
pub fn as_any(&self) -> &dyn Any
[src]
pub fn as_any_mut(&mut self) -> &mut dyn Any
[src]
pub fn core_data(&self) -> &CoreData
[src]
pub fn core_data_mut(&mut self) -> &mut CoreData
[src]
pub fn widget_name(&self) -> &'static str
[src]
pub fn as_widget(&self) -> &dyn WidgetConfig
[src]
pub fn as_widget_mut(&mut self) -> &mut dyn WidgetConfig
[src]
pub fn id(&self) -> WidgetId
[src]
pub fn is_disabled(&self) -> bool
[src]
pub fn set_disabled(&mut self, disabled: bool) -> TkAction
[src]
pub fn with_disabled(self, disabled: bool) -> Self where
Self: Sized,
[src]
Self: Sized,
pub fn rect(&self) -> Rect
[src]
pub fn input_state(&self, mgr: &ManagerState, disabled: bool) -> InputState
[src]
Auto Trait Implementations
impl<D, W> RefUnwindSafe for List<D, W> where
D: RefUnwindSafe,
W: RefUnwindSafe,
D: RefUnwindSafe,
W: RefUnwindSafe,
impl<D, W> Send for List<D, W> where
D: Send,
W: Send,
D: Send,
W: Send,
impl<D, W> Sync for List<D, W> where
D: Sync,
W: Sync,
D: Sync,
W: Sync,
impl<D, W> Unpin for List<D, W> where
D: Unpin,
W: Unpin,
D: Unpin,
W: Unpin,
impl<D, W> UnwindSafe for List<D, W> where
D: UnwindSafe,
W: UnwindSafe,
D: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,