mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Generalize child of NodeBackground 🍼
This commit is contained in:
parent
80e076814d
commit
a6cae89b47
@ -5,8 +5,8 @@ use super::*;
|
|||||||
pub struct NodeBackground {
|
pub struct NodeBackground {
|
||||||
/// The background fill.
|
/// The background fill.
|
||||||
pub fill: Fill,
|
pub fill: Fill,
|
||||||
/// The child node whose sides to pad.
|
/// The child node to be filled in.
|
||||||
pub child: NodeFixed,
|
pub child: Node,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Layout for NodeBackground {
|
impl Layout for NodeBackground {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
//! Layouting.
|
//! Layouting.
|
||||||
|
|
||||||
|
mod background;
|
||||||
mod fixed;
|
mod fixed;
|
||||||
mod node;
|
mod node;
|
||||||
mod pad;
|
mod pad;
|
||||||
mod par;
|
mod par;
|
||||||
mod background;
|
|
||||||
mod spacing;
|
mod spacing;
|
||||||
mod stack;
|
mod stack;
|
||||||
mod text;
|
mod text;
|
||||||
@ -14,11 +14,11 @@ use crate::env::{Env, ResourceId};
|
|||||||
use crate::geom::*;
|
use crate::geom::*;
|
||||||
use crate::shaping::Shaped;
|
use crate::shaping::Shaped;
|
||||||
|
|
||||||
|
pub use background::*;
|
||||||
pub use fixed::*;
|
pub use fixed::*;
|
||||||
pub use node::*;
|
pub use node::*;
|
||||||
pub use pad::*;
|
pub use pad::*;
|
||||||
pub use par::*;
|
pub use par::*;
|
||||||
pub use background::*;
|
|
||||||
pub use spacing::*;
|
pub use spacing::*;
|
||||||
pub use stack::*;
|
pub use stack::*;
|
||||||
pub use text::*;
|
pub use text::*;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
use crate::{eval::Softness, layout::NodeBackground};
|
|
||||||
use crate::layout::{Expansion, Fill, NodeFixed, NodeSpacing, NodeStack};
|
use crate::layout::{Expansion, Fill, NodeFixed, NodeSpacing, NodeStack};
|
||||||
use crate::paper::{Paper, PaperClass};
|
use crate::paper::{Paper, PaperClass};
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
use crate::{eval::Softness, layout::NodeBackground};
|
||||||
|
|
||||||
/// `align`: Align content along the layouting axes.
|
/// `align`: Align content along the layouting axes.
|
||||||
///
|
///
|
||||||
@ -210,7 +210,7 @@ pub fn box_(ctx: &mut EvalContext, args: &mut Args) -> Value {
|
|||||||
if let Some(color) = color {
|
if let Some(color) = color {
|
||||||
ctx.push(NodeBackground {
|
ctx.push(NodeBackground {
|
||||||
fill: Fill::Color(color),
|
fill: Fill::Color(color),
|
||||||
child: fixed_node,
|
child: Node::Any(fixed_node.into()),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
ctx.push(fixed_node);
|
ctx.push(fixed_node);
|
||||||
|
@ -464,10 +464,8 @@ fn draw_geometry(canvas: &mut Canvas, pos: Point, _: &Env, element: &Geometry) {
|
|||||||
Shape::Rect(s) => {
|
Shape::Rect(s) => {
|
||||||
let (w, h) = (s.width.to_pt() as f32, s.height.to_pt() as f32);
|
let (w, h) = (s.width.to_pt() as f32, s.height.to_pt() as f32);
|
||||||
canvas.fill_rect(Rect::from_xywh(x, y, w, h).unwrap(), &paint);
|
canvas.fill_rect(Rect::from_xywh(x, y, w, h).unwrap(), &paint);
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_image(canvas: &mut Canvas, pos: Point, env: &Env, element: &Image) {
|
fn draw_image(canvas: &mut Canvas, pos: Point, env: &Env, element: &Image) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user