mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:17:44 +00:00
LibGUI+PixelPaint: Move fit_image_to_view to AbstractZoomPanWidget
We often want to zoom and fit the content of the widget into the visible frame (or some rect within the frame), and it makes sense to move this functionality into the AbstractZoomPanWidget to minimize the amount of coordinate math derived classes need to do. This commit moves the code that implements this functionality from `PixelPaint::ImageEditor` into `AbstractZoomPanWidget` so that we can also use it for other applications (such as ImageViewer!)
This commit is contained in:
parent
12daecf72d
commit
5c763e9832
5 changed files with 39 additions and 30 deletions
|
@ -54,6 +54,17 @@ public:
|
|||
|
||||
Function<void(float)> on_scale_change;
|
||||
|
||||
enum class FitType {
|
||||
Width,
|
||||
Height,
|
||||
Both
|
||||
};
|
||||
void fit_content_to_rect(Gfx::IntRect const& rect, FitType = FitType::Both);
|
||||
void fit_content_to_view(FitType fit_type = FitType::Both)
|
||||
{
|
||||
fit_content_to_rect(rect(), fit_type);
|
||||
}
|
||||
|
||||
private:
|
||||
Gfx::IntRect m_original_rect;
|
||||
Gfx::IntRect m_content_rect;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue