Re: Stupid Question Again - Proportional Scaling

2018-03-19 Thread Bob Sneidar via use-livecode
> On Mar 18, 2018, at 09:57 , Richard Gaskin via use-livecode 
>  wrote:
> 
> How often do we see apps that constrain window resizing?

This is common I think for apps which have a set of fields displaying data, 
tables etc. Maybe there are some panes and tabs, but to reduce the window to 
less than x,y would require the contents to be scrollable. We have an app whose 
window settings get corrupted if Windows Display has a scale factor set over 
100%. Another app will simply refuse to run if the resolution of the current 
monitor is below a minimum. A lot of times developers don't want to deal with 
window geometry. Their solution is to tell you, "Don't do that" when it comes 
to window sizing, or they don't allow you to do it at all. 

Bob S




___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread Richard Gaskin via use-livecode

J. Landman Gay wrote:

> On 3/18/18 12:41 PM, Richard Gaskin via use-livecode wrote:
>> Exactly.  The contents of the window can respond to the resizeStack
>> message to be maximized within the window's content region without
>> necessarily constraining the resize of the window's shape itself.
>>
>
> Sure, but aesthetically it's ugly.

That's a pretty sweeping dismissal of the countless apps that handle 
this problem that way.


Some feel that many multi-window apps are ugly, in a world increasingly 
migrating to less fidgety UIs that keep everything in one window 
separated by panes (consider Premier vs iMovie).


Personally, I'm disinclined to consider any solution "ugly" until I've 
seen the context of use.


With this challenge of displaying an image in a window, if the common 
solution is truly ugly you've chosen the wrong neutral color. ;)


Otherwise it's simply a design decision, as attractive or unattractive 
as you make it.


Inventing novel interaction models that break from user expectations is 
not without some risk of its own.  I won't go so far as to say it's 
necessarily ugly, but whenever I find myself considering a seldom-seen 
against-the-grain solution I first look at how others solve this and 
consider the necessity of inventing new ways of doing things as common 
as resizing windows.


But in some rare cases, rare solutions may be the perfect fit.

HH's code is very nice - does the job well, resizing very smoothly on my 
Ubuntu box.  If it's what's needed, by all means use it.


Without seeing the full app design, I have no opinion of whether any 
proposed solution could be considered attractive or otherwise.  I'm just 
providing options for consideration.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread hh via use-livecode
Never tried to script that. It's *eventually* simple -- as always with LC.
Here again a little bit optimised, changing the size also by the scrollWheel:

-- 1. Don't use a resizestack handler
-- 2. Set resizable of the stack to FALSE

local l0, t0, ff

on mouseDown
 put the long id of the target into tgt
 if not tgt begins with "image " then exit mouseDown
 put the left of this stack into l0
 put the top of this stack into t0
 -- if the image is always the same then ff can be computed once
 put the formattedHeight of tgt/the formattedWidth of tgt into ff
 put the right of tgt - the clickH into dx
 setRects dx,tgt
end mouseDown

on setRects dx,tgt
 if setRects is in the pendingmessages then exit setRects
 lock screen; lock messages
 put dx+the mouseH into w0
 put ff*w0 into h0
 set the rect of this stack to (l0,t0,l0+w0,t0+h0)
 set the rect of tgt to (0,0,w0,h0)
 if the mouse is down --> TMHO, polling the mouse is here OK
 then send "setRects dx,tgt" to me in 8 millisecs --> 8-16 millisecs
end setRects

on rawkeydown k
 put the long id of the target into tgt
 if not tgt begins with "image " then pass rawkeydown
 lock screen; lock messages
 put the left of this stack into l0
 put the top of this stack into t0
 switch k
   case 65308; put  16 into d; break -- scrollwheel backward
   case 65309; put -16 into d; break -- scrollwheel forward
 end switch
 put d+the width of tgt into w0
 -- if the image is always the same then this becomes: put w0*ff into h0
 put w0*the formattedHeight of tgt/the formattedWidth of tgt into h0
 set the rect of this stack to (l0,t0,l0+w0,t0+h0)
 set the rect of tgt to (0,0,w0,h0)
