Repository navigation
Conversation
1. Root cause: adjustViewScaleRatio() used full viewport dimensions to compute scale ratio without reserving any margin 2. Fix: subtract 40px (20px per side) from viewport width and height before computing the scale ratio 3. Impact: both crop and non-crop modes now keep >=20px margin on all sides; no API change, only local variable adjustment Log: canvas now keeps 20px margin on all sides of viewport Influence: 1. Test image loading with various canvas sizes 2. Test crop mode entry/exit with different viewport sizes 3. Verify no regression on manual zoom and page switch fix: 缩放计算预留画布边距 1. 根因:adjustViewScaleRatio() 使用 viewport 全量尺寸计算缩放比, 未预留任何边距 2. 方案:计算缩放比前从 viewport 尺寸中减去 40px(每侧 20px) 3. 影响:裁剪与非裁剪模式均保证四边至少 20px 间距;无接口变更 Log: 画布四边预留 20px 边距,修复裁剪时贴边问题 Influence: 1. 测试不同画布尺寸下的图像加载 2. 测试不同 viewport 尺寸下裁剪模式进出 3. 验证手动缩放和页面切换无回归 PMS: BUG-287307
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideImplementationReserve 20 pixels on each side of the viewport before calculating the view scale ratio.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/frame/ccentralwidget.cpp" line_range="718-719" />
<code_context>
- 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;
qreal sceneWidth = scene()->width();
qreal sceneHeight = scene()->height();
</code_context>
<issue_to_address>
**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.
</issue_to_address>
### Comment 2
<location path="src/frame/ccentralwidget.cpp" line_range="718-719" />
<code_context>
- 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;
qreal sceneWidth = scene()->width();
qreal sceneHeight = scene()->height();
</code_context>
<issue_to_address>
**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.
</issue_to_address>
### Comment 3
<location path="src/frame/ccentralwidget.cpp" line_range="718" />
<code_context>
- 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;
qreal sceneWidth = scene()->width();
</code_context>
<issue_to_address>
**Imported images keep the old scale**
When an image is imported through the type-1 adaptation path or `DrawBoard::loadImage()`, those paths do not call `adjustViewScaleRatio()`, so an oversized canvas keeps its previous scale and can reach the viewport edges.
Call `adjustViewScaleRatio()` on both image-import paths.
</issue_to_address>| int viewportWidth = view()->viewport()->width() - margin * 2; | ||
| int viewportHeight = view()->viewport()->height() - margin * 2; |
There was a problem hiding this comment.
🟡 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 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.
Prompt for AI agents
In `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.| int viewportWidth = view()->viewport()->width() - margin * 2; | ||
| int viewportHeight = view()->viewport()->height() - margin * 2; |
There was a problem hiding this comment.
🟡 Medium · 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.
Prompt for AI agents
In `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.| int viewportWidth = view()->viewport()->width(); | ||
| int viewportHeight = view()->viewport()->height(); | ||
| const int margin = 20; | ||
| int viewportWidth = view()->viewport()->width() - margin * 2; |
There was a problem hiding this comment.
🟡 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 call adjustViewScaleRatio(), 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
In `src/frame/ccentralwidget.cpp` at line 718:
**Imported images keep the old scale**
When an image is imported through the type-1 adaptation path or `DrawBoard::loadImage()`, those paths do not call `adjustViewScaleRatio()`, so an oversized canvas keeps its previous scale and can reach the viewport edges.
Call `adjustViewScaleRatio()` on both image-import paths.
fix: reserve viewport margin in adjustViewScaleRatio
to compute scale ratio without reserving any margin
before computing the scale ratio
sides; no API change, only local variable adjustment
Log: canvas now keeps 20px margin on all sides of viewport
Influence:
fix: 缩放计算预留画布边距
未预留任何边距
Log: 画布四边预留 20px 边距,修复裁剪时贴边问题
Influence:
PMS: BUG-287307
Summary by Sourcery
Bug Fixes: