diff options
author | Linus Groh <mail@linusgroh.de> | 2023-01-12 14:39:53 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-12 15:14:09 +0000 |
commit | 0cc151bc1cdeeb4b8977102d9cabddf091c014db (patch) | |
tree | 7fe4389edb57f503bcbc4396b94b6959ac59d539 /Ladybird/WebContentView.cpp | |
parent | 05ef6c9b640b815d02ed335c09df90b7ac948ff2 (diff) | |
download | serenity-0cc151bc1cdeeb4b8977102d9cabddf091c014db.zip |
Ladybird: Implement zoom :^)
Diffstat (limited to 'Ladybird/WebContentView.cpp')
-rw-r--r-- | Ladybird/WebContentView.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Ladybird/WebContentView.cpp b/Ladybird/WebContentView.cpp index 59be8b6737..5ff8f17704 100644 --- a/Ladybird/WebContentView.cpp +++ b/Ladybird/WebContentView.cpp @@ -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); |