end rawkeydown

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread J. Landman Gay via use-livecode

Very nice. :)

On 3/18/18 1:29 PM, hh via use-livecode wrote:

@Peter
You could try the following (doesn't need a shiftkey down).
Put the following into the stack's script and drag anywhere the
image to resize it and the stack proportionally (topLeft fixed).

-- 1. Don't use any resize stack handler
-- 2. set resizable of the stack to FALSE

local l0, t0, ew, eh

on mouseDown
   put the long id of the target into tgt
   if not tgt begins with "image " then exit mouseDown
   put the left of this stack into l0
   put the top of this stack into t0
   put the formattedWidth of tgt into ew
   put the formattedHeight of tgt into eh
   put the right of tgt - the clickH into dx
   setRects dx,tgt
end mouseDown

on setRects dx,tgt
   lock screen; lock messages
   put dx+the mouseH into w0; put eh/ew * w0 into h0
   set the rect of this stack to (l0,t0,l0+w0,t0+h0)
   set the rect of tgt to (0,0,w0,h0)
   if the mouse is down --> TMHO, polling the mouse is here OK
   then send "setRects dx,tgt" to me in 8 millisecs --> 8-16 millisecs



end setRects



--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread J. Landman Gay via use-livecode

On 3/18/18 12:41 PM, Richard Gaskin via use-livecode wrote:
Exactly.  The contents of the window can respond to the resizeStack 
message to be maximized within the window's content region without 
necessarily constraining the resize of the window's shape itself.




Sure, but aesthetically it's ugly.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread hh via use-livecode
@Peter
You could try the following (doesn't need a shiftkey down).
Put the following into the stack's script and drag anywhere the
image to resize it and the stack proportionally (topLeft fixed).

-- 1. Don't use any resize stack handler
-- 2. set resizable of the stack to FALSE

local l0, t0, ew, eh

on mouseDown
  put the long id of the target into tgt
  if not tgt begins with "image " then exit mouseDown
  put the left of this stack into l0
  put the top of this stack into t0
  put the formattedWidth of tgt into ew
  put the formattedHeight of tgt into eh
  put the right of tgt - the clickH into dx
  setRects dx,tgt
end mouseDown

on setRects dx,tgt
  lock screen; lock messages
  put dx+the mouseH into w0; put eh/ew * w0 into h0
  set the rect of this stack to (l0,t0,l0+w0,t0+h0)
  set the rect of tgt to (0,0,w0,h0)
  if the mouse is down --> TMHO, polling the mouse is here OK
  then send "setRects dx,tgt" to me in 8 millisecs --> 8-16 millisecs



end setRects


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread Richard Gaskin via use-livecode
Exactly.  The contents of the window can respond to the resizeStack 
message to be maximized within the window's content region without 
necessarily constraining the resize of the window's shape itself.


--
 Richard Gaskin
 Fourth World Systems

J. Landman Gay wrote:
> I think he wants to use window resizing as an automatic zoom, like
> a magnifying glass. Google Maps does this with + and - buttons but
> doesn't resize the window content to fit.
> --
> Jacqueline Landman Gay | jacque at hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
>
> On March 18, 2018 11:58:55 AM Richard Gaskin via use-livecode wrote:
>
> But if maintaining the image within the window to maximally fit
> the window's rect while maintaining its proportions is the goal,
> a suitably neutral color fil



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread J. Landman Gay via use-livecode
I think he wants to use window resizing as an automatic zoom, like a 
magnifying glass. Google Maps does this with + and - buttons but doesn't 
resize the window content to fit.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On March 18, 2018 11:58:55 AM Richard Gaskin via use-livecode 
 wrote:


But if maintaining the image within the window to maximally fit the
window's rect while maintaining its proportions is the goal, a suitably
neutral color filling the card would seem to suffice as at least as well
as whatever clutter may be behind the window outside of its bounds, no?



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread Richard Gaskin via use-livecode

Peter Reid wrote:

>> I have a sub-stack that contains an image.  I want the user to be
>> able to drag the corners and edges of the sub-stack window to make
>> the window and its image larger or smaller, but the window and
>> image must maintain their original aspect ratio ? no stretching,
>> no empty borders etc.
...
> It's a pity that this proved a bit more convoluted than perhaps it
> should have been.

How often do we see apps that constrain window resizing?

There are probably a few, and now one more.  But it's not common, and 
apparently what few OS APIs may be provided for such hooks aren't easy 
to access or at least often used, or we might see more of it.


LC tends to provide easy access to common UI objects and behaviors that 
the OSes make easy to use.  When we pursue and edge case is where things 
get tricky.


If your solution is working well for what you need then it's probably 
not worth revisiting the design.  But one thing I've learned from my 
customers is that they sometimes resize windows for reasons I didn't 
anticipate.


As designers, we tend to think of resizing a window as something we do 
to view the window's content.  In that use case, if the content is 
square there's certainly no harm, and perhaps some benefit, in 
constraining the user's resize action to keep the window square as well.


But I've found sometimes users resize windows to remove visual clutter 
from their desktop.  This can result in a window with empty space along 
at least two edges if the content within it has no sensible way to make 
full use of the window's content region.


Yet in some cases, I have to ask: why not let the user define their own 
preferred rect for the window, and I'll do my job of making the interior 
fit as usably and attractively as I can within whatever the user wants 
to do.


Of course I have no idea what you're building, and there may be some 
excellent reasons to constrain the user's resize action.


But if maintaining the image within the window to maximally fit the 
window's rect while maintaining its proportions is the goal, a suitably 
neutral color filling the card would seem to suffice as at least as well 
as whatever clutter may be behind the window outside of its bounds, no?


Certainly simpler to write. :)  When I find myself working hard against 
the grain of what OSes suggest for common UI elements, sometimes it 
helps me pause and reconsider *why* I'm doing that, to see if there's a 
more with-the-grain approach the maintains consistency for the user 
experience.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread Peter Reid via use-livecode
Hi Jacqueline & hh

Thanks for the feedback. After I sent my query I came across a relevant 
response in the forum:

https://forums.livecode.com/viewtopic.php?t=30385

In particular MaxV's response which is very similar to yours Jacqueline. When I 
tried this I too realised that I'd need a "send" to tidy-up afterwards!

Here's my complete code (all in the stack script):

local tAdjustingStack

on resizeStack
   if not tAdjustingStack then
  put the top of image "myImage" into tTop
  put the left of image "myImage" into tLeft
  put the realSize of image "MyImage" into tSize
  put the startsizeStack of image "myImage" into tSS
  set the width of image "myImage" to (item 1 of tSize * the width of this 
stack / item 1 of tSS )
  set the height of image "myImage" to (item 2 of tSize * the height of 
this stack / item 2 of tSS )
  if the width of image "myImage" > the height of image "myImage" then
 set the width of image "myImage" to (item 1 of tSize / item 2 of tSize 
* the height of image "myImage")
  else
 set the height of image "myImage" to (item 2 of tSize / item 1 of 
tSize * the width of image "myImage")
  end if
  set the top of image "myImage" to tTop
  set the left of image "myImage" to tLeft
   end if
   pass resizeStack
end resizeStack

on tidyUpAfterwards
   put the topLeft of this stack into tTL
   if the width of this stack <> the width of image "myImage" then
  lock screen
  put true into tAdjustingStack
  set the width of this stack to the width of image "myImage"
  set the topLeft of this stack to tTL
   end if
   if the height of this stack <> the height of image "myImage" then
  lock screen
  put true into tAdjustingStack
  set the height of this stack to the height of image "myImage"
  set the topLeft of this stack to tTL
   end if
   unlock screen
   put false into tAdjustingStack
   send "tidyUpAfterwards" to me in 5 ticks
end tidyUpAfterwards

on preOpenStack
   put false into tAdjustingStack
   set the realsize of image "myImage" to (the width of image "myImage", the 
height of image "myImage")
   set the startSizeStack of image "myImage" to (the width of this stack, the 
height of this stack) 
   send "tidyUpAfterwards" to me in 5 ticks
end preOpenStack

It's a pity that this proved a bit more convoluted than perhaps it should have 
been.

Thanks again.

Peter
--
Peter Reid
71 Leconfield Road, Loughborough, Leics. LE11 3SP, UK
Tel: +44 (0)1509 268843
Mobile/Cell: 07778 632533
Email: pe...@reidit.net

> Message: 1
> Date: Sat, 17 Mar 2018 17:14:36 +
> From: Peter Reid <pr...@reidit.co.uk>
> To: use-livecode@lists.runrev.com
> Subject: Stupid Question Again - Proportional Scaling
> Message-ID: <6de66fac-c1bc-4f32-8186-b76d769d7...@reidit.co.uk>
> Content-Type: text/plain; charset=utf-8
> 
> I know it's possible and I know it's simple really, but I can't remember 
> it/figure it out!
> 
> I have a sub-stack that contains an image.  I want the user to be able to 
> drag the corners and edges of the sub-stack window to make the window and its 
> image larger or smaller, but the window and image must maintain their 
> original aspect ratio ? no stretching, no empty borders etc.  I've tried the 
> following in the card script:
> 
> global gImageRatio
> 
> on resizeStack pNewWidth, pNewHeight, pOldWidth, pOldHeight
>   propSizeImage "coinSet", gImageRatio
>   pass resizeStack
> end resizeStack
> 
> on propSizeImage pImageName, @pImageRatio
>   put the width of this stack into propWidth
>   set the width of image pImageName to propWidth 
>   put propWidth div pImageRatio into propHeight
>   put the width of image pImageName into tWidth
>   put the height of image pImageName into tHeight
>   if propHeight > tHeight then
>  put tHeight into propH
>  put tHeight * pImageRatio into propW
>   else if propHeight < tHeight then
>  put propHeight into propH
>  put propH * pImageRatio into propW
>   else
>  put tWidth into propW
>  put tHeight into propH
>   end if
>   set the height of image pImageName to propH 
>   set the width of image pImageName to propW 
>   set the height of this stack to propH 
>   set the width of this stack to propW
>   set the topLeft of image pImageName to 0,0
> end propSizeImage
> 
> with the following initialisation in the stack script:
> 
> global gImageRatio
> 
> on preOpenStack
>   put the width of image "CoinSet" / the height of image "CoinSet" into 
> gImageRatio
> e

Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread J. Landman Gay via use-livecode

On 3/18/18 1:26 AM, hh via use-livecode wrote:

[Sorry lost above half of my answer.]

You could try the following with user's interaction:

For proportional resizing a stack window
hold the shiftkey down when resizing.

And in card's script add

on resizestack w,h
   set rect of img 1 to (0,0,w,h)
end resizestack


If Peter doesn't mind instructing his users to use the shift key, this 
would be a good solution.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread hh via use-livecode
[Sorry lost above half of my answer.]

You could try the following with user's interaction:

For proportional resizing a stack window
hold the shiftkey down when resizing.

And in card's script add

on resizestack w,h
  set rect of img 1 to (0,0,w,h)
end resizestack

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread hh via use-livecode
For proportional resizing a stack window
hold the shiftkey down when resizing.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Stupid Question Again - Proportional Scaling

2018-03-18 Thread J. Landman Gay via use-livecode

On 3/17/18 12:14 PM, Peter Reid via use-livecode wrote:

I have a sub-stack that contains an image.  I want the user to be able
to drag the corners and edges of the sub-stack window to make the window
and its image larger or smaller, but the window and image must maintain
their original aspect ratio – no stretching, no empty borders etc.



I wish we had a way to determine when a stack resize is finished. The 
best I could do is run a "send" loop to check the mouse state. Maybe 
someone else knows a better way. It doesn't seem possible to change the 
stack size within a resizeStack handler, which makes sense, so the 
adjustment has to be done afterward.


I think this sort of does what you want, but there's a "snap" at the end 
when the stack adjusts to the new image size. It accomodates images of 
any orientation.



constant kImgName = "coinSet"

on resizeStack pNewWidth, pNewHeight, pOldWidth, pOldHeight
  put the formattedWidth of img kImgName into tFWidth
  put the formattedHeight of img kImgName into tFHeight
  if tFHeight > tFWidth then
resizeToHeight tFHeight,tFWidth
  else
resizeToWidth tFHeight,tFWidth
  end if
  checkResizeDone
end resizeStack

on resizeToHeight tOrigImgHeight,tOrigImgWidth
  put the height of this cd/tOrigImgHeight  into tRatio
  put (tOrigImgWidth * tRatio) into tNewWidth
  put (tOrigImgHeight * tRatio) into tNewHeight
  set the rect of img kImgName to 0,0,tNewWidth,tNewHeight
end resizeToHeight

on resizeToWidth tOrigImgHeight,tOrigImgWidth
  put the width of this cd into tW
  put tW/tOrigImgWidth into tRatio
  put (tOrigImgWidth * tRatio) into tNewWidth
  put (tOrigImgHeight * tRatio) into tNewHeight
  set the rect of img kImgName to 0,0,tNewWidth,tNewHeight
end resizeToWidth

on checkResizeDone
  if the mouse is up then
set the rect of this stack to \
  (globalLoc(the topleft of img kImgName) & globalLoc(the 
bottomright of img kImgName))

  else
send "checkResizeDone" to me in 100 milliseconds
  end if
end checkResizeDone

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Stupid Question Again - Proportional Scaling

2018-03-17 Thread Peter Reid via use-livecode
I know it's possible and I know it's simple really, but I can't remember 
it/figure it out!

I have a sub-stack that contains an image.  I want the user to be able to drag 
the corners and edges of the sub-stack window to make the window and its image 
larger or smaller, but the window and image must maintain their original aspect 
ratio – no stretching, no empty borders etc.  I've tried the following in the 
card script:

global gImageRatio

on resizeStack pNewWidth, pNewHeight, pOldWidth, pOldHeight
   propSizeImage "coinSet", gImageRatio
   pass resizeStack
end resizeStack

on propSizeImage pImageName, @pImageRatio
   put the width of this stack into propWidth
   set the width of image pImageName to propWidth 
   put propWidth div pImageRatio into propHeight
   put the width of image pImageName into tWidth
   put the height of image pImageName into tHeight
   if propHeight > tHeight then
  put tHeight into propH
  put tHeight * pImageRatio into propW
   else if propHeight < tHeight then
  put propHeight into propH
  put propH * pImageRatio into propW
   else
  put tWidth into propW
  put tHeight into propH
   end if
   set the height of image pImageName to propH 
   set the width of image pImageName to propW 
   set the height of this stack to propH 
   set the width of this stack to propW
   set the topLeft of image pImageName to 0,0
end propSizeImage

with the following initialisation in the stack script:

global gImageRatio

on preOpenStack
   put the width of image "CoinSet" / the height of image "CoinSet" into 
gImageRatio
end preOpenStack

I'm probably missing something obvious, but can anyone help please?!

Thanks

Peter
--
Peter Reid
Loughborough, UK



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode