Version: 1.2.0_devel (using KDE 3.4.0, compiled sources) Compiler: gcc version 3.4.3 OS: SunOS (sun4u) release 5.8 When inserting an image, in some cases it is crucial to be able to maintain its aspect ratio. This is currently impossible to do. I think a "Maintain aspect ratio" option should be added, and even used as default.
Should implement for 1.3.
I think this should be "blocked" by a more important issue: WYSIWYG, and maintaining aspect ratio of all objects.
George, I don't understand your comment... From my experiments, there is a modifier key that allows to resize objects while maintaining their aspect ratio, which is good. The problem (specific to image objects) is that you need to define their bounding box blindly, before you can insert the image since the dialog wher you sprecify the input file comes only after you've drawn a rectangle. The problem (and difference with other objects) is due to the fact that for images there is a "right" size (or at least aspect ratio) *before* you start drawing (that of the original image file). This is not the case when you draw other objects, which do not have a "right" size a priori.
Proposal: Add a Maintain aspect ratio checkbox to the picture dialog. If this is checked then when creating a new picture object the aspect ratio will be maintained. This would be relatively simple. More difficult would be enforcing the aspect ratio when a picture object is saved to a graphics file, printed, or dropped onto another object (changing its parent). For these cases we could assume that the top-left corner remains fixed in aspect relative to the parent. Are there any other such cases? Should we prefer to modify the width or the height to maintain the aspect ratio? Or possibly whichever necessitates the smaller change in pixel space.
The fixed aspect ration images should work conceptually in the same way as a label. They should render on any output medium with a fixed aspect ratio, as do labels. The anchor position (I think it is the bottom left) should be the same for fixed aspect images as it is for labels.
SVN commit 541675 by dhanson: BUG:121159 Added a _maintainAspect boolean for KstViewObjects, which allows the default behaviour when resizing objects to be aspect preserving. Added a checkbox to the KstViewPicture to enable this option. If this checkbox is enabled when the image source is selected, then the KstViewPicture will override the user's initial size choice to maintain the aspect ratio. M +1 -0 kstborderedviewobject.h M +18 -17 ksttoplevelview.cpp M +5 -5 ksttoplevelview.h M +13 -0 kstviewobject.cpp M +4 -0 kstviewobject.h M +31 -0 kstviewpicture.cpp M +6 -0 kstviewpicture.h
The changes modify the aspect ratio correctly when the object is first created, but should continually maintain the aspect ratio as the parent object is resized (including printing, exporting, etc.)
Please don't commit this without posting a patch for review first.
Created attachment 16164 [details] Proposed patch. Maintains aspect when view objects or their parents are resized if _maintainAspect is enabled.
There are a few problems with this: 1) tha aspect ratio of the original picture is not maintained if I create a picture and then alter the size of the parent window 2) if I use the SHIFT key while resizing the picture the maintain aspect ratio should be unchecked 3) using the SHIFT key while resizing the picture does not create the size of picture I was expecting based on the preview of the resize
I can't reproduce (1). I agree with (2). (3) is a result of my not implementing (2). I would like to remove the aspect maintaining code from the KstViewObject::resize part of the patch, and just trust that the mouse graphics handler has ensured that the new size will maintain aspect. This will effectively fix (2) as well.
SVN commit 544402 by dhanson: BUG:121159 objects with _maintainAspect == true will now maintain their aspect on parent resize. M +6 -0 kstviewobject.cpp --- trunk/extragear/graphics/kst/src/libkstapp/kstviewobject.cpp #544401:544402 @@ -1455,6 +1455,12 @@ _geom.setTop(geom.top() + int(_aspect.y * geom.height())); _geom.setRight(geom.left() + int((_aspect.x + _aspect.w) * geom.width()) - 1); _geom.setBottom(geom.top() + int((_aspect.y + _aspect.h) * geom.height()) - 1); + + if (_maintainAspect == true) { + QSize maintaining_size(myOldGeom.size()); + maintaining_size.scale(_geom.size(),QSize::ScaleMin); + _geom.setSize(maintaining_size); + } } if (_geom.width() < _minimumSize.width() || _geom.height() < _minimumSize.height()) { _geom.setSize(_geom.size().expandedTo(_minimumSize));