Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite push_line interface, and make patterned lines match gecko closer #1923

Merged
merged 4 commits into from Oct 25, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

update wrench to use new line style

  • Loading branch information
Gankra committed Oct 24, 2017
commit 5dee833ba649e29896435f87c6ef91d69945e6a7
@@ -30,6 +30,7 @@ root:
start: 10
end: 210
width: 3
thickness: 1
orientation: horizontal
color: red
style: wavy
@@ -62,7 +63,8 @@ root:
baseline: 95
start: 10
end: 210
width: 8
width: 6
thickness: 2
orientation: horizontal
color: red
style: wavy
@@ -101,7 +103,8 @@ root:
baseline: 190
start: 10
end: 210
width: 8
width: 12
thickness: 3
orientation: horizontal
color: black
style: wavy
@@ -142,7 +145,8 @@ root:
baseline: 290
start: 10
end: 210
width: 8
width: 16
thickness: 4
orientation: horizontal
color: black
style: wavy
@@ -177,6 +181,7 @@ root:
baseline: 250
start: 10
end: 210
thickness: 1
width: 3
orientation: vertical
color: red
@@ -210,7 +215,8 @@ root:
baseline: 330
start: 10
end: 210
width: 8
thickness: 2
width: 6
orientation: vertical
color: red
style: wavy
@@ -249,7 +255,8 @@ root:
baseline: 440
start: 10
end: 210
width: 8
thickness: 4
width: 16
orientation: vertical
color: red
style: wavy
@@ -213,9 +213,9 @@ impl<'a> RawtestHarness<'a> {
blur_radius: 1.0,
color: ColorF::new(0.0, 0.0, 0.0, 1.0),
});
builder.push_line(&PrimitiveInfo::new(rect(100., 100., 100., 100.)),
110., 110., 160., LineOrientation::Horizontal, 2.0,
ColorF::new(0.0, 0.0, 0.0, 1.0), LineStyle::Solid);
builder.push_line(&PrimitiveInfo::new(rect(110., 110., 50., 2.)),
0.0, LineOrientation::Horizontal,
&ColorF::new(0.0, 0.0, 0.0, 1.0), LineStyle::Solid);
builder.restore();
}

@@ -578,10 +578,6 @@ impl YamlFrameReader {
info: &mut LayoutPrimitiveInfo,
) {
let color = item["color"].as_colorf().unwrap_or(*BLACK_COLOR);
let baseline = item["baseline"].as_f32().expect("line must have baseline");
let start = item["start"].as_f32().expect("line must have start");
let end = item["end"].as_f32().expect("line must have end");
let width = item["width"].as_f32().expect("line must have width");
let orientation = item["orientation"]
.as_str()
.and_then(LineOrientation::from_str)
@@ -590,14 +586,47 @@ impl YamlFrameReader {
.as_str()
.and_then(LineStyle::from_str)
.expect("line must have style");

let wavy_line_thickness = if let LineStyle::Wavy = style {
item["thickness"].as_f32().expect("wavy lines must have a thickness")
} else {
0.0
};

if item["baseline"].is_badvalue() {
let bounds_key = if item["type"].is_badvalue() {
"rect"
} else {
"bounds"
};

info.rect = item[bounds_key]
.as_rect()
.expect("line type must have bounds");
} else {
// Legacy line representation
let baseline = item["baseline"].as_f32().expect("line must have baseline");
let start = item["start"].as_f32().expect("line must have start");
let end = item["end"].as_f32().expect("line must have end");
let width = item["width"].as_f32().expect("line must have width");

info.rect = match orientation {
LineOrientation::Horizontal => {
LayoutRect::new(LayoutPoint::new(start, baseline),
LayoutSize::new(end - start, width))
}
LineOrientation::Vertical => {
LayoutRect::new(LayoutPoint::new(baseline, start),
LayoutSize::new(width, end - start))
}
};
}

dl.push_line(
&info,
baseline,
start,
end,
wavy_line_thickness,
orientation,
width,
color,
&color,
style,
);
}
@@ -649,11 +649,10 @@ impl YamlFrameWriter {
}
Line(item) => {
str_node(&mut v, "type", "line");
f32_node(&mut v, "baseline", item.baseline);
f32_node(&mut v, "start", item.start);
f32_node(&mut v, "end", item.end);
if let LineStyle::Wavy = item.style {
f32_node(&mut v, "thickness", item.wavy_line_thickness);
}
str_node(&mut v, "orientation", item.orientation.as_str());
f32_node(&mut v, "width", item.width);
color_node(&mut v, "color", item.color);
str_node(&mut v, "style", item.style.as_str());
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.