Multiple resolutions, resize stack a solution
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Multiple resolutions, resize stack a solution
one might take from your totally tubular post that a cat might place the script of the handler inside that openCard handler....but I might just be burnt out and not thinking correctly....
Re: Multiple resolutions, resize stack a solution
Hi guys,
sorry for being so sceptical about scaling datagrids
Best
Klaus
sorry for being so sceptical about scaling datagrids
Best
Klaus
Re: Multiple resolutions, resize stack a solution
Well that's just fine in my book....Up until you and simon showed me how to use the friggin things, I was banished to the world of using fields with list behaviors! I am just happy to finally have a small grasp on how they work....getting them to resize is a minor detail in my estimation. I can't sing the praises of the resize handler enough for rookies like myself. If you think about it, getting the stacks to resize is a more "advanced" option for people like me who have only been with LC and development for 2 years or less. I guess you can teach old dogs new tricks (like me at 38), but it takes time and lots and lots of reading. I know some will laugh at being old at 38, but if you think about it, I bet the average age of people developing on any platform is around 20...I more or less do this for fun with the hopes of striking gold, so coding for me is relinquished to the times the wife and kids are asleep and I'm not being accused of shutting myself in my office and ignoring everyone! lol....I very much appreciate the help received from vets like you and simon....
Re: Multiple resolutions, resize stack a solution
Hi Kenny,
if it helps: I am turning 57 this month, got my first computer (Mac LC) with 37 and started programming with 39
Best
Klaus
if it helps: I am turning 57 this month, got my first computer (Mac LC) with 37 and started programming with 39
Best
Klaus
Re: Multiple resolutions, resize stack a solution
That sounds just like me man...Just went rouge with Mac products in the house and pitched the PC's at 37....only reason I got a mac was to use it with LC and now it is the only thing I use....the pc gathers dust and only get dusted off when I need to test something I have created for PC... HA!
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Multiple resolutions, resize stack a solution
Hi Kenny,
Don't forget to write if adding the second loop fixed your card loading problem.
Simon
Don't forget to write if adding the second loop fixed your card loading problem.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Posts: 72
- Joined: Sat Apr 06, 2013 8:09 am
- Location: London
Re: Multiple resolutions, resize stack a solution
I've created an Android App with 5 Cards - do I have to go into every single card and cut and paste the output into a single stack as below?
Is there a way to create a single button that you just create once and it goes through all cards and works out the data needed?
Every single card in my application is the same width and height
on resizeStack
put the height of this stack into tHeight
put the width of this stack into tWidth
set the rect of image id 1006 of card id 1002 to round(0* tWidth),round(0* tHeight),round(1* tWidth),round(1* tHeight)
set the rect of button id 1013 of card id 1002 to round(0.295* tWidth),round(0.427* tHeight),round(0.705* tWidth),round(0.505* tHeight)
set the rect of button id 1014 of card id 1002 to round(0.295* tWidth),round(0.544* tHeight),round(0.705* tWidth),round(0.622* tHeight)
set the rect of button id 1015 of card id 1002 to round(0.298* tWidth),round(0.658* tHeight),round(0.708* tWidth),round(0.736* tHeight)
set the rect of button id 1016 of card id 1002 to round(0.298* tWidth),round(0.772* tHeight),round(0.708* tWidth),round(0.85* tHeight)
set the rect of button id 1017 of card id 1002 to round(0.288* tWidth),round(0.891* tHeight),round(0.698* tWidth),round(0.969* tHeight)
set the rect of image id 1007 of card id 1003 to round(0* tWidth),round(0* tHeight),round(1* tWidth),round(1* tHeight)
set the rect of button id 1018 of card id 1003 to round(0.7* tWidth),round(0.897* tHeight),round(0.99* tWidth),round(0.975* tHeight)
set the rect of image id 1008 of card id 1004 to round(0* tWidth),round(0* tHeight),round(1* tWidth),round(1* tHeight)
set the rect of button id 1019 of card id 1004 to round(0.7* tWidth),round(0.895* tHeight),round(0.99* tWidth),round(0.973* tHeight)
set the rect of button id 1024 of card id 1004 to round(0.598* tWidth),round(0.552* tHeight),round(0.943* tWidth),round(0.773* tHeight)
set the rect of image id 1009 of card id 1005 to round(0* tWidth),round(0* tHeight),round(1* tWidth),round(1* tHeight)
set the rect of button id 1020 of card id 1005 to round(0.686* tWidth),round(0.897* tHeight),round(0.976* tWidth),round(0.975* tHeight)
set the rect of button id 1023 of card id 1005 to round(0.225* tWidth),round(0.745* tHeight),round(0.785* tWidth),round(0.855* tHeight)
set the rect of image id 1011 of card id 1010 to round(0* tWidth),round(0* tHeight),round(1* tWidth),round(1* tHeight)
set the rect of button id 1021 of card id 1010 to round(0.7* tWidth),round(0.897* tHeight),round(0.99* tWidth),round(0.975* tHeight)
set the rect of button id 1022 of card id 1010 to round(0.225* tWidth),round(0.745* tHeight),round(0.785* tWidth),round(0.847* tHeight)
end resizeStack
Is there a way to create a single button that you just create once and it goes through all cards and works out the data needed?
Every single card in my application is the same width and height
on resizeStack
put the height of this stack into tHeight
put the width of this stack into tWidth
set the rect of image id 1006 of card id 1002 to round(0* tWidth),round(0* tHeight),round(1* tWidth),round(1* tHeight)
set the rect of button id 1013 of card id 1002 to round(0.295* tWidth),round(0.427* tHeight),round(0.705* tWidth),round(0.505* tHeight)
set the rect of button id 1014 of card id 1002 to round(0.295* tWidth),round(0.544* tHeight),round(0.705* tWidth),round(0.622* tHeight)
set the rect of button id 1015 of card id 1002 to round(0.298* tWidth),round(0.658* tHeight),round(0.708* tWidth),round(0.736* tHeight)
set the rect of button id 1016 of card id 1002 to round(0.298* tWidth),round(0.772* tHeight),round(0.708* tWidth),round(0.85* tHeight)
set the rect of button id 1017 of card id 1002 to round(0.288* tWidth),round(0.891* tHeight),round(0.698* tWidth),round(0.969* tHeight)
set the rect of image id 1007 of card id 1003 to round(0* tWidth),round(0* tHeight),round(1* tWidth),round(1* tHeight)
set the rect of button id 1018 of card id 1003 to round(0.7* tWidth),round(0.897* tHeight),round(0.99* tWidth),round(0.975* tHeight)
set the rect of image id 1008 of card id 1004 to round(0* tWidth),round(0* tHeight),round(1* tWidth),round(1* tHeight)
set the rect of button id 1019 of card id 1004 to round(0.7* tWidth),round(0.895* tHeight),round(0.99* tWidth),round(0.973* tHeight)
set the rect of button id 1024 of card id 1004 to round(0.598* tWidth),round(0.552* tHeight),round(0.943* tWidth),round(0.773* tHeight)
set the rect of image id 1009 of card id 1005 to round(0* tWidth),round(0* tHeight),round(1* tWidth),round(1* tHeight)
set the rect of button id 1020 of card id 1005 to round(0.686* tWidth),round(0.897* tHeight),round(0.976* tWidth),round(0.975* tHeight)
set the rect of button id 1023 of card id 1005 to round(0.225* tWidth),round(0.745* tHeight),round(0.785* tWidth),round(0.855* tHeight)
set the rect of image id 1011 of card id 1010 to round(0* tWidth),round(0* tHeight),round(1* tWidth),round(1* tHeight)
set the rect of button id 1021 of card id 1010 to round(0.7* tWidth),round(0.897* tHeight),round(0.99* tWidth),round(0.975* tHeight)
set the rect of button id 1022 of card id 1010 to round(0.225* tWidth),round(0.745* tHeight),round(0.785* tWidth),round(0.847* tHeight)
end resizeStack
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Multiple resolutions, resize stack a solution
Yup!Is there a way to create a single button that you just create once and it goes through all cards and works out the data needed?
Rats, was really hoping someone else would do this:
Code: Select all
on mouseUp
put the height of this stack into tHeight
put the width of this stack into tWidth
put "on resizeStack" & cr & "put the height of this stack into tHeight" & cr & "put the width of this stack into tWidth" & cr into tResize
repeat with N = 1 to the number of cards of this stack --new repeat line for multiple cards
repeat with i = 1 to the number of controls of cd N
put the long id of control i of cd N into tName
if tName = the long id of me then next repeat
put wordOffset("stack",tName) into tWord
put word 1 to (tWord -2) of tName into tName
put the rect of control i of cd N into tSize
put round(item 1 of tSize / tWidth,3) into tLeft
put round(item 2 of tSize /tHeight,3) into tTop
put round(item 3 of tSize / tWidth,3) into tRight
put round(item 4 of tSize / tHeight,3) into tBottom
put "set the rect of" && tName && "to" && "round(" & tLeft & "* tWidth)" & comma & "round(" & tTop & "* tHeight)" & comma & \
"round(" & tRight & "* tWidth)" & comma & "round(" & tBottom & "* tHeight)" & cr after tResize
end repeat
end repeat
put "end resizeStack" after tResize
set the clipboardData["text"] to tResize
answer information "The script has been copied to the clipboard, paste it into the stack script" titled "Now paste it"
end mouseUp
Kenny... are you watching?
Simon
edit code correction April '14
Last edited by Simon on Wed Apr 23, 2014 1:32 am, edited 1 time in total.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Posts: 72
- Joined: Sat Apr 06, 2013 8:09 am
- Location: London
Re: Multiple resolutions, resize stack a solution
Not sure if it worked 100% or not - I loaded up an old version of my App that I created before using your resizing script - added a button and ran the script and pasted the result as below.
But when I resize the card the image resized perfectly but some of the buttons I drew on top didn't move correctly.
I think it has something to do with preloading the card into memory - I think if the script is run before the Preload into memory function has been turned off it doesn't always work correctly.
is there a way to get the script to automatically turn off the preload into memory option for each card and also set the quality of every image from normal to Good - this would be a handy time saver
Right now I'm just creating very basic apps that provide people with information. The way I'm creating my Apps at present is to simply draw the screen out in a program similar to Photoshop using a canvas the same as my Samsung Galaxy note 800 wide by 1280 pixel tall and then export that as a PNG File and draw hidden or light coloured buttons over the top on the image in LiveCode. Pressing these buttons just takes you to another page or to a URL or Google Map.
I could export each button I draw but that's a lot more time consuming then simply drawing a hidden button over the top.
on resizeStack
put the height of this stack into tHeight
put the width of this stack into tWidth
set the rect of image id 1006 of card id 1002 to round(0* tWidth),round(0* tHeight),round(0.999* tWidth),round(1* tHeight)
set the rect of button id 1013 of card id 1002 to round(0.295* tWidth),round(0.427* tHeight),round(0.704* tWidth),round(0.505* tHeight)
set the rect of button id 1014 of card id 1002 to round(0.295* tWidth),round(0.544* tHeight),round(0.704* tWidth),round(0.622* tHeight)
set the rect of button id 1015 of card id 1002 to round(0.297* tWidth),round(0.658* tHeight),round(0.707* tWidth),round(0.736* tHeight)
set the rect of button id 1016 of card id 1002 to round(0.297* tWidth),round(0.772* tHeight),round(0.707* tWidth),round(0.85* tHeight)
set the rect of button id 1017 of card id 1002 to round(0.287* tWidth),round(0.891* tHeight),round(0.697* tWidth),round(0.969* tHeight)
set the rect of image id 1007 of card id 1003 to round(0* tWidth),round(0* tHeight),round(0.999* tWidth),round(1* tHeight)
set the rect of button id 1018 of card id 1003 to round(0.295* tWidth),round(0.427* tHeight),round(0.704* tWidth),round(0.505* tHeight)
set the rect of image id 1008 of card id 1004 to round(0* tWidth),round(0* tHeight),round(0.999* tWidth),round(1* tHeight)
set the rect of button id 1019 of card id 1004 to round(0.295* tWidth),round(0.427* tHeight),round(0.704* tWidth),round(0.505* tHeight)
set the rect of button id 1024 of card id 1004 to round(0.295* tWidth),round(0.544* tHeight),round(0.704* tWidth),round(0.622* tHeight)
set the rect of image id 1009 of card id 1005 to round(0* tWidth),round(0* tHeight),round(0.999* tWidth),round(1* tHeight)
set the rect of button id 1020 of card id 1005 to round(0.295* tWidth),round(0.427* tHeight),round(0.704* tWidth),round(0.505* tHeight)
set the rect of button id 1023 of card id 1005 to round(0.295* tWidth),round(0.544* tHeight),round(0.704* tWidth),round(0.622* tHeight)
set the rect of image id 1011 of card id 1010 to round(0* tWidth),round(0* tHeight),round(0.999* tWidth),round(1* tHeight)
set the rect of button id 1021 of card id 1010 to round(0.295* tWidth),round(0.427* tHeight),round(0.704* tWidth),round(0.505* tHeight)
set the rect of button id 1022 of card id 1010 to round(0.295* tWidth),round(0.544* tHeight),round(0.704* tWidth),round(0.622* tHeight)
end resizeStack
But when I resize the card the image resized perfectly but some of the buttons I drew on top didn't move correctly.
I think it has something to do with preloading the card into memory - I think if the script is run before the Preload into memory function has been turned off it doesn't always work correctly.
is there a way to get the script to automatically turn off the preload into memory option for each card and also set the quality of every image from normal to Good - this would be a handy time saver
Right now I'm just creating very basic apps that provide people with information. The way I'm creating my Apps at present is to simply draw the screen out in a program similar to Photoshop using a canvas the same as my Samsung Galaxy note 800 wide by 1280 pixel tall and then export that as a PNG File and draw hidden or light coloured buttons over the top on the image in LiveCode. Pressing these buttons just takes you to another page or to a URL or Google Map.
I could export each button I draw but that's a lot more time consuming then simply drawing a hidden button over the top.
on resizeStack
put the height of this stack into tHeight
put the width of this stack into tWidth
set the rect of image id 1006 of card id 1002 to round(0* tWidth),round(0* tHeight),round(0.999* tWidth),round(1* tHeight)
set the rect of button id 1013 of card id 1002 to round(0.295* tWidth),round(0.427* tHeight),round(0.704* tWidth),round(0.505* tHeight)
set the rect of button id 1014 of card id 1002 to round(0.295* tWidth),round(0.544* tHeight),round(0.704* tWidth),round(0.622* tHeight)
set the rect of button id 1015 of card id 1002 to round(0.297* tWidth),round(0.658* tHeight),round(0.707* tWidth),round(0.736* tHeight)
set the rect of button id 1016 of card id 1002 to round(0.297* tWidth),round(0.772* tHeight),round(0.707* tWidth),round(0.85* tHeight)
set the rect of button id 1017 of card id 1002 to round(0.287* tWidth),round(0.891* tHeight),round(0.697* tWidth),round(0.969* tHeight)
set the rect of image id 1007 of card id 1003 to round(0* tWidth),round(0* tHeight),round(0.999* tWidth),round(1* tHeight)
set the rect of button id 1018 of card id 1003 to round(0.295* tWidth),round(0.427* tHeight),round(0.704* tWidth),round(0.505* tHeight)
set the rect of image id 1008 of card id 1004 to round(0* tWidth),round(0* tHeight),round(0.999* tWidth),round(1* tHeight)
set the rect of button id 1019 of card id 1004 to round(0.295* tWidth),round(0.427* tHeight),round(0.704* tWidth),round(0.505* tHeight)
set the rect of button id 1024 of card id 1004 to round(0.295* tWidth),round(0.544* tHeight),round(0.704* tWidth),round(0.622* tHeight)
set the rect of image id 1009 of card id 1005 to round(0* tWidth),round(0* tHeight),round(0.999* tWidth),round(1* tHeight)
set the rect of button id 1020 of card id 1005 to round(0.295* tWidth),round(0.427* tHeight),round(0.704* tWidth),round(0.505* tHeight)
set the rect of button id 1023 of card id 1005 to round(0.295* tWidth),round(0.544* tHeight),round(0.704* tWidth),round(0.622* tHeight)
set the rect of image id 1011 of card id 1010 to round(0* tWidth),round(0* tHeight),round(0.999* tWidth),round(1* tHeight)
set the rect of button id 1021 of card id 1010 to round(0.295* tWidth),round(0.427* tHeight),round(0.704* tWidth),round(0.505* tHeight)
set the rect of button id 1022 of card id 1010 to round(0.295* tWidth),round(0.544* tHeight),round(0.704* tWidth),round(0.622* tHeight)
end resizeStack
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Multiple resolutions, resize stack a solution
That makes a 0 size control...set the rect of image id 1007 of card id 1003 to round(0* tWidth),round(0* tHeight)
Figure out why that is happening first. Must be that was their current size during the script building.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Multiple resolutions, resize stack a solution
Simon....I am ....well a disappointment ...I was hoping to get to this and make you proud but I failed! I'm going to go to the island of misfit coders...
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Multiple resolutions, resize stack a solution
Don't be silly Kenny,
You haven't whined once and that's great!
So many times people say "This command doesn't work, LC is broken".
Now that really gets my knickers in a twist.
Keep up the good work,
Simon
You haven't whined once and that's great!
So many times people say "This command doesn't work, LC is broken".
Now that really gets my knickers in a twist.
Keep up the good work,
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Multiple resolutions, resize stack a solution
G'day, and thank you Simon for the reSizer script.
I've written a stack that I wanted to run on 11", 13", & 15" notebooks, at 610 x 800, and also on an iPad at 768 x 800, so I had to re-write the reSizer so it only shrank vertically if on a smaller notebook, but resized horizontally on an iPad. Also, when icon containing buttons were resized, there was an 'overhang' of the active area.
So, this revised script not only resizes horizontally if on an iPad, but also relocates buttons with icons, rather than resizing them. You also get to choose if you want to resize buttons without icons.
Hope it's useful to someone!
Regards
Santa
I've written a stack that I wanted to run on 11", 13", & 15" notebooks, at 610 x 800, and also on an iPad at 768 x 800, so I had to re-write the reSizer so it only shrank vertically if on a smaller notebook, but resized horizontally on an iPad. Also, when icon containing buttons were resized, there was an 'overhang' of the active area.
So, this revised script not only resizes horizontally if on an iPad, but also relocates buttons with icons, rather than resizing them. You also get to choose if you want to resize buttons without icons.
Hope it's useful to someone!
Regards
Santa
Code: Select all
on mouseUp
answer "Do you want to resize buttons without icons?" with "No" or "Yes" or "Cancel"
if it = cancel then exit mouseup
put it into theButtonFlag
put the height of this stack into tHeight
put the width of this stack into tWidth
put "on resizeStack" & cr & "put the height of this stack into tHeight" & cr & "put the width of this stack into tWidth" & cr into tResize
put " if the environment = ""e& "mobile" "e&"then"&cr after tResize
repeat with thecard = 1 to number of cards of this stack
go to card thecard of this stack
repeat with i = 1 to the number of controls of this card
put the long id of control i into tName
if tName = the long id of me then next repeat
put wordOffset("stack",tName) into tWord
put word 1 to (tWord -2) of tName into tName
put the rect of control i into tSize
put round(item 1 of tSize / tWidth,3) into tLeft
put (item 2 of tSize ) into tTop
put round(item 3 of tSize / tWidth,3) into tRight
put (item 4 of tSize ) into tBottom
if word 1 of long id of control i is not "Button" or (theButtonFlag = "Yes" and the icon of control i is 0) then
put "set the rect of" && tName && "to" && "round(" & tLeft & "* tWidth)" & comma & " (" & tTop &")" & comma & \
"round(" & tRight & "* tWidth)" & comma & "(" & tBottom & ")" & cr after tResize
else
put "set the location of" && tName && "to" && "round(" & tLeft & "* tWidth)" &&"+"&&(item 3 of tSize-item 1 of tSize) div 2 +1\
& comma & " (" & tTop&&"+" && (tBottom-tTop)div 2 +1&")" & cr after tResize
end if
end repeat
end repeat
put "else" & cr after tResize
repeat with thecard = 1 to number of cards of this stack
go to card thecard of this stack
repeat with i = 1 to the number of controls of this card
put the long id of control i into tName
if tName = the long id of me then next repeat
put wordOffset("stack",tName) into tWord
put word 1 to (tWord -2) of tName into tName
put the rect of control i into tSize
put round(item 1 of tSize / tWidth,3) into tLeft
put round(item 2 of tSize /tHeight,3) into tTop
put round(item 3 of tSize / tWidth,3) into tRight
put round(item 4 of tSize / tHeight,3) into tBottom
put "set the rect of" && tName && "to" && "round(" & tLeft & "* tWidth)" & comma & "round(" & tTop & "* tHeight)" & comma & \
"round(" & tRight & "* tWidth)" & comma & "round(" & tBottom & "* tHeight)" & cr after tResize
end repeat
end repeat
put "end if" & cr after tResize
put "end resizeStack" after tResize
set the clipboardData["text"] to tResize
answer information "The script has been copied to the clipboard, paste it into the stack script" titled "Now paste it"
end mouseUp
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Multiple resolutions, resize stack a solution
Hey Santa,
Thanks for contributing to this code.
I wonder what LC's Resolution Independence will look like? Will it have options for cases like yours?
Simon
Thanks for contributing to this code.
I wonder what LC's Resolution Independence will look like? Will it have options for cases like yours?
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Mon Jul 31, 2006 1:39 am
- Location: New Zealand, Australia, Germany, Japan
- Contact:
Re: Multiple resolutions, resize stack a solution
G'day all
Just in case you weren't aware of it, Monte presented his scaling/resolution independent framework called mApp at the LC Developer conference a month or so ago. He has it available on his website at mergext.com
Definitely worth a look. I'm currently using it and hoping to get at least some starting docs done for it one of these days.
cheers
Alan
Just in case you weren't aware of it, Monte presented his scaling/resolution independent framework called mApp at the LC Developer conference a month or so ago. He has it available on his website at mergext.com
Definitely worth a look. I'm currently using it and hoping to get at least some starting docs done for it one of these days.
cheers
Alan