summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/Painter.cpp
blob: 9f9688a94ce6d9d039e4a8a4555b41b76f877f3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibGUI/Painter.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
#include <LibGfx/Bitmap.h>

namespace GUI {
Painter::Painter(Gfx::Bitmap& bitmap)
    : Gfx::Painter(bitmap)
{
}

Painter::Painter(Widget& widget)
    : Painter(*widget.window()->back_bitmap())
{
    state().font = &widget.font();
    auto origin_rect = widget.window_relative_rect();
    state().translation = origin_rect.location();
    state().clip_rect = origin_rect.intersected(m_target->rect());
    m_clip_origin = state().clip_rect;
}

}