pub struct RowPositionSolver<D: Directional> { /* private fields */ }
Expand description

Allows efficient implementations of draw / event handlers based on the layout representation.

This is only applicable where child widgets are contained in a slice of type W: Widget (which may be Box<dyn Widget>). In other cases, the naive implementation (test all items) must be used.

Implementations§

Construct with given directionality

Examples found in repository?
src/layout/visitor.rs (line 439)
438
439
440
441
442
443
444
445
446
447
448
    fn find_id(&mut self, coord: Coord) -> Option<WidgetId> {
        let solver = RowPositionSolver::new(self.direction);
        solver
            .find_child_mut(self.children, coord)
            .and_then(|child| child.find_id(coord))
    }

    fn draw(&mut self, mut draw: DrawMgr) {
        let solver = RowPositionSolver::new(self.direction);
        solver.for_children(self.children, draw.get_clip_rect(), |w| draw.recurse(w));
    }

Find the child containing the given coordinates

Returns None when the coordinates lie within the margin area or outside of the parent widget.

Examples found in repository?
src/layout/row_solver.rs (line 297)
296
297
298
299
300
301
302
303
304
305
306
307
308
    pub fn find_child<W: Widget>(self, widgets: &[W], coord: Coord) -> Option<&W> {
        self.find_child_index(widgets, coord).map(|i| &widgets[i])
    }

    /// Find the child containing the given coordinates
    ///
    /// Returns `None` when the coordinates lie within the margin area or
    /// outside of the parent widget.
    #[inline]
    pub fn find_child_mut<W: Widget>(self, widgets: &mut [W], coord: Coord) -> Option<&mut W> {
        self.find_child_index(widgets, coord)
            .map(|i| &mut widgets[i])
    }

Find the child containing the given coordinates

Returns None when the coordinates lie within the margin area or outside of the parent widget.

Find the child containing the given coordinates

Returns None when the coordinates lie within the margin area or outside of the parent widget.

Examples found in repository?
src/layout/visitor.rs (line 441)
438
439
440
441
442
443
    fn find_id(&mut self, coord: Coord) -> Option<WidgetId> {
        let solver = RowPositionSolver::new(self.direction);
        solver
            .find_child_mut(self.children, coord)
            .and_then(|child| child.find_id(coord))
    }

Call f on each child intersecting the given rect

Examples found in repository?
src/layout/visitor.rs (line 447)
445
446
447
448
    fn draw(&mut self, mut draw: DrawMgr) {
        let solver = RowPositionSolver::new(self.direction);
        solver.for_children(self.children, draw.get_clip_rect(), |w| draw.recurse(w));
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Cast from Self to T Read more
Try converting from Self to T Read more
Try approximate conversion from Self to T Read more
Cast approximately from Self to T Read more
Cast to integer, truncating Read more
Cast to the nearest integer Read more
Cast the floor to an integer Read more
Cast the ceiling to an integer Read more
Try converting to integer with truncation Read more
Try converting to the nearest integer Read more
Try converting the floor to an integer Read more
Try convert the ceiling to an integer Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.