LibGUI: Adjust TextEditor's clipping rect for text
And simplify its construction. The first visual line was being over-clipped vertically by an amount equal to the frame's thickness. Selections and icons in TextBoxes and the first line of Editors now display correctly.
This commit is contained in:
parent
2424858c32
commit
b2df863b55
Notes:
sideshowbarker
2024-07-17 19:39:46 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/b2df863b550 Pull-request: https://github.com/SerenityOS/serenity/pull/12264 Reviewed-by: https://github.com/linusg ✅
1 changed files with 4 additions and 15 deletions
|
@ -370,12 +370,12 @@ Gfx::IntRect TextEditor::gutter_content_rect(size_t line_index) const
|
|||
|
||||
Gfx::IntRect TextEditor::ruler_rect_in_inner_coordinates() const
|
||||
{
|
||||
return { gutter_width(), 0, ruler_width(), height() - height_occupied_by_horizontal_scrollbar() };
|
||||
return { gutter_width(), 0, ruler_width(), widget_inner_rect().height() };
|
||||
}
|
||||
|
||||
Gfx::IntRect TextEditor::gutter_rect_in_inner_coordinates() const
|
||||
{
|
||||
return { 0, 0, gutter_width(), height() - height_occupied_by_horizontal_scrollbar() };
|
||||
return { 0, 0, gutter_width(), widget_inner_rect().height() };
|
||||
}
|
||||
|
||||
Gfx::IntRect TextEditor::visible_text_rect_in_inner_coordinates() const
|
||||
|
@ -474,19 +474,8 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
auto text_left = 0;
|
||||
if (m_ruler_visible)
|
||||
text_left = ruler_rect_in_inner_coordinates().right() + 1;
|
||||
else if (m_gutter_visible)
|
||||
text_left = gutter_rect_in_inner_coordinates().right() + 1;
|
||||
text_left += frame_thickness();
|
||||
|
||||
Gfx::IntRect text_clip_rect {
|
||||
0,
|
||||
frame_thickness(),
|
||||
width() - width_occupied_by_vertical_scrollbar() - text_left,
|
||||
height() - height_occupied_by_horizontal_scrollbar()
|
||||
};
|
||||
auto gutter_ruler_width = gutter_width() + ruler_width();
|
||||
Gfx::IntRect text_clip_rect { 0, 0, widget_inner_rect().width() - gutter_ruler_width, widget_inner_rect().height() };
|
||||
text_clip_rect.translate_by(horizontal_scrollbar().value(), vertical_scrollbar().value());
|
||||
painter.add_clip_rect(text_clip_rect);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue