1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

LibGfx: Replace 'bool dotted' with a LineStyle::{Solid,Dotted} enum

Just a bool is insufficient as we'll have to support dashed lines as well.
This commit is contained in:
Linus Groh 2020-05-10 11:58:33 +01:00 committed by Andreas Kling
parent da42279171
commit 59d00e5df6
3 changed files with 21 additions and 11 deletions

View file

@ -102,10 +102,14 @@ void LayoutBox::paint_border(RenderingContext& context, Edge edge, const Gfx::Fl
color = (edge == Edge::Left || edge == Edge::Top) ? top_left_color : bottom_right_color;
}
bool dotted = border_style.has_value() && border_style.value()->to_string() == "dotted";
auto line_style = Gfx::Painter::LineStyle::Solid;
if (border_style.has_value()) {
if (border_style.value()->to_string() == "dotted")
line_style = Gfx::Painter::LineStyle::Dotted;
}
auto draw_line = [&](auto& p1, auto& p2) {
context.painter().draw_line({ (int)p1.x(), (int)p1.y() }, { (int)p2.x(), (int)p2.y() }, color, 1, dotted);
context.painter().draw_line({ (int)p1.x(), (int)p1.y() }, { (int)p2.x(), (int)p2.y() }, color, 1, line_style);
};
auto width_for = [&](CSS::PropertyID property_id) -> float {