mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGUI: Resize TextEditor ruler based on needed space
Ruler width is now calculated according to the number of digits in the line count.
This commit is contained in:
parent
15cb4207fc
commit
a5fefbf840
Notes:
sideshowbarker
2024-07-19 03:32:34 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/a5fefbf8408 Pull-request: https://github.com/SerenityOS/serenity/pull/3175 Reviewed-by: https://github.com/awesomekling
1 changed files with 3 additions and 2 deletions
|
@ -42,6 +42,7 @@
|
|||
#include <LibGfx/Palette.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -328,8 +329,8 @@ int TextEditor::ruler_width() const
|
|||
{
|
||||
if (!m_ruler_visible)
|
||||
return 0;
|
||||
// FIXME: Resize based on needed space.
|
||||
return 5 * font().glyph_width('x') + 4;
|
||||
int line_count_digits = static_cast<int>(log10(line_count())) + 1;
|
||||
return line_count() < 10 ? (line_count_digits + 1) * font().glyph_width('x') + 4 : line_count_digits * font().glyph_width('x') + 4;
|
||||
}
|
||||
|
||||
Gfx::IntRect TextEditor::ruler_content_rect(size_t line_index) const
|
||||
|
|
Loading…
Reference in a new issue