1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:47:45 +00:00

WindowServer: Load multiple scaled versions of Bitmaps and Cursors

This enables rendering of mixed-scale screen layouts with e.g. high
resolution cursors and window button icons on high-dpi screens while
using lower resolution bitmaps on regular screens.
This commit is contained in:
Tom 2021-06-18 19:21:30 -06:00 committed by Andreas Kling
parent aa15bf81e4
commit 61af9d882e
15 changed files with 269 additions and 99 deletions

View file

@ -9,6 +9,7 @@
#include <LibGfx/StylePainter.h>
#include <WindowServer/Button.h>
#include <WindowServer/Event.h>
#include <WindowServer/Screen.h>
#include <WindowServer/WindowManager.h>
namespace WindowServer {
@ -23,7 +24,7 @@ Button::~Button()
{
}
void Button::paint(Gfx::Painter& painter)
void Button::paint(Screen& screen, Gfx::Painter& painter)
{
auto palette = WindowManager::the().palette();
Gfx::PainterStateSaver saver(painter);
@ -31,10 +32,11 @@ void Button::paint(Gfx::Painter& painter)
Gfx::StylePainter::paint_button(painter, rect(), palette, Gfx::ButtonStyle::Normal, m_pressed, m_hovered);
if (m_icon) {
auto icon_location = rect().center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2));
auto& bitmap = m_icon->bitmap(screen.scale_factor());
auto icon_location = rect().center().translated(-(bitmap.width() / 2), -(bitmap.height() / 2));
if (m_pressed)
painter.translate(1, 1);
painter.blit(icon_location, *m_icon, m_icon->rect());
painter.blit(icon_location, bitmap, bitmap.rect());
}
}