mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
Browser: Size the content box in "Box Model" based on its text
This commit is contained in:
parent
69fc7009bf
commit
dc8ac83f77
1 changed files with 7 additions and 3 deletions
|
@ -18,8 +18,13 @@ void ElementSizePreviewWidget::paint_event(GUI::PaintEvent& event)
|
||||||
int outer_margin = 10;
|
int outer_margin = 10;
|
||||||
int text_width_padding = 4;
|
int text_width_padding = 4;
|
||||||
int text_height_padding = 4;
|
int text_height_padding = 4;
|
||||||
int inner_content_width = 100;
|
int content_width_padding = 8;
|
||||||
int inner_content_height = max(15, font().glyph_height() + 2 * text_height_padding);
|
int content_height_padding = 8;
|
||||||
|
|
||||||
|
auto content_size_text = String::formatted("{}x{}", m_node_content_width, m_node_content_height);
|
||||||
|
|
||||||
|
int inner_content_width = max(100, font().width(content_size_text) + 2 * content_width_padding);
|
||||||
|
int inner_content_height = max(15, font().glyph_height() + 2 * content_height_padding);
|
||||||
|
|
||||||
auto format_size_text = [&](float size) {
|
auto format_size_text = [&](float size) {
|
||||||
return String::formatted("{:.4f}", size);
|
return String::formatted("{:.4f}", size);
|
||||||
|
@ -98,7 +103,6 @@ void ElementSizePreviewWidget::paint_event(GUI::PaintEvent& event)
|
||||||
draw_size_texts(padding_rect, Color::Black, m_node_box_sizing.padding);
|
draw_size_texts(padding_rect, Color::Black, m_node_box_sizing.padding);
|
||||||
|
|
||||||
// paint content box
|
// paint content box
|
||||||
auto content_size_text = String::formatted("{}x{}", m_node_content_width, m_node_content_height);
|
|
||||||
painter.fill_rect(content_rect, Color(140, 182, 192));
|
painter.fill_rect(content_rect, Color(140, 182, 192));
|
||||||
draw_borders(content_rect, Color::Black);
|
draw_borders(content_rect, Color::Black);
|
||||||
content_rect.shrink(1, 1, 1, 1);
|
content_rect.shrink(1, 1, 1, 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue