Re: TODO item: proportional scaling



Le Wed, May 01, 2002, à 04:36:58PM -0400, Titus J. Anderson a écrit:
So, I thought I'd try my hand at it.  It only works for boxes right now, but
shouldn't be too difficult to make it work for the other basic objects.  Here's
the patch for v0.88.1 (I'm not working with the CVS version at this point.)

Sounds like a good idea; however, this patch can't be applied "as is": there 
has been a lot of StdProp-related changes in CVS, which impact the definition 
of Element (you'll need to add this aspectRatio field to the stdprop
description of an Element). Also, it must be clear that this approach break
binary compatibility -- I don't care at all, at least until we hit 1.0, but
some might. 

!   if (modifiers == MODIFIER_SHIFT) {
!     element_move_handle_aspect(&box->element, handle->id, to, (real) box->element.aspectRatio);
!   } else {
!     element_move_handle(&box->element, handle->id, to, reason);
!   }

Perhaps a better idea here would be to add a parameter to
element_move_handle (and fix all invocations), passing the modifiers.
element_move_handle() will be able to access aspectRatio on its own (hmmm --
better call it aspect_ratio for consistency with the rest of the code,
thanks), and factorise out the test on the modifiers' state into the common
element code.

*************** box_create(Point *startpoint,
*** 511,516 ****
--- 515,521 ----
    elem->corner = *startpoint;
    elem->width = DEFAULT_WIDTH;
    elem->height = DEFAULT_WIDTH;
+   elem->aspectRatio = elem->width / elem->height;

May be better to init this value in element_init(), and not paying attention
to it if it is zero, and recompute it in element_update_data() ? This way,
save the extra parameter, there is no change to individual objects, only to
the common code.

        -- Cyrille

-- 
Grumpf.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]