diff options
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/actions.rs | 8 | ||||
| -rw-r--r-- | src/layout/mod.rs | 15 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/layout/actions.rs b/src/layout/actions.rs index 3eb4fb7f..bbefbfc0 100644 --- a/src/layout/actions.rs +++ b/src/layout/actions.rs @@ -84,7 +84,7 @@ impl LayoutActionList { MoveAbsolute(pos) => self.next_pos = Some(self.origin + pos), DebugBox(pos, size) => self.actions.push(DebugBox(self.origin + pos, size)), - SetFont(index, size) if (index, size) != self.active_font => { + SetFont(index, size) => { self.next_font = Some((index, size)); } @@ -92,8 +92,12 @@ impl LayoutActionList { if let Some(target) = self.next_pos.take() { self.actions.push(MoveAbsolute(target)); } + if let Some((index, size)) = self.next_font.take() { - self.actions.push(SetFont(index, size)); + if (index, size) != self.active_font { + self.actions.push(SetFont(index, size)); + self.active_font = (index, size); + } } self.actions.push(action); diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 14aa6417..abf140d6 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -76,6 +76,11 @@ impl MultiLayout { self.layouts.push(layout); } + /// The count of sublayouts. + pub fn count(&self) -> usize { + self.layouts.len() + } + /// Whether this layout contains any sublayouts. pub fn is_empty(&self) -> bool { self.layouts.is_empty() @@ -91,6 +96,16 @@ impl IntoIterator for MultiLayout { } } +impl<'a> IntoIterator for &'a MultiLayout { + type Item = &'a Layout; + type IntoIter = std::slice::Iter<'a, Layout>; + + fn into_iter(self) -> Self::IntoIter { + self.layouts.iter() + } +} + + /// The context for layouting. #[derive(Copy, Clone)] pub struct LayoutContext<'a, 'p> { |
