mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
LibGUI: Make all views use CenterLeft as the default text alignment
If a model doesn't specify a text alignment for a given field, we now fall back to CenterLeft. This will look better than Center in the vast majority of cases.
This commit is contained in:
parent
2adb0a07e5
commit
278b307713
3 changed files with 3 additions and 3 deletions
|
@ -162,7 +162,7 @@ void ListView::paint_event(PaintEvent& event)
|
||||||
auto text_rect = row_rect;
|
auto text_rect = row_rect;
|
||||||
text_rect.move_by(horizontal_padding(), 0);
|
text_rect.move_by(horizontal_padding(), 0);
|
||||||
text_rect.set_width(text_rect.width() - horizontal_padding() * 2);
|
text_rect.set_width(text_rect.width() - horizontal_padding() * 2);
|
||||||
auto text_alignment = model()->data(index, Model::Role::TextAlignment).to_text_alignment(Gfx::TextAlignment::Center);
|
auto text_alignment = model()->data(index, Model::Role::TextAlignment).to_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
painter.draw_text(text_rect, data.to_string(), font, text_alignment, text_color);
|
painter.draw_text(text_rect, data.to_string(), font, text_alignment, text_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ void TableView::paint_event(PaintEvent& event)
|
||||||
if (cell_background_color.is_valid())
|
if (cell_background_color.is_valid())
|
||||||
painter.fill_rect(cell_rect_for_fill, cell_background_color.to_color(background_color));
|
painter.fill_rect(cell_rect_for_fill, cell_background_color.to_color(background_color));
|
||||||
}
|
}
|
||||||
auto text_alignment = model()->data(cell_index, Model::Role::TextAlignment).to_text_alignment(Gfx::TextAlignment::Center);
|
auto text_alignment = model()->data(cell_index, Model::Role::TextAlignment).to_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
painter.draw_text(cell_rect, data.to_string(), font_for_index(cell_index), text_alignment, text_color, Gfx::TextElision::Right);
|
painter.draw_text(cell_rect, data.to_string(), font_for_index(cell_index), text_alignment, text_color, Gfx::TextElision::Right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,7 @@ void TreeView::paint_event(PaintEvent& event)
|
||||||
} else {
|
} else {
|
||||||
if (!is_selected_row)
|
if (!is_selected_row)
|
||||||
text_color = model.data(cell_index, Model::Role::ForegroundColor).to_color(palette().color(foreground_role()));
|
text_color = model.data(cell_index, Model::Role::ForegroundColor).to_color(palette().color(foreground_role()));
|
||||||
auto text_alignment = model.data(cell_index, Model::Role::TextAlignment).to_text_alignment(Gfx::TextAlignment::Center);
|
auto text_alignment = model.data(cell_index, Model::Role::TextAlignment).to_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
painter.draw_text(cell_rect, data.to_string(), font_for_index(cell_index), text_alignment, text_color, Gfx::TextElision::Right);
|
painter.draw_text(cell_rect, data.to_string(), font_for_index(cell_index), text_alignment, text_color, Gfx::TextElision::Right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue