mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 12:55:08 +00:00
GTextEditor: Let's use a Vector for the line backing store.
I'm eventually gonna want to replace this with something more clever, like a automagically splicing vector or something, but for now, at least we move away from immutable Strings.
This commit is contained in:
parent
a21ecd440a
commit
ce35cddb1b
4 changed files with 36 additions and 17 deletions
|
@ -323,10 +323,10 @@ void Painter::blit(const Point& position, const GraphicsBitmap& source, const Re
|
|||
draw_bitmap(point, font().glyph_bitmap(ch), color);
|
||||
}
|
||||
|
||||
void Painter::draw_text(const Rect& rect, const String& text, TextAlignment alignment, Color color)
|
||||
void Painter::draw_text(const Rect& rect, const char* text, int length, TextAlignment alignment, Color color)
|
||||
{
|
||||
Point point;
|
||||
|
||||
|
||||
if (alignment == TextAlignment::TopLeft) {
|
||||
point = rect.location();
|
||||
} else if (alignment == TextAlignment::CenterLeft) {
|
||||
|
@ -343,8 +343,8 @@ void Painter::draw_text(const Rect& rect, const String& text, TextAlignment alig
|
|||
}
|
||||
|
||||
int space_width = font().glyph_width(' ') + font().glyph_spacing();
|
||||
for (ssize_t i = 0; i < text.length(); ++i) {
|
||||
byte ch = text[i];
|
||||
for (ssize_t i = 0; i < length; ++i) {
|
||||
char ch = text[i];
|
||||
if (ch == ' ') {
|
||||
point.move_by(space_width, 0);
|
||||
continue;
|
||||
|
@ -354,6 +354,11 @@ void Painter::draw_text(const Rect& rect, const String& text, TextAlignment alig
|
|||
}
|
||||
}
|
||||
|
||||
void Painter::draw_text(const Rect& rect, const String& text, TextAlignment alignment, Color color)
|
||||
{
|
||||
draw_text(rect, text.characters(), text.length(), alignment, color);
|
||||
}
|
||||
|
||||
void Painter::set_pixel(const Point& p, Color color)
|
||||
{
|
||||
auto point = p;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue