mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
GTextEditor: Simplify painting of the ruler.
This commit is contained in:
parent
ffe4522316
commit
0a7137617d
1 changed files with 7 additions and 10 deletions
|
@ -198,20 +198,17 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
||||||
auto selection = normalized_selection();
|
auto selection = normalized_selection();
|
||||||
bool has_selection = selection.is_valid();
|
bool has_selection = selection.is_valid();
|
||||||
|
|
||||||
painter.set_font(Font::default_font());
|
|
||||||
for (int i = first_visible_line; i <= last_visible_line; ++i) {
|
for (int i = first_visible_line; i <= last_visible_line; ++i) {
|
||||||
bool is_current_line = i == m_cursor.line();
|
bool is_current_line = i == m_cursor.line();
|
||||||
auto ruler_line_rect = ruler_content_rect(i);
|
auto ruler_line_rect = ruler_content_rect(i);
|
||||||
Color text_color = Color::MidGray;
|
painter.draw_text(
|
||||||
if (is_current_line) {
|
ruler_line_rect.shrunken(2, 0),
|
||||||
painter.set_font(Font::default_bold_font());
|
String::format("%u", i),
|
||||||
text_color = Color::DarkGray;
|
is_current_line ? Font::default_bold_font() : font(),
|
||||||
}
|
TextAlignment::CenterRight,
|
||||||
painter.draw_text(ruler_line_rect.shrunken(2, 0), String::format("%u", i), TextAlignment::CenterRight, text_color);
|
is_current_line ? Color::DarkGray : Color::MidGray
|
||||||
if (is_current_line)
|
);
|
||||||
painter.set_font(Font::default_font());
|
|
||||||
}
|
}
|
||||||
painter.set_font(font());
|
|
||||||
|
|
||||||
painter.set_clip_rect({ ruler_rect.right() + 1, 0, width() - m_vertical_scrollbar->width() - ruler_width(), height() - m_horizontal_scrollbar->height() });
|
painter.set_clip_rect({ ruler_rect.right() + 1, 0, width() - m_vertical_scrollbar->width() - ruler_width(), height() - m_horizontal_scrollbar->height() });
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue