Re: Resize Window with fixed ratio
Re: Resize Window with fixed ratio
- Subject: Re: Resize Window with fixed ratio
- From: Lorenzo <email@hidden>
- Date: Fri, 19 Nov 2004 20:11:28 +0100
Yes, I know that frameRect != contentRect.
Maybe you didn't read my email carefully.
I mean that, if I redefine the ratio within the windowWillResize, thus all
the time, the proposed size and also the content rect size will be the last
size I let set.
Since this size is rounded to an integer value, I lose my initial float
ratio, so e.g. if I started from 1024 x 768, and I resize firslty to 512 x
384, then, without releasing the mouse, I go back to 1024, I don't get back
768 but 790.
I hope I was clear now. Anyway I solved the trouble. I define a ratio in the
windowDidResize, only if the type of current Event is not NSLeftMouseDragged
or the shift is not pressed. This let me set the ratio automatically at any
time the window changes size because of opening a file, or changing a
value... and, in case of hand-resizing, the ratio value doesn't change. It
remains the last set.
;-)
However I would like to have a method like "windowShouldResize" which should
be much better than having an unuseful headhake...
Best Regards
--
Lorenzo
email: email@hidden
> From: Glenn Andreas <email@hidden>
> Date: Fri, 19 Nov 2004 09:10:06 -0600
> To: Lorenzo <email@hidden>
> Cc: email@hidden
> Subject: Re: Resize Window with fixed ratio
>
>> Hi,
>> I am trying to resize a window (by dragging the bottom-right corner) and
>> force the window to have a fixed ratio (height / width).
>>
>> I am using the "windowWillResize" method but it doesn't fit my needs.
>>
>> I need to set the ratio just "before" the resizing begins, so if the user
>> hold down the Shift key, he resizes the window proportionally; otherwise he
>> resizes the window with custom size.
>>
>> The problem is that I cannot find any method like "windowShouldResize" and I
>> cannot get the ratio before the resizing begins.
>
>
> IIRC, if you grab the content rect of the window in windowWillResize,
> it will be the size that the window currently is before it is resized
> (so you can use the ratio of the current size if the shift key is
> down).
>
>
> Also, don't forget that frameRect != contentRect (and when
> constraining, you usually want the content to be constrained, and not
> the frame), so contentRectForFrameRect:/frameRectForContentRect are
> your friends
> --
> Glenn Andreas email@hidden
> <http://www.gandreas.com/> oh my!
> Mad, Bad, and Dangerous to Know
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden