mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Prepare axis setting for flex layouter ♟
This commit is contained in:
parent
796c2486ce
commit
bd66ebd683
@ -48,6 +48,7 @@ enum FlexUnit {
|
||||
Space(Size),
|
||||
/// A forced break of the current flex run.
|
||||
Break,
|
||||
SetAxes(LayoutAxes),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -97,6 +98,11 @@ impl FlexLayouter {
|
||||
self.units.push(FlexUnit::Break);
|
||||
}
|
||||
|
||||
/// Update the axes in use by this flex layouter.
|
||||
pub fn set_axes(&self, axes: LayoutAxes) {
|
||||
self.units.push(FlexUnit::SetAxes(axes));
|
||||
}
|
||||
|
||||
/// Compute the justified layout.
|
||||
///
|
||||
/// The layouter is not consumed by this to prevent ownership problems
|
||||
@ -117,6 +123,8 @@ impl FlexLayouter {
|
||||
self.space = None;
|
||||
self.finish_run()?;
|
||||
},
|
||||
|
||||
FlexUnit::SetAxes(axes) => self.layout_set_axes(axes),
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,6 +170,10 @@ impl FlexLayouter {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn layout_set_axes(&mut self, axes: LayoutAxes) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
/// Finish the current flex run.
|
||||
fn finish_run(&mut self) -> LayoutResult<()> {
|
||||
let mut actions = LayoutActionList::new();
|
||||
@ -183,11 +195,6 @@ impl FlexLayouter {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Update the axes in use by this flex layouter.
|
||||
pub fn set_axes(&self, axes: LayoutAxes) {
|
||||
|
||||
}
|
||||
|
||||
/// This layouter's context.
|
||||
pub fn ctx(&self) -> FlexContext {
|
||||
self.ctx
|
||||
|
@ -100,8 +100,10 @@ impl<'a, 'p> TreeLayouter<'a, 'p> {
|
||||
|
||||
Command::SetStyle(style) => *self.style.to_mut() = style,
|
||||
Command::SetAxes(axes) => {
|
||||
self.stack.set_axes(axes);
|
||||
self.flex.set_axes(axes);
|
||||
if axes.secondary != self.ctx.axes.secondary {
|
||||
self.stack.set_axes(axes);
|
||||
}
|
||||
self.ctx.axes = axes;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user