pub struct RowSolver<S: RowStorage> { /* private fields */ }
Expand description
A RulesSolver
for rows (and, without loss of generality, for columns).
This is parameterised over:
S:
RowStorage
— persistent storage type
Implementations§
source§impl<S: RowStorage> RowSolver<S>
impl<S: RowStorage> RowSolver<S>
sourcepub fn new<D: Directional>(
axis: AxisInfo,
(dir, len): (D, usize),
storage: &mut S
) -> Self
pub fn new<D: Directional>(
axis: AxisInfo,
(dir, len): (D, usize),
storage: &mut S
) -> Self
Construct.
Argument order is consistent with other RulesSolver
s.
axis
:AxisInfo
instance passed intosize_rules
(dir, len)
: direction and number of itemsstorage
: reference to persistent storage
Examples found in repository?
src/layout/visitor.rs (line 343)
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
fn size_rules(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
let dim = (self.direction, self.children.len());
let mut solver = RowSolver::new(axis, dim, self.data);
for (n, child) in (&mut self.children).enumerate() {
solver.for_child(self.data, n, |axis| child.size_rules(mgr.re(), axis));
}
solver.finish(self.data)
}
fn set_rect(&mut self, mgr: &mut ConfigMgr, rect: Rect) {
let dim = (self.direction, self.children.len());
let mut setter = RowSetter::<D, Vec<i32>, _>::new(rect, dim, self.data);
for (n, child) in (&mut self.children).enumerate() {
child.set_rect(mgr, setter.child_rect(self.data, n));
}
}
fn find_id(&mut self, coord: Coord) -> Option<WidgetId> {
// TODO(opt): more efficient search strategy?
self.children.find_map(|child| child.find_id(coord))
}
fn draw(&mut self, mut draw: DrawMgr) {
for child in &mut self.children {
child.draw(draw.re_clone());
}
}
}
/// Float layout
struct Float<'a, I>
where
I: DoubleEndedIterator<Item = Visitor<'a>>,
{
children: I,
}
impl<'a, I> Layout for Float<'a, I>
where
I: DoubleEndedIterator<Item = Visitor<'a>>,
{
fn size_rules(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
let mut rules = SizeRules::EMPTY;
for child in &mut self.children {
rules = rules.max(child.size_rules(mgr.re(), axis));
}
rules
}
fn set_rect(&mut self, mgr: &mut ConfigMgr, rect: Rect) {
for child in &mut self.children {
child.set_rect(mgr, rect);
}
}
fn find_id(&mut self, coord: Coord) -> Option<WidgetId> {
self.children.find_map(|child| child.find_id(coord))
}
fn draw(&mut self, mut draw: DrawMgr) {
let mut iter = (&mut self.children).rev();
if let Some(first) = iter.next() {
first.draw(draw.re_clone());
}
for child in iter {
draw.with_pass(|draw| child.draw(draw));
}
}
}
/// A row/column over a slice
struct Slice<'a, W: Widget, D: Directional> {
data: &'a mut DynRowStorage,
direction: D,
children: &'a mut [W],
}
impl<'a, W: Widget, D: Directional> Layout for Slice<'a, W, D> {
fn size_rules(&mut self, mgr: SizeMgr, axis: AxisInfo) -> SizeRules {
let dim = (self.direction, self.children.len());
let mut solver = RowSolver::new(axis, dim, self.data);
for (n, child) in self.children.iter_mut().enumerate() {
solver.for_child(self.data, n, |axis| child.size_rules(mgr.re(), axis));
}
solver.finish(self.data)
}
Trait Implementations§
source§impl<S: RowStorage> RulesSolver for RowSolver<S>
impl<S: RowStorage> RulesSolver for RowSolver<S>
§type ChildInfo = usize
type ChildInfo = usize
Type required by
RulesSolver::for_child
(see implementation documentation)Auto Trait Implementations§
impl<S> RefUnwindSafe for RowSolver<S>where
S: RefUnwindSafe,
impl<S> Send for RowSolver<S>where
S: Send,
impl<S> Sync for RowSolver<S>where
S: Sync,
impl<S> Unpin for RowSolver<S>where
S: Unpin,
impl<S> UnwindSafe for RowSolver<S>where
S: UnwindSafe,
Blanket Implementations§
source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more