Keep stack proportions when resizing

Peter Bogdanoff bogdanoff at me.com
Fri Oct 8 17:11:38 EDT 2021


Thanks Devin, I’ll try these out.

I’m seeing that the resizing process is not going to be visually smooth, so I’m content at present to have something that does the job in chunks or at the end of the resize.

Peter

> On Oct 8, 2021, at 4:56 PM, Devin Asay via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Peter,
> 
> I asked this question several years ago and what I gathered is that it’s not easy because window resizing is under the control of the operating system, and LiveCode can’t really override it.
> 
> My attempts were not completely satisfactory:
> 
> I have a stack that I want to constrain to a 4:3 ratio when resizing, with a minimum stack size of 800 X 600. A search of the archives didn't yield any relevant results.
> 
> If I do this (in the resizeStack handler):
> 
> put the topLeft of this stack into tAnchorPnt
> set the height of this stack to (pNewWdth * 3) div 4
> set the topLeft of this stack to tAnchorPnt
> 
> it works as long as my drag on the resize gadget has a horizontal component.
> 
> Likewise, this works:
> 
> put the topLeft of this stack into tAnchorPnt
> set the width of this stack to (pNewHgt * 4) div 3
> set the topLeft of this stack to tAnchorPnt
> 
> as long as there is a vertical component to the drag.
> 
> This:
> 
> put the topLeft of this stack into tAnchorPnt
> if pNewWdth <> pOldWdth then
>   set the height of this stack to (pNewWdth * 3) div 4
> else
>   set the width of this stack to (pNewHgt * 4) div 3
> end if
> set the topLeft of this stack to tAnchorPnt
> 
> Just produces bizarre results.
> 
> After I posted about it,I did get a few workarounds.
> 
> Scott Rossi suggested that you create your own resize handle instead of using the one built-in to the window:
> 
> One way to do this is to use a dedicated object for the resizer and to
> calculate the new dimensions before resizing the stack.
> 
> Execute this in your message box:
> go url "http://www.tactilemedia.com/download/constrained.livecode"
> 
> This demonstrates one way to do a 4 x 3 ratio stack.  I'm not sure if it's
> possible to get the window refresh to completely sync with the location of
> the resizer, but maybe this will get you close.
> 
> Roger Eller and Berndt Niggeman suggested that you can’t do it in real time, but you could “snap” it to the correct size after resizing:
> 
> I am with Roger on this.
> 
> here is a little code snippet that does constrain the aspect after resizing
> 
> -----------------------------------------------------------
> on resizeStack pNewWidth, pNewHeight, pOldWidth, pOldHeight
> 
>  -- block repeat loop if you want to have all the changes occur after last
> resize, kind of animation
>  repeat for each line aMessage in the pendingMessages
>     if aMessage contains "adjustRatio" then cancel item 1 of aMessage
>  end repeat
> 
>  send "adJustRatio pNewWidth, pNewHeight, pOldWidth, pOldHeight" to me in
> 0 milliseconds
> end resizeStack
> 
> on adJustRatio pNewWidth, pNewHeight, pOldWidth, pOldHeight
>  put round (pNewWidth / 2) into tNewHeight
>  put the rect of me into tRect
>  put item 2 of tRect + tNewHeight into item 4 of tRect
>  set the rect of me to tRect
> end adJustRatio
> -----------------------------------------------------------
> 
> 
> Dunbarx suggested trapping the resizeStack handler, but that doesn’t seem to work just right, probably because the message is sent *after* the resize, not before.
> 
> Hope this helps.
> 
> - Devin
> 
> 
> On Oct 8, 2021, at 1:18 PM, Peter Bogdanoff via use-livecode <use-livecode at lists.runrev.com<mailto:use-livecode at lists.runrev.com>> wrote:
> 
> Does anyone have a script to keep a stack’s proportions constant when the user is changing the stack size by dragging the lower right corner? This is a stack with a control containing a video or image. I’ve used the geometry manager for the objects within the stack but the stack itself needs to be shaped correctly.
> 
> Peter Bogdanoff
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com<mailto:use-livecode at lists.runrev.com>
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> Devin Asay
> Director
> Office of Digital Humanities
> Brigham Young University
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list