mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-21 07:06:04 +00:00
Ladybird: Implement zoom :^)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user