mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-06 17:48:37 +00:00
PixelPaint: Add keyboard zoom shortcuts
You can now use Ctrl+= and Ctrl+- to zoom in and out.
This commit is contained in:
parent
b48b8c372e
commit
2976311536
Notes:
sideshowbarker
2024-07-18 20:15:28 +09:00
Author: https://github.com/danielledeleo
Commit: 2976311536
Pull-request: https://github.com/SerenityOS/serenity/pull/6368
Issue: https://github.com/SerenityOS/serenity/issues/4138
Reviewed-by: https://github.com/linusg
3 changed files with 31 additions and 6 deletions
|
@ -370,15 +370,19 @@ Layer* ImageEditor::layer_at_editor_position(const Gfx::IntPoint& editor_positio
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void ImageEditor::scale_centered_on_position(const Gfx::IntPoint& position, float scale_delta)
|
||||
void ImageEditor::clamped_scale(float scale_delta)
|
||||
{
|
||||
auto old_scale = m_scale;
|
||||
|
||||
m_scale += scale_delta;
|
||||
if (m_scale < 0.1f)
|
||||
m_scale = 0.1f;
|
||||
if (m_scale > 100.0f)
|
||||
m_scale = 100.0f;
|
||||
}
|
||||
|
||||
void ImageEditor::scale_centered_on_position(const Gfx::IntPoint& position, float scale_delta)
|
||||
{
|
||||
auto old_scale = m_scale;
|
||||
clamped_scale(scale_delta);
|
||||
|
||||
Gfx::FloatPoint focus_point {
|
||||
m_pan_origin.x() - (position.x() - width() / 2.0f) / old_scale,
|
||||
|
@ -393,11 +397,19 @@ void ImageEditor::scale_centered_on_position(const Gfx::IntPoint& position, floa
|
|||
relayout();
|
||||
}
|
||||
|
||||
void ImageEditor::scale_by(float scale_delta)
|
||||
{
|
||||
if (scale_delta != 0) {
|
||||
clamped_scale(scale_delta);
|
||||
relayout();
|
||||
}
|
||||
}
|
||||
|
||||
void ImageEditor::reset_scale_and_position()
|
||||
{
|
||||
if (m_scale != 1.0f)
|
||||
m_scale = 1.0f;
|
||||
|
||||
|
||||
m_pan_origin = Gfx::FloatPoint(0, 0);
|
||||
relayout();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue