Repository navigation
fix: reserve viewport margin in adjustViewScaleRatio #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -714,8 +714,9 @@ void Page::closeEvent(QCloseEvent *event) | |
| void Page::adjustViewScaleRatio() | ||
| { | ||
| if (nullptr != view()) { | ||
| int viewportWidth = view()->viewport()->width(); | ||
| int viewportHeight = view()->viewport()->height(); | ||
| const int margin = 20; | ||
| int viewportWidth = view()->viewport()->width() - margin * 2; | ||
| int viewportHeight = view()->viewport()->height() - margin * 2; | ||
|
Comment on lines
+718
to
+719
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Canvas stays at minimum zoom When either viewport dimension is below 40px during an adjustment, the 20px margin subtraction makes an available dimension nonpositive, so the fit ratio is nonpositive and Prevent nonpositive fit dimensions and rerun the adjustment when the viewport is enlarged. Prompt for AI agentsIn `src/frame/ccentralwidget.cpp` at lines 718-719:
**Canvas stays at minimum zoom**
When either viewport dimension is below 40px during an adjustment, the 20px margin subtraction makes an available dimension nonpositive, so the fit ratio is nonpositive and `PageView::scaleWithCenter()` clamps it to 0.1; the canvas is left at minimum zoom instead of fitting. An image-load adjustment stays there after a later resize.
Prevent nonpositive fit dimensions and rerun the adjustment when the viewport is enlarged.
Comment on lines
+718
to
+719
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Canvas exceeds the margins When the canvas needs a fit ratio below 0.1, Allow this fit adjustment to use ratios below 0.1. Prompt for AI agentsIn `src/frame/ccentralwidget.cpp` at lines 718-719:
**Canvas exceeds the margins**
When the canvas needs a fit ratio below 0.1, `PageView::scaleWithCenter()` clamps the requested ratio to 0.1, so the canvas remains larger than the margin-reduced viewport and reaches or extends beyond its edges.
Allow this fit adjustment to use ratios below 0.1. |
||
| qreal sceneWidth = scene()->width(); | ||
| qreal sceneHeight = scene()->height(); | ||
| if (viewportWidth < sceneWidth || viewportHeight < sceneHeight) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Imported images keep the old scale
When an image is imported through the type-1 adaptation path or
DrawBoard::loadImage(), those paths do not calladjustViewScaleRatio(), so an oversized canvas keeps its previous scale and can reach the viewport edges.Call
adjustViewScaleRatio()on both image-import paths.Prompt for AI agents