Btw, there is a unittest (KisZoomAndPanTest) that could help you with the code. I guess I didn't add a testcase for handling of the image resize. You can play with it as well, if you like :)<br><br><div class="gmail_quote">
On Wed, Jan 30, 2013 at 11:30 PM, Dmitry Kazakov <span dir="ltr"><<a href="mailto:dimula73@gmail.com" target="_blank">dimula73@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi, Sven!<div><br></div><div>I looked in the code. It looks like the problem is a bit more general. When we do Resize Image or Resize Canvas actions, the canvas is resized on screen, but the offset does *not* change. This looks actually not quite bad for these very actions, because the user considers it as "the canvas is scaled relative to the topleft corner". But this is, of course, not the best way from the usability point of view. You can actually check this if you remove all the pan() calls from the KisCropTool. The cropped area will be moved to the topleft corner of the initial canvas.</div>

<div><br></div><div>So, I guess, we could widen this bug to all the three actions. We would get the equal requirements for all these actions (Crop, Resize, Rescale):</div><div>1) If the zoom mode is Fit{Width,Page}, switch to Fixed Zoom mode of the same scale</div>

<div>2) Recenter the resulting image on screen without changing transformation (the center of the image is in the center of screen)</div><div><br></div><div>If we generalize these requirements to all the three actions, then the problems with threaded execution and undo well be solved very easily, because the code, that handles resizing of the image in the UI (called by the automatically emitted signal) is placed in one place, in KisView2::slotImageSizeChanged().</div>

<div><br></div><div>You could probably just add something like (and remove the code from KisCropTool at all):</div><div><br></div><div><pre style="font-size:12px;line-height:14.390625px;margin-top:0px;margin-bottom:0px;padding:0px;background-image:none;vertical-align:top">
<span style>m_d<span>-</span><span>></span>zoomManager<span>-</span><span>></span>zoomController<span>()->resetToFixedZoom();</span></span></pre>
<pre style="font-size:12px;line-height:14.390625px;margin-top:0px;margin-bottom:0px;padding:0px;background-image:none;vertical-align:top"><pre style="margin-top:0px;margin-bottom:0px;padding:0px;background-image:none;vertical-align:top">
<span style>m_d<span>-</span><span>></span>canvasController<span>->setPreferredCenter(widgetSizeRect.center());</span></span></pre><pre style="margin-top:0px;margin-bottom:0px;padding:0px;background-image:none;vertical-align:top">
<span style>m_d-<span>></span>canvasController->recenterPreferred()</span></pre></pre><div><br></div><div>The question is whether we need to generalize these actions or not, but I guess this is quite ok from the UI pov.</div>

<br><br></div><div><br><div class="gmail_quote"><div><div class="h5">On Wed, Jan 30, 2013 at 4:43 AM, Sven Langkamp <span dir="ltr"><<a href="mailto:sven.langkamp@gmail.com" target="_blank">sven.langkamp@gmail.com</a>></span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">Hi,<br>
<br>
<br>
<br>
I have modified the patch for the cropping tool to work with transform<br>
images without resetting transformation. It's does pan the canvas by<br>
the widget distance of the crop rect before and the (0,0) image pixel<br>
after cropping. It still requires an ugly hack that I would like to<br>
avoid: The new values are not immoderately available after cropping so<br>
I use a timer to add a small delay. Dmitry do you have an idea how<br>
that can be avoided? Any signal that tells that the update is<br>
finished?<br>
<br>
Patch is attached.<br>
<span><font color="#888888"><br>
<br>
<br>
Sven<br>
</font></span><br></div></div>_______________________________________________<br>
kimageshop mailing list<br>
<a href="mailto:kimageshop@kde.org" target="_blank">kimageshop@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/kimageshop" target="_blank">https://mail.kde.org/mailman/listinfo/kimageshop</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br>Dmitry Kazakov
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Dmitry Kazakov