1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

Ladybird: Implement zoom :^)

This commit is contained in:
Linus Groh 2023-01-12 14:39:53 +00:00
parent 05ef6c9b64
commit 0cc151bc1c
4 changed files with 82 additions and 0 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -575,6 +576,35 @@ void WebContentView::set_color_scheme(ColorScheme color_scheme)
}
}
void WebContentView::zoom_in()
{
if (m_zoom_level >= ZOOM_MAX_LEVEL)
return;
m_zoom_level += ZOOM_STEP;
update_zoom();
}
void WebContentView::zoom_out()
{
if (m_zoom_level <= ZOOM_MIN_LEVEL)
return;
m_zoom_level -= ZOOM_STEP;
update_zoom();
}
void WebContentView::reset_zoom()
{
m_zoom_level = 1.0f;
update_zoom();
}
void WebContentView::update_zoom()
{
client().async_set_device_pixels_per_css_pixel(m_device_pixel_ratio * m_zoom_level);
update_viewport_rect();
request_repaint();
}
void WebContentView::showEvent(QShowEvent* event)
{
QAbstractScrollArea::showEvent(event);