mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Pass the Padding by value in the layout data struct
It can simply be a Copy type anyway. So there is no more special code needed in the rust (and also in C++) generator for it
This commit is contained in:
parent
4b0ae4d5a1
commit
b36de552e5
3 changed files with 7 additions and 17 deletions
|
@ -1529,18 +1529,8 @@ fn compile_expression(expr: &Expression, ctx: &EvaluationContext) -> TokenStream
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expression::Struct { ty, values } => {
|
Expression::Struct { ty, values } => {
|
||||||
if let Type::Struct { fields, name, node } = ty {
|
if let Type::Struct { fields, name, .. } = ty {
|
||||||
let elem = fields.keys().map(|k| {
|
let elem = fields.keys().map(|k| values.get(k).map(|e| compile_expression(e, ctx)));
|
||||||
values.get(k).map(|e| {
|
|
||||||
let e = compile_expression(e, ctx);
|
|
||||||
if node.is_none() && k == "padding" {
|
|
||||||
// FIXME: it would be nice if we didn't have to handle this field specially
|
|
||||||
quote!(&#e)
|
|
||||||
} else {
|
|
||||||
e
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
if let Some(name) = name {
|
if let Some(name) = name {
|
||||||
let name_tokens: TokenStream = struct_name_to_tokens(name.as_str());
|
let name_tokens: TokenStream = struct_name_to_tokens(name.as_str());
|
||||||
let keys = fields.keys().map(|k| ident(k));
|
let keys = fields.keys().map(|k| ident(k));
|
||||||
|
|
|
@ -334,7 +334,7 @@ impl Default for Constraint {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Default)]
|
#[derive(Copy, Clone, Debug, Default)]
|
||||||
pub struct Padding {
|
pub struct Padding {
|
||||||
pub begin: Coord,
|
pub begin: Coord,
|
||||||
pub end: Coord,
|
pub end: Coord,
|
||||||
|
@ -345,7 +345,7 @@ pub struct Padding {
|
||||||
pub struct GridLayoutData<'a> {
|
pub struct GridLayoutData<'a> {
|
||||||
pub size: Coord,
|
pub size: Coord,
|
||||||
pub spacing: Coord,
|
pub spacing: Coord,
|
||||||
pub padding: &'a Padding,
|
pub padding: Padding,
|
||||||
pub cells: Slice<'a, GridLayoutCellData>,
|
pub cells: Slice<'a, GridLayoutCellData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ impl Default for LayoutAlignment {
|
||||||
pub struct BoxLayoutData<'a> {
|
pub struct BoxLayoutData<'a> {
|
||||||
pub size: Coord,
|
pub size: Coord,
|
||||||
pub spacing: Coord,
|
pub spacing: Coord,
|
||||||
pub padding: &'a Padding,
|
pub padding: Padding,
|
||||||
pub alignment: LayoutAlignment,
|
pub alignment: LayoutAlignment,
|
||||||
pub cells: Slice<'a, BoxLayoutCellData>,
|
pub cells: Slice<'a, BoxLayoutCellData>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ pub(crate) fn solve_layout(
|
||||||
core_layout::solve_grid_layout(&core_layout::GridLayoutData {
|
core_layout::solve_grid_layout(&core_layout::GridLayoutData {
|
||||||
size: size_ref.map(expr_eval).unwrap_or(0.),
|
size: size_ref.map(expr_eval).unwrap_or(0.),
|
||||||
spacing,
|
spacing,
|
||||||
padding: &padding,
|
padding,
|
||||||
cells: Slice::from(cells.as_slice()),
|
cells: Slice::from(cells.as_slice()),
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
|
@ -128,7 +128,7 @@ pub(crate) fn solve_layout(
|
||||||
&core_layout::BoxLayoutData {
|
&core_layout::BoxLayoutData {
|
||||||
size: size_ref.as_ref().map(expr_eval).unwrap_or(0.),
|
size: size_ref.as_ref().map(expr_eval).unwrap_or(0.),
|
||||||
spacing,
|
spacing,
|
||||||
padding: &padding,
|
padding,
|
||||||
alignment,
|
alignment,
|
||||||
cells: Slice::from(cells.as_slice()),
|
cells: Slice::from(cells.as_slice()),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue