mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
Use f64 type in layout
This commit is contained in:
parent
e8058513f3
commit
420314d0b3
3 changed files with 9 additions and 9 deletions
|
|
@ -108,7 +108,7 @@ impl Attribute {
|
|||
}
|
||||
|
||||
/// Extracts a percentage from this attribute's value.
|
||||
fn percent(self) -> f32 {
|
||||
fn percent(self) -> f64 {
|
||||
match self.dimension() {
|
||||
Dimension::Percent(value) => value,
|
||||
_ => panic!("expected a percentage"),
|
||||
|
|
@ -151,8 +151,8 @@ pub enum AttributeValue {
|
|||
pub struct LayoutAttributes {
|
||||
pub width: Dimension,
|
||||
pub height: Dimension,
|
||||
pub x_align: f32,
|
||||
pub y_align: f32,
|
||||
pub x_align: f64,
|
||||
pub y_align: f64,
|
||||
pub spacing: BoxDimensions,
|
||||
pub padding: BoxDimensions,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,11 +76,11 @@ pub enum TemplateStringSegment {
|
|||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum Dimension {
|
||||
/// Absolute value in pixels.
|
||||
AbsolutePx(f32),
|
||||
AbsolutePx(f64),
|
||||
/// Percent of parent container size along the same axis.
|
||||
Percent(f32),
|
||||
Percent(f64),
|
||||
/// Percent of free space remaining in parent container.
|
||||
PercentRemainder(f32),
|
||||
PercentRemainder(f64),
|
||||
/// Minimum size required to fit the children.
|
||||
Inner,
|
||||
/// Size relative to the width of this component.
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ impl AttributeParser {
|
|||
// AbsolutePx: px
|
||||
Some([value, px]) if px.eq_ignore_ascii_case("px") => {
|
||||
let pixels = value
|
||||
.parse::<f32>()
|
||||
.parse::<f64>()
|
||||
.expect(&format!("Invalid value `{}` specified in the attribute type`{}` when parsing XML layout", value, attribute_type)[..]);
|
||||
let dimension = Dimension::AbsolutePx(pixels);
|
||||
TypeValueOrArgument::TypeValue(TypeValue::Dimension(dimension))
|
||||
|
|
@ -136,7 +136,7 @@ impl AttributeParser {
|
|||
// Percent: ?%
|
||||
Some([value, "%"]) => {
|
||||
let percent = value
|
||||
.parse::<f32>()
|
||||
.parse::<f64>()
|
||||
.expect(&format!("Invalid value `{}` specified in the attribute type `{}` when parsing XML layout", value, attribute_type)[..]);
|
||||
let dimension = Dimension::Percent(percent);
|
||||
TypeValueOrArgument::TypeValue(TypeValue::Dimension(dimension))
|
||||
|
|
@ -144,7 +144,7 @@ impl AttributeParser {
|
|||
// PercentRemainder: ?@
|
||||
Some([value, "@"]) => {
|
||||
let percent_remainder = value
|
||||
.parse::<f32>()
|
||||
.parse::<f64>()
|
||||
.expect(&format!("Invalid value `{}` specified in the attribute type `{}` when parsing XML layout", value, attribute_type)[..]);
|
||||
let dimension = Dimension::PercentRemainder(percent_remainder);
|
||||
TypeValueOrArgument::TypeValue(TypeValue::Dimension(dimension))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue