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

Implement asymmetric border colors #689

Merged
merged 4 commits into from Aug 20, 2013
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Implement asymmetric border colors

  • Loading branch information
sammykim committed Aug 20, 2013
commit 0e863b3cef679738767267b3e61ef28511daaddb
@@ -104,7 +104,7 @@ pub struct BorderDisplayItem<E> {
border: SideOffsets2D<Au>,

/// The color of the border.
color: Color,
color: SideOffsets2D<Color>,
}

impl<E> DisplayItem<E> {
@@ -37,8 +37,7 @@ impl<'self> RenderContext<'self> {
pub fn draw_border(&self,
bounds: &Rect<Au>,
border: SideOffsets2D<Au>,
color: Color) {
let pattern = ColorPattern(color);
color: SideOffsets2D<Color>) {
let draw_opts = DrawOptions(1 as AzFloat, 0 as uint16_t);
let stroke_fields = 2; // CAP_SQUARE
let mut stroke_opts = StrokeOptions(0 as AzFloat, 10 as AzFloat, stroke_fields);
@@ -53,28 +52,28 @@ impl<'self> RenderContext<'self> {
let y = rect.origin.y + border.top * 0.5;
let start = Point2D(rect.origin.x, y);
let end = Point2D(rect.origin.x + rect.size.width, y);
self.canvas.draw_target.stroke_line(start, end, &pattern, &stroke_opts, &draw_opts);
self.canvas.draw_target.stroke_line(start, end, &ColorPattern(color.top), &stroke_opts, &draw_opts);

// draw bottom border
stroke_opts.line_width = border.bottom;
let y = rect.origin.y + rect.size.height - border.bottom * 0.5;
let start = Point2D(rect.origin.x, y);
let end = Point2D(rect.origin.x + rect.size.width, y);
self.canvas.draw_target.stroke_line(start, end, &pattern, &stroke_opts, &draw_opts);
self.canvas.draw_target.stroke_line(start, end, &ColorPattern(color.bottom), &stroke_opts, &draw_opts);

// draw left border
stroke_opts.line_width = border.left;
let x = rect.origin.x + border.left * 0.5;
let start = Point2D(x, rect.origin.y);
let end = Point2D(x, rect.origin.y + rect.size.height);
self.canvas.draw_target.stroke_line(start, end, &pattern, &stroke_opts, &draw_opts);
self.canvas.draw_target.stroke_line(start, end, &ColorPattern(color.left), &stroke_opts, &draw_opts);

// draw right border
stroke_opts.line_width = border.right;
let x = rect.origin.x + rect.size.width - border.right * 0.5;
let start = Point2D(x, rect.origin.y);
let end = Point2D(x, rect.origin.y + rect.size.height);
self.canvas.draw_target.stroke_line(start, end, &pattern, &stroke_opts, &draw_opts);
self.canvas.draw_target.stroke_line(start, end, &ColorPattern(color.right), &stroke_opts, &draw_opts);
}

pub fn draw_image(&self, bounds: Rect<Au>, image: Arc<~Image>) {
@@ -639,7 +639,11 @@ impl RenderBox {
extra: ExtraDisplayListData::new(*self),
},
border: debug_border,
color: rgb(0, 0, 200).to_gfx_color(),
color: SideOffsets2D::new(rgb(0, 0, 200).to_gfx_color(),

This comment has been minimized.

Copy link
@sanxiyn

sanxiyn Aug 8, 2013

Contributor

I think you want debug_color local variable just like debug_border.

This comment has been minimized.

Copy link
@sammykim

sammykim Aug 8, 2013

Author Contributor

I can't merge them to debug_color as same as debug_border.
Becuase their values are not same.

rgb(0, 0, 200).to_gfx_color(),
rgb(0, 0, 200).to_gfx_color(),
rgb(0, 0, 200).to_gfx_color())

};
list.append_item(BorderDisplayItemClass(border_display_item))
}
@@ -659,7 +663,11 @@ impl RenderBox {
extra: ExtraDisplayListData::new(*self),
},
border: debug_border,
color: rgb(0, 200, 0).to_gfx_color(),
color: SideOffsets2D::new(rgb(0, 200, 0).to_gfx_color(),
rgb(0, 200, 0).to_gfx_color(),
rgb(0, 200, 0).to_gfx_color(),
rgb(0, 200, 0).to_gfx_color())

};
list.append_item(BorderDisplayItemClass(border_display_item))
}
@@ -687,7 +695,11 @@ impl RenderBox {
extra: ExtraDisplayListData::new(*self),
},
border: debug_border,
color: rgb(0, 0, 200).to_gfx_color(),
color: SideOffsets2D::new(rgb(0, 0, 200).to_gfx_color(),
rgb(0, 0, 200).to_gfx_color(),
rgb(0, 0, 200).to_gfx_color(),
rgb(0, 0, 200).to_gfx_color())

};
list.append_item(BorderDisplayItemClass(border_display_item))
}
@@ -914,9 +926,10 @@ impl RenderBox {
return
}

// FIXME: all colors set to top color. this is obviously not right.
let top_color = self.style().border_top_color();
let color = top_color.to_gfx_color();
let right_color = self.style().border_right_color();
let bottom_color = self.style().border_bottom_color();
let left_color = self.style().border_left_color();

// Append the border to the display list.
do list.with_mut_ref |list| {
@@ -929,7 +942,10 @@ impl RenderBox {
border.right,
border.bottom,
border.left),
color: color,
color: SideOffsets2D::new(top_color.to_gfx_color(),
right_color.to_gfx_color(),
bottom_color.to_gfx_color(),
left_color.to_gfx_color())
};

list.append_item(BorderDisplayItemClass(border_display_item))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.