1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 17:37:35 +00:00

Get rid of the "root widget" concept in WindowManager.

Instead just create a GraphicsBitmap wrapper around the display framebuffer
and teach Painter how to draw directly into a GraphicsBitmap.
This commit is contained in:
Andreas Kling 2019-01-12 03:42:50 +01:00
parent 0e6c19ffa6
commit bb28c31531
10 changed files with 18 additions and 80 deletions

View file

@ -6,9 +6,15 @@
#include <AK/Assertions.h>
#include <AK/StdLibExtras.h>
Painter::Painter(GraphicsBitmap& bitmap)
{
m_font = &Font::defaultFont();
m_target = &bitmap;
m_clipRect = { { 0, 0 }, bitmap.size() };
}
Painter::Painter(Widget& widget)
: m_widget(widget)
, m_font(&widget.font())
: m_font(&widget.font())
{
m_target = widget.backing();
ASSERT(m_target);
@ -102,7 +108,6 @@ void Painter::drawText(const Rect& rect, const String& text, TextAlignment align
if (alignment == TextAlignment::TopLeft) {
point = rect.location();
} else if (alignment == TextAlignment::CenterLeft) {
int textWidth = text.length() * font().glyphWidth();
point = { rect.x(), rect.center().y() - (font().glyphHeight() / 2) };
} else if (alignment == TextAlignment::Center) {
int textWidth = text.length() * font().glyphWidth();