mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 19:55:06 +00:00
GTextEditor: Fix wrong width calculations with line-wrapping enabled
There were various little mistakes in the width calculations used by the line-wrapping layout code. With this patch, we should no longer see the horizontal scrollbar get enabled with line-wrapping enabled. I will hide the scrollbar in a separate patch.
This commit is contained in:
parent
74ca299b4b
commit
906582d8df
2 changed files with 4 additions and 14 deletions
|
@ -306,10 +306,10 @@ Rect GTextEditor::ruler_rect_in_inner_coordinates() const
|
|||
Rect GTextEditor::visible_text_rect_in_inner_coordinates() const
|
||||
{
|
||||
return {
|
||||
(m_horizontal_content_padding * 2) + (m_ruler_visible ? (ruler_rect_in_inner_coordinates().right() + 1) : 0),
|
||||
m_horizontal_content_padding + (m_ruler_visible ? (ruler_rect_in_inner_coordinates().right() + 1) : 0),
|
||||
0,
|
||||
width() - width_occupied_by_vertical_scrollbar() - ruler_width(),
|
||||
height() - height_occupied_by_horizontal_scrollbar()
|
||||
frame_inner_rect().width() - (m_horizontal_content_padding * 2) - width_occupied_by_vertical_scrollbar() - ruler_width(),
|
||||
frame_inner_rect().height() - height_occupied_by_horizontal_scrollbar()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -941,13 +941,6 @@ void GTextEditor::Line::set_text(const StringView& text)
|
|||
memcpy(m_text.data(), text.characters_without_null_termination(), text.length() + 1);
|
||||
}
|
||||
|
||||
int GTextEditor::Line::width(const Font& font) const
|
||||
{
|
||||
if (m_editor.is_line_wrapping_enabled())
|
||||
return m_editor.visible_text_rect_in_inner_coordinates().width();
|
||||
return font.width(view());
|
||||
}
|
||||
|
||||
void GTextEditor::Line::append(const char* characters, int length)
|
||||
{
|
||||
int old_length = m_text.size() - 1;
|
||||
|
@ -1367,8 +1360,6 @@ void GTextEditor::recompute_all_visual_lines()
|
|||
line.m_visual_rect.set_y(y_offset);
|
||||
y_offset += line.m_visual_rect.height();
|
||||
}
|
||||
if (content_size().height() == y_offset)
|
||||
return;
|
||||
|
||||
update_content_size();
|
||||
}
|
||||
|
@ -1387,7 +1378,7 @@ void GTextEditor::Line::recompute_visual_lines()
|
|||
auto glyph_width = m_editor.font().glyph_width(ch);
|
||||
if ((line_width_so_far + glyph_width) > available_width) {
|
||||
m_visual_line_breaks.append(i);
|
||||
line_width_so_far = 0;
|
||||
line_width_so_far = glyph_width;
|
||||
continue;
|
||||
}
|
||||
line_width_so_far += glyph_width;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue